tftest.cpp

Go to the documentation of this file.
00001 #include "TimeFrequency.h"
00002 #include "StackedSpectrum.h"
00003 #include "UniformRNG.h"
00004 #include "types.h"
00005 #include "WFunc.h"
00006 #include <iostream>
00007 #include "VecMat.h"
00008 #include <gsl/gsl_math.h>
00009 using namespace std;
00010 int main()
00011 {
00012         const double tolerance = 1e-6;
00013         const int runs = 100;
00014         const int maxseg = 1000;
00015 
00016         UniformRNG Random;
00017 
00018         for (int r = 0; r < runs; ++r)
00019         {
00020                 const int length = Random.GetNumber(maxseg * 500);
00021                 const int seglength = Random.GetNumber(maxseg) +10;
00022                 const int speclength = seglength/2+1;
00023                 ttsdata Input(length);
00024                 tcompdata Spectrum(seglength/2+1);
00025 
00026                 cout << "Run: " << r << "       ";
00027                 cout << "Ts length: " << length << " Seglength: " << seglength << "     ";
00028                 bool runok = true;
00029                 for (int i = 0; i < length; ++i)
00030                         Input.at(i) = Random.GetNumber();
00031                 try
00032                 {
00033                         gplib::cmat result =
00034                                 TimeFrequency(Input.begin(), Input.end(), seglength, Hamming());
00035                         StackedSpectrum(Input.begin(), Input.end(), Spectrum.begin(),seglength, Hamming());
00036                         gplib::cvec tfstack
00037                                 = prod( boost::numeric::ublas::scalar_vector<double>(length/seglength,1.0),result);
00038                         cout << "Matrix   Rows: " << result.size1() << " Columns: " << result.size2() << endl;
00039                         cout << "tfstack size: " << tfstack.size() << endl;
00040                         for (int i = 0; i < speclength; ++i)
00041                         {
00042                                 if ((gsl_fcmp(Spectrum.at(i).real(),tfstack(i).real(),tolerance) != 0) ||
00043                                         (gsl_fcmp(Spectrum.at(i).imag(),tfstack(i).imag(),tolerance) != 0))
00044                                 {
00045                                 cout << endl;
00046                                 cout << i << " " << Spectrum.at(i) << " " << tfstack(i) << endl;
00047                                 runok = false;
00048                                 }
00049                         }
00050                 }
00051                 catch(CFatalException &e)
00052                 {
00053                         cout << e.what() << "     ";
00054                         runok = false;
00055                 }
00056                 if (runok)
00057                         cout << "Run OK !" << endl;
00058                 else
00059                         cout << "Run failed !" << endl;
00060         }
00061         cout << "All finished !" << endl;
00062 }

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