// fft_test.cc -- test of a memory leak // To use this file, your version of Octave must support dynamic // linking. To find out if it does, type the command // // x = octave_config_info; x.DEFS // // at the Octave prompt. Support for dynamic linking is included if // the output contains the string -DWITH_DYNAMIC_LINKING=1. // // To compile this file, type the command // // mkoctfile --verbose fft_test.cc // // at the shell prompt. The script mkoctfile should have been // installed along with Octave. Running it will create a file called // fft_test.oct that can be loaded by Octave. // // Enter: // // help fft_test // // at the Octave prompt to have a description of how fft_test should be used. // // This file may be used under the terms defined by the GNU // General Public License [write to the Free Software Foundation, // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA] // // WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // // #include #include #include #include #include #include #include #include #include #include #include DEFUN_DLD (fft_test, args, , "test for a memory leak") { octave_value_list retval; /*----------- get input parameters ----------------*/ int nargin = args.length (); if (nargin < 1) { error("Usage: fft_test(x)"); return retval; } ColumnVector x(args(0).vector_value()); int N=x.length(); double *in = x.fortran_vec(); fftw_complex* out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N); if (out == NULL) return retval; fftw_plan planF = fftw_plan_dft_r2c_1d (N, in, out, FFTW_ESTIMATE); if (planF == NULL) return retval; fftw_plan planB = fftw_plan_dft_c2r_1d (N, out, in, FFTW_ESTIMATE); // if (planB == NULL) return retval; // fftw_execute(planF); fftw_execute(planB); // fftw_destroy_plan(planF); fftw_destroy_plan(planB); // fftw_cleanup(); fftw_free(out); out=NULL; retval(0)=x; return retval; }