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),
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())
00042 {
00043 AnisoMTSynth.SetFrequencies(MeasuredData.GetFrequencies());
00044 }
00045 Member2Aniso(member, AnisoMTSynth);
00046 AnisoMTSynth.GetData();
00047
00048 double returnvalue = 0;
00049
00050 const unsigned int nelements = 4;
00051 const unsigned int ndata = nelements * MeasuredData.GetTensor().size();
00052 SetMisfit().resize(ndata);
00053 SetSynthData().resize(ndata);
00054
00055 for (unsigned int i = 0; i < ndata; i += nelements)
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 }