view yetilab/transform/test/test_fft.yeti @ 238:0c86d9284f20 sparse

Implement sparse matrix construction, add tests for sparse matrices (currently failing)
author Chris Cannam
date Mon, 20 May 2013 14:18:14 +0100
parents 77c6a81c577f
children 197d23954a4e
line wrap: on
line source

module yetilab.transform.test.test_fft;

{ realForward, realInverse } = load yetilab.transform.fft;
{ list, fromList } = load yetilab.vector.vector;
{ complex } = load yetilab.vector.complex;

{ compare } = load yetilab.test.test;

testFFT orig reals imags =
   (out = realForward (length orig) (fromList orig);
    back = realInverse (length orig) out;
    compare out (array (map2 complex reals imags)) and compare (list back) orig);

[

"dc": \(
    testFFT [1,1,1,1] [4,0,0] [0,0,0];
),

"sine": \(
    testFFT [0,1,0,-1] [0,0,0] [0,-2,0];
),

"cosine": \(
    testFFT [1,0,-1,0] [0,2,0] [0,0,0];
),

"sineCosine": \(
    testFFT [0.5,1,-0.5,-1] [0,1,0] [0,-2,0];
),

"nyquist": \(
    testFFT [1,-1,1,-1] [0,0,4] [0,0,0];
),

"dirac": \(
    testFFT [1,0,0,0] [1,1,1] [0,0,0] and
        testFFT [0,1,0,0] [1,0,-1] [0,-1,0] and
        testFFT [0,0,1,0] [1,-1,1] [0,0,0] and
        testFFT [0,0,0,1] [1,0,-1] [0,1,0];
),

] is hash<string, () -> boolean>;