Exemplo n.º 1
0
bool test3() {
    FFT fft;

    vector<complex<double> > in, out, expected, temp;
    in.push_back(complex<double>(0.0,0.0));
    in.push_back(complex<double>(1.0,0.0));
    in.push_back(complex<double>(0.0,0.0));
    in.push_back(complex<double>(0.0,0.0));
    in.push_back(complex<double>(0.0,0.0));

    expected.push_back(complex<double>( 0.125,  0.0));
    expected.push_back(complex<double>( 0.088, -0.088));
    expected.push_back(complex<double>( 0.000, -0.125));
    expected.push_back(complex<double>(-0.088, -0.088));
    expected.push_back(complex<double>(-0.125,  0.0));
    expected.push_back(complex<double>(-0.088,  0.088));
    expected.push_back(complex<double>( 0.000,  0.125));
    expected.push_back(complex<double>( 0.088,  0.088));

    fft.FT(in,out);
    
    if (!checkEqual(expected,out)) {
	printError(expected,out);
	cout << __FILE__ << ": " << __LINE__ << endl;
	return false;
    } 
    
    fft.inverseFT(out, temp);

    return true;

}
Exemplo n.º 2
0
bool test1() {
    FFT fft;
    vector<complex<double> > in, out, expected, temp;
    in.push_back(complex<double>(1.0,0.0));
    in.push_back(complex<double>(0.0,0.0));
    in.push_back(complex<double>(0.0,0.0));
    in.push_back(complex<double>(0.0,0.0));
    in.push_back(complex<double>(0.0,0.0));
    in.push_back(complex<double>(0.0,0.0));
    in.push_back(complex<double>(0.0,0.0));
    in.push_back(complex<double>(0.0,0.0));

    expected.push_back(complex<double>(0.125,0.0));
    expected.push_back(complex<double>(0.125,0.0));
    expected.push_back(complex<double>(0.125,0.0));
    expected.push_back(complex<double>(0.125,0.0));
    expected.push_back(complex<double>(0.125,0.0));
    expected.push_back(complex<double>(0.125,0.0));
    expected.push_back(complex<double>(0.125,0.0));
    expected.push_back(complex<double>(0.125,0.0));

    fft.FT(in,out);
    
    if (!checkEqual(expected,out)) {
	printError(expected,out);
	return false;
    } 

    fft.inverseFT(out, temp);

    if (!checkEqual(in,temp)) {
	printError(in,temp);
	return false;
    }

    return true;
    
}