mtnullspace.cpp

Go to the documentation of this file.
00001 #include "C1DMTObjective.h"
00002 #include "MTRecObjective.h"
00003 #include "SeismicDataComp.h"
00004 #include "GradFunc.h"
00005 #include "CUniformRNG.h"
00006 #include "convert.h"
00007 #include <iostream>
00008 #include <fstream>
00009 #include <boost/numeric/ublas/io.hpp>
00010 #include <boost/numeric/bindings/lapack/lapack.hpp>
00011 #include <boost/numeric/bindings/traits/ublas_matrix.hpp>
00012 #include <boost/numeric/bindings/traits/ublas_vector.hpp>
00013 #include <boost/numeric/ublas/banded.hpp>
00014 #include <algorithm>
00015 
00016 using namespace std;
00017 int main()
00018 {
00019         const int nparam = 6;
00020         const int nsamples = 10;
00021         CMTStation MTData;
00022         SeismicDataComp RecData;
00023         RecData.GetData("test.rec");
00024         MTData.GetData("test.mtt"); //
00025         C1DMTObjective MTObjective(MTData);
00026         MTObjective.AppendFitParameters(&MTTensor::GetRhoxy,&MTTensor::GetdRhoxy,0.01);
00027         MTObjective.AppendFitParameters(&MTTensor::GetPhixy,&MTTensor::GetdPhixy,0.01);
00028         MTRecObjective CombObjective(MTData,RecData,0,0.0,4.0,0.001,0.07);
00029         
00030         ublas::vector<double> Model(nparam);
00031         Model(0) = 2;
00032         Model(1) = 0.1;
00033         Model(2) = 4;
00034         Model(3) = 10;
00035         Model(4) = 10;
00036         Model(5) = 10;
00037         //Model(4) = 3.4;
00038         //Model(5) = 4.0;
00039         //Model(6) = 2.8;
00040         //Model(7) = 3.2;
00041         double OldRMS = MTObjective.CalcPerformance(Model);
00042         MTObjective.CalcPerformance(Model);
00043         ublas::vector<double> OldData(MTObjective.GetSynthData());
00044         ModelAnalysis Analyser(MTObjective);
00045         Analyser.SetModel(Model);
00046         Analyser.SetRelativeSVDThreshold(1.0e-2);
00047         
00048         cout << "Singular Values : " << Analyser.GetSingularValues() << endl;
00049         cout << "Analysis R: " << Analyser.GetModelResolution() << endl;
00050         cout << "Analysis Null: " << Analyser.GetModelNullspace() << endl;
00051         
00052         ublas::vector<double> Projection(nparam), Perturb(nparam), NewModel(nparam);
00053         CUniformRNG Random;
00054         for (int sampleno = 0; sampleno < nsamples; ++sampleno)
00055         {
00056                 for (int i = 0; i < nparam; ++i)
00057                         Perturb(i) = Random.GetNumber();
00058                 Projection = prod(Analyser.GetModelNullspace(),Perturb);
00059                 //cout << "Projection: " << Projection << endl;
00060                 NewModel = Model+Projection;
00061                 //cout << " Old Model: " << Model << endl;
00062                 //cout << " New Model: " << NewModel << endl;
00063                 double NewRMS = MTObjective.CalcPerformance(NewModel);
00064                 ublas::vector<double> NewData(MTObjective.GetSynthData());
00065                 MTObjective.WritePlot("out"+stringify(sampleno));
00066         }
00067         /*cout << "OldRMS: " << OldRMS << " NewRMS: " << NewRMS << endl;
00068         double difference = 0.0;
00069         for (int i = 0; i < NewData.size(); ++i)
00070                 difference += pow((NewData(i) - OldData(i))/OldData(i),2);
00071         //cout << "Old Data: " << OldData << endl;
00072         //cout << "New Data: " << NewData << endl;
00073         ofstream diffile("differences");
00074         ofstream datafile("data");
00075         for (int i = 0; i < OldData.size(); ++i)
00076         {
00077                 datafile << i << " " << OldData(i) << " " << NewData(i) << endl;
00078                 diffile << (OldData(i) - NewData(i))/OldData(i) << endl;
00079         }
00080         cout << "Difference: " << sqrt(difference/NewData.size()) << endl;*/
00081 }

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