1 /*! 2 * \file src/Math/FactorizedKriging1D1D.cxx 3 * \brief 4 * \author Thomas Helfer 5 * \brief 19 mai 2010 6 * \copyright Copyright (C) 2006-2018 CEA/DEN, EDF R&D. All rights 7 * reserved. 8 * This project is publicly released under either the GNU GPL Licence 9 * or the CECILL-A licence. A copy of thoses licences are delivered 10 * with the sources of TFEL. CEA or EDF may also distribute this 11 * project under specific licensing conditions. 12 */ 13 14 #include"TFEL/Raise.hxx" 15 #include"TFEL/Math/FactorizedKriging1D1D.hxx" 16 17 namespace tfel 18 { 19 20 namespace math 21 { 22 FactorizedKriging1D1D(const std::vector<double> & vx,const std::vector<double> & vy,const std::vector<double> & vz)23 FactorizedKriging1D1D::FactorizedKriging1D1D(const std::vector<double>& vx, 24 const std::vector<double>& vy, 25 const std::vector<double>& vz) 26 { 27 raise_if<KrigingErrorInvalidLength>((vx.size()!=vy.size())|| 28 (vx.size()!=vz.size())); 29 const auto n0 = KrigingUtilities::normalize(vx); 30 this->a0 = n0.first; 31 this->b0 = n0.second; 32 const auto n1 = KrigingUtilities::normalize(vy); 33 this->a1 = n1.first; 34 this->b1 = n1.second; 35 auto px = vx.cbegin(); 36 auto py = vy.cbegin(); 37 auto pz = vz.cbegin(); 38 for(;px!=vx.end();++px,++py,++pz){ 39 FK::addValue(this->a0*(*px)+this->b0, 40 this->a1*(*py)+this->b1,*pz); 41 } 42 FK::buildInterpolation(); 43 } 44 FactorizedKriging1D1D(const tfel::math::vector<double> & vx,const tfel::math::vector<double> & vy,const tfel::math::vector<double> & vz)45 FactorizedKriging1D1D::FactorizedKriging1D1D(const tfel::math::vector<double>& vx, 46 const tfel::math::vector<double>& vy, 47 const tfel::math::vector<double>& vz) 48 { 49 raise_if<KrigingErrorInvalidLength>((vx.size()!=vy.size())|| 50 (vx.size()!=vz.size())); 51 const auto n0 = KrigingUtilities::normalize(vx); 52 this->a0 = n0.first; 53 this->b0 = n0.second; 54 const auto n1 = KrigingUtilities::normalize(vy); 55 this->a1 = n1.first; 56 this->b1 = n1.second; 57 auto px = vx.cbegin(); 58 auto py = vy.cbegin(); 59 auto pz = vz.cbegin(); 60 for(;px!=vx.end();++px,++py,++pz){ 61 FK::addValue(this->a0*(*px)+this->b0, 62 this->a1*(*py)+this->b1,*pz); 63 } 64 FK::buildInterpolation(); 65 } 66 operator ()(const double vx,const double vy) const67 double FactorizedKriging1D1D::operator()(const double vx, 68 const double vy) const 69 { 70 return FK::operator()(this->a0*(vx)+this->b0, 71 this->a1*(vy)+this->b1); 72 } // end of FactorizedKriging1D1D::operator() 73 74 FactorizedKriging1D1D::~FactorizedKriging1D1D() = default; 75 76 } // end of namespace math 77 78 } // end of namespace tfel 79 80