PTensor1DMTObjective.cpp

Go to the documentation of this file.
00001 #include "PTensor1DMTObjective.h"
00002 #include "Member2Aniso.h"
00003 #include <gsl/gsl_math.h>
00004 #include <cassert>
00005 #include <numeric>
00006 using namespace std;
00007 
00008 namespace gplib
00009   {
00010     PTensor1DMTObjective::PTensor1DMTObjective(
00011         const PTensorMTStation &LocalMTData) :
00012       errorlevel(0.01), // we set a standard error level of 1%
00013           MeasuredData(LocalMTData)
00014       {
00015       }
00016 
00017     PTensor1DMTObjective::~PTensor1DMTObjective()
00018       {
00019       }
00020 
00021     PTensor1DMTObjective::PTensor1DMTObjective(const PTensor1DMTObjective &Old) :
00022       PlottableObjective(Old), errorlevel(Old.errorlevel), MeasuredData(
00023           Old.MeasuredData), AnisoMTSynth(Old.AnisoMTSynth)
00024       {
00025       }
00026 
00027     PTensor1DMTObjective& PTensor1DMTObjective::operator=(
00028         const PTensor1DMTObjective& source)
00029       {
00030         if (this == &source)
00031           return *this;
00032         PlottableObjective::operator=(source);
00033         errorlevel = source.errorlevel;
00034         MeasuredData = source.MeasuredData;
00035         AnisoMTSynth = source.AnisoMTSynth;
00036         return *this;
00037       }
00038 
00039     void PTensor1DMTObjective::SafeParallel(const ttranscribed &member)
00040       {
00041         if (AnisoMTSynth.GetFrequencies().empty()) //if we didn't set the frequencies before
00042           {
00043             AnisoMTSynth.SetFrequencies(MeasuredData.GetFrequencies());
00044           }
00045         Member2Aniso(member, AnisoMTSynth);
00046         AnisoMTSynth.GetData();
00047 
00048         double returnvalue = 0; // init misfit value
00049 
00050         const unsigned int nelements = 4;
00051         const unsigned int ndata = nelements * MeasuredData.GetTensor().size(); //we fit 4 real phase tensor elements
00052         SetMisfit().resize(ndata); //make sure Misfit in base class can hold enough elements
00053         SetSynthData().resize(ndata); // and same for data
00054 
00055         for (unsigned int i = 0; i < ndata; i += nelements) //we do the 4 elements in one block
00056           {
00057             returnvalue += CalcMisfit(
00058                 MeasuredData.at(i / nelements).GetPhi11(), AnisoMTSynth.at(i
00059                     / nelements).GetPhi11(),
00060                 MeasuredData.at(i / nelements).GetdPhi11(), errorlevel, i);
00061             returnvalue += CalcMisfit(
00062                 MeasuredData.at(i / nelements).GetPhi12(), AnisoMTSynth.at(i
00063                     / nelements).GetPhi12(),
00064                 MeasuredData.at(i / nelements).GetdPhi12(), errorlevel, i + 1);
00065             returnvalue += CalcMisfit(
00066                 MeasuredData.at(i / nelements).GetPhi21(), AnisoMTSynth.at(i
00067                     / nelements).GetPhi21(),
00068                 MeasuredData.at(i / nelements).GetdPhi21(), errorlevel, i + 2);
00069             returnvalue += CalcMisfit(
00070                 MeasuredData.at(i / nelements).GetPhi22(), AnisoMTSynth.at(i
00071                     / nelements).GetPhi22(),
00072                 MeasuredData.at(i / nelements).GetdPhi22(), errorlevel, i + 3);
00073           }
00074         SetRMS(pow(returnvalue / ndata, 1.0 / GetFitExponent()));
00075       }
00076 
00077     double PTensor1DMTObjective::PostParallel(const ttranscribed &member)
00078       {
00079         return GetRMS();
00080       }
00081   }

Generated on Tue Nov 3 13:24:14 2009 for GPLIB++ by  doxygen 1.5.8