From octave-sources-request at bevo dot che dot wisc dot edu Wed Aug 6 09:49:00 2003 Subject: Re: results with strange floating-point number bias From: nwerneck at cefala dot org To: octave-sources at bevo dot che dot wisc dot edu Date: Wed, 6 Aug 2003 11:49:13 -0300 --+HP7ph2BbKc20aGI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Here is the source code of the funtion. I'm compiling it with mkoctfile-2.1.50 fftnic.cc -L$(HOME)/lib -I$(HOME)/include -lfftw3 -lstdc++-3-libc6.2-2-2.10.0 -- Nicolau Werneck 9F99 25AB E47E 8724 2F71 http://cefala.org/~nwerneck EA40 DC23 42CE 6B76 B07F "To his dog, every man is Napoleon; hence the constant popularity of dogs." -- Aldous Huxley --+HP7ph2BbKc20aGI Content-Type: text/x-c++src; charset=us-ascii Content-Disposition: attachment; filename="fftnic.cc" #include "/home/nwerneck/include/octave-2.1.50/octave/oct.h" #include "/home/nwerneck/include/octave-2.1.50/octave/oct-cmplx.h" #include "/home/nwerneck/include/fftw3.h" DEFUN_DLD(fftnic, args, , "-*- texinfo -*-\n\ at deftypefn {Loadable Function} {} overdrive (@var{signal}, @var{a}, @var{b})\n\ Distorted amplification function. This function emulates an overdriven\n\ amplifier circuit or speaker, multiplying the input signal by at var{b}/@var{a}\n\ when the absolute value of the signal is smaller than at var{a}, and by a smaller\n\ amount when the signal exceeds the linearity treshold.\n\ \n\ The resulting input-output characteristic curve is simply a straight line\n\ from (0,0) to ( at var{a},@var{b}) and then to (1,1).\n\ The command\n\ > plot(overdrive([-1:0.1:1]', 0.25, 0.75)); will produce a example plot of the input-output characteristic curve of an\n\ overdrive effect.\n\ > overdrive(sin([0:0.1:2*pi]'), 0, 1) will produce a square wave, Cross-over occurs when at var{a} > @var{b}. The command\n\ > overdrive(sin([0:0.1:2*pi]'), 0.1, 0) will return a sinusoidal signal with cross-over distortion. at end deftypefn") { // double * teste; octave_value retval; fftw_plan ftp; if (args.length () != 1) { print_usage ("fftnic"); return retval; } if(!args(0).is_real_matrix()) { gripe_wrong_type_arg("fftnic", args(0)); return retval; } Matrix m = args(0).matrix_value(); ComplexMatrix sai; ComplexColumnVector ccv( (m.rows()/2)+1 ); ftp = fftw_plan_dft_r2c_1d(m.column(0).length(), \ m.column(0).fortran_vec(), \ reinterpret_cast (ccv.fortran_vec() ),\ FFTW_ESTIMATE ); fftw_execute(ftp); //sai = ComplexMatrix(ccv); fftw_destroy_plan(ftp); return octave_value(ccv); } --+HP7ph2BbKc20aGI--