1 /*! 2 * \file src/Math/Kriging3D.cxx 3 * \brief 4 * \author Thomas Helfer 5 * \brief 18 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/Kriging3D.hxx" 16 17 namespace tfel 18 { 19 20 namespace math 21 { 22 Kriging3D(const std::vector<double> & vx,const std::vector<double> & vy,const std::vector<double> & vz,const std::vector<double> & vv)23 Kriging3D::Kriging3D(const std::vector<double>& vx, 24 const std::vector<double>& vy, 25 const std::vector<double>& vz, 26 const std::vector<double>& vv) 27 { 28 using tfel::math::tvector; 29 std::vector<double>::const_iterator px; 30 std::vector<double>::const_iterator py; 31 std::vector<double>::const_iterator pz; 32 std::vector<double>::const_iterator pv; 33 tvector<3u,double> v; 34 const auto n1 = KrigingUtilities::normalize(vx); 35 this->a1 = n1.first; 36 this->b1 = n1.second; 37 const auto n2 = KrigingUtilities::normalize(vy); 38 this->a2 = n2.first; 39 this->b2 = n2.second; 40 const auto n3 = KrigingUtilities::normalize(vz); 41 this->a3 = n3.first; 42 this->b3 = n3.second; 43 raise_if<KrigingErrorInvalidLength>((vx.size()!=vy.size())|| 44 (vx.size()!=vz.size())|| 45 (vx.size()!=vv.size())); 46 for(px=vx.begin(),py=vy.begin(),pz=vz.begin(),pv=vv.begin(); 47 px!=vx.end();++px,++py,++pz,++pv){ 48 v(0)=this->a1*(*px)+this->b1; 49 v(1)=this->a2*(*py)+this->b2; 50 v(2)=this->a3*(*pz)+this->b3; 51 Kriging<3u,double>::addValue(v,*pv); 52 } 53 Kriging<3u,double>::buildInterpolation(); 54 } 55 Kriging3D(const tfel::math::vector<double> & vx,const tfel::math::vector<double> & vy,const tfel::math::vector<double> & vz,const tfel::math::vector<double> & vv)56 Kriging3D::Kriging3D(const tfel::math::vector<double>& vx, 57 const tfel::math::vector<double>& vy, 58 const tfel::math::vector<double>& vz, 59 const tfel::math::vector<double>& vv) 60 { 61 using namespace tfel::math; 62 using tfel::math::vector; 63 vector<double>::const_iterator px; 64 vector<double>::const_iterator py; 65 vector<double>::const_iterator pz; 66 vector<double>::const_iterator pv; 67 tvector<3u,double> v; 68 raise_if<KrigingErrorInvalidLength>((vx.size()!=vy.size())|| 69 (vx.size()!=vz.size())|| 70 (vx.size()!=vv.size())); 71 const auto n1 = KrigingUtilities::normalize(vx); 72 this->a1 = n1.first; 73 this->b1 = n1.second; 74 const auto n2 = KrigingUtilities::normalize(vy); 75 this->a2 = n2.first; 76 this->b2 = n2.second; 77 const auto n3 = KrigingUtilities::normalize(vz); 78 this->a3 = n3.first; 79 this->b3 = n3.second; 80 for(px=vx.begin(),py=vy.begin(),pz=vz.begin(),pv=vv.begin(); 81 px!=vx.end();++px,++py,++pz,++pv){ 82 v(0)=this->a1*(*px)+this->b1; 83 v(1)=this->a2*(*py)+this->b2; 84 v(2)=this->a3*(*pz)+this->b3; 85 Kriging<3u,double>::addValue(v,*pv); 86 } 87 Kriging<3u,double>::buildInterpolation(); 88 } 89 operator ()(const double vx,const double vy,const double vz) const90 double Kriging3D::operator()(const double vx, 91 const double vy, 92 const double vz) const 93 { 94 using namespace tfel::math; 95 tvector<3u,double> v; 96 v(0)=this->a1*(vx)+this->b1; 97 v(1)=this->a2*(vy)+this->b2; 98 v(2)=this->a3*(vz)+this->b3; 99 return Kriging<3u,double>::operator()(v); 100 } // end of Kriging3D::operator() 101 102 Kriging3D::~Kriging3D() = default; 103 104 } // end of namespace math 105 106 } // end of namespace tfel 107