isoaniso.cpp

Go to the documentation of this file.
00001 #include "C1DAnisoMTSynthData.h"
00002 #include "C1DMTSynthData.h"
00003 #include <iostream>
00004 #include <fstream>
00005 #include <cassert>
00006 #include <numeric>
00007 #include <boost/date_time/posix_time/posix_time.hpp>
00008 #include "UniformRNG.h"
00009 int main()
00010 {
00011         C1DAnisoMTSynthData Aniso;
00012         C1DMTSynthData Iso;
00013         UniformRNG Random;
00014         using namespace boost::posix_time;
00015         using namespace boost::gregorian;
00016         const unsigned int nlayers = 50;
00017         trealdata rho1(nlayers,0);
00018         trealdata rho2(nlayers,0);
00019         trealdata rho3(nlayers,0);
00020         trealdata strike(nlayers,0);
00021         trealdata slant(nlayers,0);
00022         trealdata dip(nlayers,0);
00023         trealdata thickness(nlayers,10);
00024         
00025         for (unsigned int i = 0; i < nlayers; ++i)
00026         {
00027                 rho1.at(i) = Random.GetNumber(1.,1000.0);
00028                 rho2.at(i) = Random.GetNumber(1.,1000.0);
00029                 rho3.at(i) = Random.GetNumber(1.,1000.0);
00030                 strike.at(i) = Random.GetNumber(0,90.0);
00031                 slant.at(i) = Random.GetNumber(0,90.0);
00032                 dip.at(i) = Random.GetNumber(0,90.0);
00033         }
00034         std::ofstream pekmod;
00035         
00036         Aniso.SetRho1(rho1);
00037         Aniso.SetRho2(rho1);
00038         Aniso.SetRho3(rho1);
00039         Aniso.SetStrikes(strike);
00040         Aniso.SetSlants(slant);
00041         Aniso.SetDips(dip);
00042         Aniso.SetThicknesses(thickness);
00043         
00044         
00045         
00046         Iso.SetResistivities(rho1);
00047         Iso.SetThicknesses(thickness);
00048         int runs =1000; 
00049         ptime startaniso = microsec_clock::local_time();
00050         for (int i = 0; i < runs; ++i)
00051                 Aniso.GetData();
00052         ptime endaniso = microsec_clock::local_time();
00053         ptime startiso = microsec_clock::local_time();
00054                 for (int i = 0; i < runs; ++i)
00055                         Iso.GetData();
00056                 ptime endiso = microsec_clock::local_time();
00057 
00058         assert(Iso.GetMTData().size() == Aniso.GetMTData().size());
00059         const double small = 1e-50;
00060         for (unsigned int i = 0; i < Iso.GetMTData().size(); ++i)
00061         {
00062                 std::cout << (Iso.GetMTData().at(i).GetZxx() - Aniso.GetMTData().at(i).GetZxx())/std::max(small,abs(Aniso.GetMTData().at(i).GetZxx())) << " ";
00063                 std::cout << (Iso.GetMTData().at(i).GetZxy() - Aniso.GetMTData().at(i).GetZxy())/std::max(small,abs(Aniso.GetMTData().at(i).GetZxy())) << " ";
00064                 std::cout << (Iso.GetMTData().at(i).GetZyx() - Aniso.GetMTData().at(i).GetZyx())/std::max(small,abs(Aniso.GetMTData().at(i).GetZyx())) << " ";
00065                 std::cout << (Iso.GetMTData().at(i).GetZyy() - Aniso.GetMTData().at(i).GetZyy())/std::max(small,abs(Aniso.GetMTData().at(i).GetZyy())) << " ";
00066                 std::cout << std::endl;
00067         }
00068         std::cout << "Time Aniso: " << endaniso - startaniso << " Time Iso: " << endiso - endaniso;
00069         std::cout << " Relative: " << (endaniso - startaniso).total_microseconds()/(endiso - startiso).total_microseconds()<< std::endl;
00070 }

Generated on Tue Aug 4 16:04:06 2009 for GPLIB++ by  doxygen 1.5.8