676
|
1 // f-ifft2.cc -*- C++ -*- |
|
2 /* |
|
3 |
1009
|
4 Copyright (C) 1994, 1995 John W. Eaton |
676
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include "config.h" |
|
26 #endif |
|
27 |
|
28 #include "dMatrix.h" |
|
29 #include "CMatrix.h" |
|
30 |
|
31 #include "tree-const.h" |
|
32 #include "user-prefs.h" |
|
33 #include "gripes.h" |
|
34 #include "error.h" |
|
35 #include "utils.h" |
|
36 #include "help.h" |
|
37 #include "defun-dld.h" |
|
38 |
|
39 // This function should be merged with Ffft2. |
|
40 |
701
|
41 DEFUN_DLD_BUILTIN ("ifft2", Fifft2, Sifft2, 3, 1, |
676
|
42 "ifft2 (X [, N] [, M])\n\ |
|
43 \n\ |
|
44 two dimensional inverse fast fourier transform of a vector") |
|
45 { |
|
46 Octave_object retval; |
|
47 |
|
48 int nargin = args.length (); |
|
49 |
712
|
50 if (nargin < 1 || nargin > 3) |
676
|
51 { |
|
52 print_usage ("ifft2"); |
|
53 return retval; |
|
54 } |
|
55 |
712
|
56 tree_constant arg = args(0); |
676
|
57 |
|
58 int n_rows = arg.rows (); |
712
|
59 if (nargin > 1) |
|
60 n_rows = NINT (args(1).double_value ()); |
676
|
61 |
|
62 if (error_state) |
|
63 return retval; |
|
64 |
|
65 int n_cols = arg.columns (); |
712
|
66 if (nargin > 2) |
|
67 n_cols = NINT (args(2).double_value ()); |
676
|
68 |
|
69 if (error_state) |
|
70 return retval; |
|
71 |
|
72 if (n_rows < 0 || n_cols < 0) |
|
73 { |
|
74 error ("ifft2: number of points must be greater than zero"); |
|
75 return retval; |
|
76 } |
|
77 |
|
78 int arg_is_empty = empty_arg ("ifft2", arg.rows (), arg.columns ()); |
|
79 |
|
80 if (arg_is_empty < 0) |
|
81 return retval; |
|
82 else if (arg_is_empty || n_rows == 0 || n_cols == 0) |
|
83 return Matrix (); |
|
84 |
|
85 if (arg.is_real_type ()) |
|
86 { |
|
87 Matrix m = arg.matrix_value (); |
|
88 |
|
89 if (! error_state) |
|
90 { |
|
91 m.resize (n_rows, n_cols, 0.0); |
|
92 retval = m.ifourier2d (); |
|
93 } |
|
94 } |
|
95 else if (arg.is_complex_type ()) |
|
96 { |
|
97 ComplexMatrix m = arg.complex_matrix_value (); |
|
98 |
|
99 if (! error_state) |
|
100 { |
|
101 m.resize (n_rows, n_cols, 0.0); |
|
102 retval = m.ifourier2d (); |
|
103 } |
|
104 } |
|
105 else |
|
106 { |
|
107 gripe_wrong_type_arg ("ifft2", arg); |
|
108 } |
|
109 |
|
110 return retval; |
|
111 } |
|
112 |
|
113 /* |
|
114 ;;; Local Variables: *** |
|
115 ;;; mode: C++ *** |
|
116 ;;; page-delimiter: "^/\\*" *** |
|
117 ;;; End: *** |
|
118 */ |