mtupca.cpp

Go to the documentation of this file.
00001 #include "PCA.h"
00002 #include "statutils.h"
00003 #include "VecMat.h"
00004 #include "TimeSeriesData.h"
00005 #include <iostream>
00006 #include <fstream>
00007 #include <vector>
00008 
00009 int main()
00010 {
00011         TimeSeriesData TsData;
00012         std::string mtuname;
00013         
00014         std::cout << "Data file name: ";
00015         std::cin >> mtuname;
00016         
00017         
00018         TsData.GetData(mtuname);
00019         
00020         
00021         const size_t nobs = TsData.GetData().Size();
00022         const size_t nchan = 4;
00023         gplib::rmat input(nchan,nobs);
00024         gplib::cmat evec(nchan,nchan);
00025         gplib::cvec eval(nchan);
00026         
00027         for (unsigned int i = 0; i < nobs; ++i)
00028         {
00029                 input(0,i) = TsData.GetData().GetEx().GetData().at(i);
00030                 input(1,i) =    TsData.GetData().GetEy().GetData().at(i);
00031                 input(2,i) = TsData.GetData().GetHx().GetData().at(i);
00032                 input(3,i) = TsData.GetData().GetHy().GetData().at(i);
00033         }
00034     
00035     PCA(input,evec,eval);
00036         
00037         gplib::cmat wmat(WhiteMat(evec, eval));
00038         std::cout << "pca evec: " << evec << std::endl;
00039         std::cout << "pca eval: " << eval << std::endl;
00040         std::cout << "pca WhM: " << wmat << std::endl;
00041         std::cout << "pca DeWhM: " << DeWhiteMat(evec, eval) << std::endl;
00042         
00043         gplib::cmat output(nchan,nobs);
00044         noalias(output) = prec_prod(wmat,input);
00045         for (unsigned int i = 0; i < nobs; ++i)
00046         {
00047                 TsData.GetData().GetEx().GetData().at(i) = output(0,i).real();
00048                 TsData.GetData().GetEy().GetData().at(i) = output(1,i).real();
00049                 TsData.GetData().GetHx().GetData().at(i) = output(2,i).real();
00050                 TsData.GetData().GetHy().GetData().at(i) = output(3,i).real();
00051         }
00052         TsData.WriteAsBirrp(mtuname+".pca");
00053 }

Generated on Fri Jul 4 15:30:21 2008 for GPLIB++ by  doxygen 1.5.5