spectest.cpp

Go to the documentation of this file.
00001 #include "TsSpectrum.h"
00002 #include "UniformRNG.h"
00003 #include "types.h"
00004 #include <iostream>
00005 #include <gsl/gsl_math.h>
00006 
00007 using namespace std;
00008 int main()
00009 {
00010         const double tolerance = 1e-6;
00011         const bool MultiCalc = false;
00012         const int length = 20000;
00013         const int runs = 100;
00014         ttsdata Input(length), Recovered(length);
00015         tcompdata Spectrum(length/2+1);
00016         UniformRNG Random;
00017         for (int r = 0; r < runs; ++r)
00018         {
00019                 cout << "Run: " << r << "       ";
00020                 bool runok = true;
00021                 for (int i = 0; i < length; ++i)
00022                         Input.at(i) = Random.GetNumber();
00023                 TsSpectrum SpecCalc(MultiCalc);
00024                 SpecCalc.CalcSpectrum(Input.begin(),Input.end(),Spectrum.begin(),Spectrum.end());
00025                 SpecCalc.CalcTimeSeries(Spectrum.begin(),Spectrum.end(),Recovered.begin(),Recovered.end());
00026                 for (int i = 0; i < length; ++i)
00027                 {
00028                         if (gsl_fcmp(Input.at(i),Recovered.at(i),tolerance) != 0)
00029                         {
00030                                 cout << endl;
00031                                 cout << i << " " << Input.at(i) << " " << Recovered.at(i) << endl;
00032                                 runok = false;
00033                         }
00034                 }
00035                 if (runok)
00036                         cout << "Run OK !" << endl;
00037                 else
00038                         cout << "Run failed !" << endl;
00039         }
00040         cout << "All finished !" << endl;
00041 }

Generated on Mon Sep 15 12:54:34 2008 for GPLIB++ by  doxygen 1.5.5