36 #if defined (HAVE_FFTW)
37 #define FFTSRC "@sc{fftw}"
39 #define FFTSRC "@sc{fftpack}"
47 int nargin = args.
length ();
49 if (nargin < 1 || nargin > 3)
62 if (! args(1).is_empty ())
64 double dval = args(1).double_value ();
66 error (
"%s: number of points (N) cannot be NaN", fcn);
71 error (
"%s: number of points (N) must be greater than zero",
82 double dval = args(2).double_value ();
84 error (
"%s: DIM cannot be NaN", fcn);
85 else if (dval < 1 || dval > dims.
length ())
86 error (
"%s: DIM must be a valid dimension along which to perform FFT",
90 dim =
NINT (dval) - 1;
115 n_points = dims (dim);
117 dims (dim) = n_points;
119 if (dims.
any_zero () || n_points == 0)
204 @deftypefn {Built-in Function} {} fft (@var{x})\n\
205 @deftypefnx {Built-in Function} {} fft (@var{x}, @var{n})\n\
206 @deftypefnx {Built-in Function} {} fft (@var{x}, @var{n}, @var{dim})\n\
207 Compute the discrete Fourier transform of @var{A} using\n\
208 a Fast Fourier Transform (FFT) algorithm.\n\
210 The FFT is calculated along the first non-singleton dimension of the\n\
211 array. Thus if @var{x} is a matrix, @code{fft (@var{x})} computes the\n\
212 FFT for each column of @var{x}.\n\
214 If called with two arguments, @var{n} is expected to be an integer\n\
215 specifying the number of elements of @var{x} to use, or an empty\n\
216 matrix to specify that its value should be ignored. If @var{n} is\n\
217 larger than the dimension along which the FFT is calculated, then\n\
218 @var{x} is resized and padded with zeros. Otherwise, if @var{n} is\n\
219 smaller than the dimension along which the FFT is calculated, then\n\
220 @var{x} is truncated.\n\
222 If called with three arguments, @var{dim} is an integer specifying the\n\
223 dimension of the matrix along which the FFT is performed\n\
224 @seealso{ifft, fft2, fftn, fftw}\n\
227 return do_fft (args,
"fft", 0);
233 @deftypefn {Built-in Function} {} ifft (@var{x})\n\
234 @deftypefnx {Built-in Function} {} ifft (@var{x}, @var{n})\n\
235 @deftypefnx {Built-in Function} {} ifft (@var{x}, @var{n}, @var{dim})\n\
236 Compute the inverse discrete Fourier transform of @var{A}\n\
237 using a Fast Fourier Transform (FFT) algorithm.\n\
239 The inverse FFT is calculated along the first non-singleton dimension\n\
240 of the array. Thus if @var{x} is a matrix, @code{fft (@var{x})} computes\n\
241 the inverse FFT for each column of @var{x}.\n\
243 If called with two arguments, @var{n} is expected to be an integer\n\
244 specifying the number of elements of @var{x} to use, or an empty\n\
245 matrix to specify that its value should be ignored. If @var{n} is\n\
246 larger than the dimension along which the inverse FFT is calculated, then\n\
247 @var{x} is resized and padded with zeros. Otherwise, if @var{n} is\n\
248 smaller than the dimension along which the inverse FFT is calculated,\n\
249 then @var{x} is truncated.\n\
251 If called with three arguments, @var{dim} is an integer specifying the\n\
252 dimension of the matrix along which the inverse FFT is performed\n\
253 @seealso{fft, ifft2, ifftn, fftw}\n\
256 return do_fft (args,
"ifft", 1);
FloatComplexNDArray ifourier(int dim=1) const
FloatComplexNDArray fourier(int dim=1) const
ComplexNDArray complex_array_value(bool frc_str_conv=false) const
bool is_real_type(void) const
void gripe_wrong_type_arg(const char *name, const char *s, bool is_error)
OCTINTERP_API void print_usage(void)
octave_idx_type length(void) const
ComplexNDArray fourier(int dim=1) const
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
FloatComplexNDArray ifourier(int dim=1) const
FloatComplexNDArray fourier(int dim=1) const
static octave_value do_fft(const octave_value_list &args, const char *fcn, int type)
ComplexNDArray ifourier(int dim=1) const
FloatNDArray float_array_value(bool frc_str_conv=false) const
ComplexNDArray ifourier(int dim=1) const
FloatComplexNDArray float_complex_array_value(bool frc_str_conv=false) const
bool is_complex_type(void) const
void resize(const dim_vector &dv, const T &rfv)
bool any_zero(void) const
dim_vector dims(void) const
NDArray array_value(bool frc_str_conv=false) const
ComplexNDArray fourier(int dim=1) const
bool is_single_type(void) const
octave_idx_type NINTbig(double x)
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))