00001 #include "CombinedRoughness.h" 00002 #include <gsl/gsl_math.h> 00003 #include <iostream> 00004 00005 using namespace std; 00006 00007 namespace gplib 00008 { 00009 CombinedRoughness::CombinedRoughness() : 00010 refcond(2.0), refvel(2.0) 00011 { 00012 } 00013 00014 CombinedRoughness::~CombinedRoughness() 00015 { 00016 } 00017 00018 //! Calculate the roughness of the model given by the parameter member 00019 void CombinedRoughness::SafeParallel(const ttranscribed &member) 00020 { 00021 const unsigned int length = member.size() / 3; //we have 3 parameters in the model, so size/3 layers 00022 double roughness = 0; // init returnvalue 00023 const int fitexp = GetFitExponent(); 00024 00025 for (unsigned int i = 1; i < length; ++i) // for all layers except the top 00026 { 00027 roughness += gsl_pow_int((member(i) - member(i - 1)) / refcond, 00028 fitexp); // add the squared difference of the values divided by reference 00029 roughness += gsl_pow_int((member(i + 2 * length) - member(i - 1 + 2 00030 * length)) / refvel, fitexp); 00031 } 00032 SetRMS(roughness); 00033 } 00034 00035 double CombinedRoughness::PostParallel(const ttranscribed &member) 00036 { 00037 return GetRMS(); 00038 } 00039 00040 //! We have to copy the base class and the local data 00041 CombinedRoughness::CombinedRoughness(const CombinedRoughness &Old) : 00042 GeneralObjective(Old), refcond(Old.refcond), refvel(Old.refvel) 00043 { 00044 } 00045 00046 //! We have to copy the base class and the local data 00047 CombinedRoughness& CombinedRoughness::operator=( 00048 const CombinedRoughness& source) 00049 { 00050 if (this == &source) 00051 return *this; 00052 GeneralObjective::operator=(source); 00053 refcond = source.refcond; 00054 refvel = source.refvel; 00055 return *this; 00056 } 00057 }
1.5.8