testkhl.cpp

Go to the documentation of this file.
00001 #include "KHL.h"
00002 #include "statutils.h"
00003 #include "UniformRNG.h"
00004 #include "VecMat.h"
00005 #include <iostream>
00006 #include <fstream>
00007 #include <algorithm>
00008 #include <iterator>
00009 #include <string>
00010 
00011 using namespace std;
00012 int main()
00013 {
00014         UniformRNG Random;
00015         
00016         
00017         string name;
00018         cout << "Infile: ";
00019         cin >> name;
00020         ifstream file(name.c_str());
00021         vector<double> in((istream_iterator<double>(file)), istream_iterator<double>());
00022         
00023         
00024         const size_t nobs = in.size();
00025         rvec input(nobs), eval(nobs);
00026         rmat evec(nobs,nobs);
00027         copy(in.begin(),in.end(),input.begin());
00028         
00029    
00030         KHLExpand(input,evec,eval);
00031         int index = 0;
00032         double biggest = eval(0);
00033         for (int i = 0; i < eval.size(); ++i)
00034                 if (eval(i) > biggest)
00035                 {
00036                         index = i;
00037                         biggest = eval(i);
00038                 }
00039         
00040         std::ofstream khloutfile("khl.out");
00041         copy(column(evec,index).begin(),column(evec,index).end(),std::ostream_iterator<double>(khloutfile,"\n"));
00042         std::ofstream khlinfile("khl.in");
00043         copy(input.begin(),input.end(),std::ostream_iterator<double>(khlinfile,"\n"));
00044         sort(eval.begin(),eval.end());
00045         std::ofstream khlevalfile("khl.eval");
00046         copy(eval.begin(),eval.end(),std::ostream_iterator<double>(khlevalfile,"\n"));
00047         //std::cout << "Input: " << input << std::endl;
00048         //std::cout << "Evec: " << evec << std::endl;
00049         //std::cout << "Eval: " << eval << std::endl;
00050         //std::cout << "Rec: " << prod(evec,eval) << std::endl;
00051 }

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