1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2012 - INRIA - Serge STEER
4//
5//  This file is distributed under the same license as the Scilab package.
6// =============================================================================
7
8// <-- CLI SHELL MODE -->
9
10//R2R case  ------------------------------------------------------------------------------------
11A=[0   1 2 2 1
12   2  -1 3 3 -1
13   3   4 5 5  4
14   2  -1 3 3 -1];
15
16Dims=[4 5];
17Sel=1;
18y=fft(A,-1,Sel);
19assert_checktrue(isreal(y));
20for j=1:Dims(2)
21  ind=list(:,j);
22  assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1));
23end
24y=fft(y,1,Sel);
25assert_checktrue(isreal(y));
26for j=1:Dims(2)
27  ind=list(:,j);
28  assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps);
29end
30
31Sel=2;
32y=fft(A,-1,Sel);
33assert_checktrue(isreal(y));
34for i=1:Dims(1)
35  ind=list(i,:);
36  assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1));
37end
38y=fft(y,1,Sel);
39assert_checktrue(isreal(y));
40for i=1:Dims(1)
41  ind=list(i,:);
42  assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps);
43end
44
45//ND case
46A=[0   1   1
47   2  -1  -1
48   3   4   4
49   2  -1  -1];
50A(:,:,2)=A+1;
51A(:,:,3)=A(:,:,2);
52
53Dims=size(A);
54Sel=1;
55y=fft(A,-1,Sel);
56assert_checktrue(isreal(y));
57for j=1:Dims(2)
58  for k=1:Dims(3)
59    ind=list(:,j,k);
60    assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1));
61  end
62end
63
64y=fft(y,1,Sel);
65assert_checktrue(isreal(y));
66for j=1:Dims(2)
67  for k=1:Dims(3)
68    ind=list(:,j,k);
69    assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps);
70  end
71end
72
73Sel=1:2;
74y=fft(A,-1,Sel);
75assert_checktrue(isreal(y));
76for k=1:Dims(3)
77  ind=list(:,:,k);
78  assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1));
79end
80
81y=fft(y,1,Sel);
82assert_checktrue(isreal(y));
83for k=1:Dims(3)
84  ind=list(:,:,k);
85  assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps);
86end
87
88Sel=2:3;
89y=fft(A,-1,Sel);
90assert_checktrue(isreal(y));
91for i=1:Dims(1)
92  ind=list(i,:,:);
93  assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1));
94end
95y=fft(y,1,Sel);
96assert_checktrue(isreal(y));
97for i=1:Dims(1)
98  ind=list(i,:,:);
99  assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps);
100end
101
102Dims=[5 4 9 5 6];
103A=matrix(rand(1,prod(Dims)),Dims);
104y=fft(A,-1,[2 4]);
105for i1=1:Dims(1)
106  for i3=1:Dims(3)
107    for i5=1:Dims(5)
108      ind=list(i1,:,i3,:,i5);;
109      assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1));
110    end
111  end
112end
113y1=fft(y,1,[2 4]);
114assert_checktrue(isreal(y1));
115assert_checkalmostequal(y1,A);
116
117
118y=fft(A,-1,[2 4 5]);
119for i1=1:Dims(1)
120  for i3=1:Dims(3)
121    ind=list(i1,:,i3,:,:);
122    assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1));
123  end
124end
125y1=fft(y,1,[2 4 5]);
126assert_checktrue(isreal(y1));
127assert_checkalmostequal(y1,A);
128
129
130Dims=[5 4 7 5 6 3];
131A=matrix(rand(1,prod(Dims)),Dims);
132y=fft(A,-1,[2 5]);
133for i1=1:Dims(1)
134  for i3=1:Dims(3)
135    for i4=1:Dims(4)
136      for i6=1:Dims(6)
137        ind=list(i1,:,i3,i4,:,i6);
138        assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1));
139      end
140    end
141  end
142end
143
144y1=fft(y,1,[2 5]);
145assert_checktrue(isreal(y1));
146assert_checkalmostequal(y1,A);
147
148
149y=fft(A,-1,[2 4 6]);
150for i1=1:Dims(1)
151  for i3=1:Dims(3)
152    for i5=1:Dims(5)
153      ind=list(i1,:,i3,:,i5,:);
154      assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1));
155    end
156  end
157end
158y1=fft(y,1,[2 4 6]);
159assert_checktrue(isreal(y1));
160assert_checkalmostequal(y1,A);
161
162y=fft(A,-1,[2 4 5 6]);
163for i1=1:Dims(1)
164  for i3=1:Dims(3)
165    ind=list(i1,:,i3,:,:,:);
166    assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1));
167  end
168end
169y1=fft(y,1,[2 4 5 6]);
170assert_checktrue(isreal(y1));
171assert_checkalmostequal(y1,A);
172