bukka / php-fftw

PHP Wrapper for FFTW library
Other
3 stars 1 forks source link

Test cases - phpt files #2

Open rspadim opened 10 years ago

rspadim commented 10 years ago

1) basically tests to create and destroy fftw objects/resources 2) about testing results... the idea is a test that cover some %of error, we will use MSE (mean square error) of a know result, and the fftw result, and check return length, for example:

$fft_array=fft_plan()... fft_execute() ... fft_result() check_return($fft_array, array( 0, 10 , 20 , 30 ... know values) );

function check_return($return_array,$know_return_array){ $expected_individual_SE=0.00001; // must check a good value $expected_total_MSE=0.00001; // must check a good value

if(count($return_array) != length($know_return_array)) return("Different array size ("count($return_array)") != (".length($know_return_array).")"); $total_MSE=0; foreach($return_array as $k=>$v){ if(!isset($know_return_array[$k])) return("Unknow [$k] index inside result array"); $curSE=sqrt(($v$v)-($know_returnarray[$k]$know_return_array[$k])); if ($cur_SE>$expected_individual_SE) return("Square error ($cur_SE) of [$k] index, bigger than allowed error ($expected_individual_SE)"); $totalMSE+=(($v$v)-($know_returnarray[$k]$know_return_array[$k])); } $total_MSE=sqrt($total_MSE / count($return_array) ); if ($total_MSE>$expected_total_MSE) return("Mean Square Error ($total_MSE) bigger than allowed error ($expected_total_MSE)"); return true; }

3) testing fft must check another feature, the "normal" fft and the inverse fft, one must me near to another, for example $signal = ifft(fft($signal))

in this case we can test fft($signal) and check if (2 test) is ok, and check ifft(fft($signal)) is ok with the original $signal value

here we use original $signal to the the inverse fft function

rspadim commented 10 years ago

found some well know test cases: http://www.sccon.ca/sccon/fft/fft3.htm

...searching others test cases... http://www.arachnoid.com/signal_processing/fft.html http://calculator.vhex.net/calculator/fast-fourier-transform-calculator-fft/1d-discrete-fourier-transform http://www.sooeet.com/math/online-fft-calculator.php http://scistatcalc.blogspot.com.br/2013/12/fft-calculator.html http://home.fuse.net/clymer/graphs/fourier.html

rspadim commented 10 years ago

sent a pull request from first fftw return test case (003.phpt and common.php)

rspadim commented 10 years ago

a nice test example write in c http://people.sc.fsu.edu/~jburkardt/c_src/fftw3/fftw3.html http://people.sc.fsu.edu/~jburkardt/c_src/fftw3/fftw3_prb.c