7
|
1 // f-ifft.cc -*- C++ -*- |
1
|
2 /* |
|
3 |
453
|
4 Copyright (C) 1993, 1994 John W. Eaton |
1
|
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 |
240
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include "config.h" |
1
|
26 #endif |
|
27 |
453
|
28 #include "dMatrix.h" |
|
29 #include "CMatrix.h" |
1
|
30 |
|
31 #include "tree-const.h" |
|
32 #include "user-prefs.h" |
|
33 #include "gripes.h" |
|
34 #include "error.h" |
519
|
35 #include "defun-dld.h" |
1
|
36 |
519
|
37 DEFUN_DLD ("ifft", Fifft, Sifft,2, 1, |
|
38 "ifft (X): inverse fast fourier transform of a vector") |
1
|
39 { |
519
|
40 Octave_object retval; |
|
41 |
|
42 int nargin = args.length (); |
1
|
43 |
519
|
44 if (nargin != 2) |
|
45 { |
|
46 print_usage ("ifft"); |
|
47 return retval; |
|
48 } |
1
|
49 |
519
|
50 tree_constant tmp = args(1).make_numeric (); |
1
|
51 |
|
52 if (tmp.rows () == 0 || tmp.columns () == 0) |
|
53 { |
|
54 int flag = user_pref.propagate_empty_matrices; |
|
55 if (flag != 0) |
|
56 { |
|
57 if (flag < 0) |
|
58 gripe_empty_arg ("ifft", 0); |
519
|
59 |
|
60 retval.resize (1, Matrix ()); |
1
|
61 } |
|
62 else |
|
63 gripe_empty_arg ("ifft", 1); |
|
64 |
|
65 return retval; |
|
66 } |
|
67 |
|
68 switch (tmp.const_type ()) |
|
69 { |
|
70 case tree_constant_rep::matrix_constant: |
|
71 { |
|
72 Matrix m = tmp.matrix_value (); |
|
73 ComplexMatrix mifft = m.ifourier (); |
516
|
74 retval = mifft; |
1
|
75 } |
|
76 break; |
|
77 case tree_constant_rep::complex_matrix_constant: |
|
78 { |
|
79 ComplexMatrix m = tmp.complex_matrix_value (); |
|
80 ComplexMatrix mifft = m.ifourier (); |
516
|
81 retval = mifft; |
1
|
82 } |
|
83 break; |
|
84 case tree_constant_rep::scalar_constant: |
|
85 case tree_constant_rep::complex_scalar_constant: |
|
86 error ("ifft: invalid scalar arguement"); |
|
87 break; |
|
88 default: |
|
89 panic_impossible (); |
|
90 break; |
|
91 } |
|
92 return retval; |
|
93 } |
|
94 |
|
95 /* |
|
96 ;;; Local Variables: *** |
|
97 ;;; mode: C++ *** |
|
98 ;;; page-delimiter: "^/\\*" *** |
|
99 ;;; End: *** |
|
100 */ |