File: fft2.sci

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (49 lines) | stat: -rw-r--r-- 1,729 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function x=fft2(varargin)
// Copyright INRIA
// Two-dimensional fast Fourier transform
// Syntax : y = fft2(x) or y = fft2(x,m,n)
// Inputs :
// x : scalar, vector, matrix, array (real or complex) 
// m, n : numbers (respectively) of rows and colums of x which used for the perfom of DFT,if the rows number respectively (columns) of x is more than m then x is truncated in order to have m rows, else if the rows (respectively columns) number of x is less than m then x rows are completed by 0 to have m rows.
//
// Outputs :
// y : scalar, vector, matrix, array (real or complex), if there is one input argument x then y and x have the same size, else if there are 3 inputs arguments then the sizes of the first and second dimension of y are equal to m and n, the others dimension sizes are equal to the size of x
// F.B

if size(varargin) == 1 then
  a = varargin(1);
  if type(a) == 1 then
    x = fft(a);
  elseif typeof(a) == 'hypermat' then
    dims = matrix(x.dims,-1,1);
    v = matrix(x.entries,-1,1);
    incr = 1;
    for k=1:2
      dk = double(dims(k));
      v = fft(v ,-1,dk,incr);
      incr = incr*dk;
    end
    x = matrix(v,double(dims));
  end
elseif size(varargin) == 3 then
  a = varargin(1);
  m = varargin(2);
  n = varargin(3);
  asize1 = size(a,1);
  asize2 = size(a,2);
  if type(a) == 1 then
    x(1:min(m,asize1),1:asize2)=a(1:min(m,asize1),1:asize2);
  elseif typeof(a) == 'hypermat' then
    dims = matrix(a.dims,-1,1);
    dims = double(dims);
    dims(1) = m;
    dims(2) = n;
    x=hypermat(dims)
    for i=1:prod(dims(3:$))
      x(1:min(m,asize1),1:min(n,asize2),i)=a(1:min(m,asize1),1:min(n,asize2),i);
    end
  end
  x=fft2(x);
else error("wrong number of input arguments");
end
endfunction