1 /*! 2 * \file include/TFEL/Math/Kriging/KrigingDefaultModel2D.hxx 3 * \brief 4 * \author Thomas Helfer 5 * \brief 10 avr 2009 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 #ifndef LIB_TFEL_MATH_KRIGINGDEFAULTMODEL2D_HXX 15 #define LIB_TFEL_MATH_KRIGINGDEFAULTMODEL2D_HXX 16 17 #include<cmath> 18 #include<limits> 19 20 #include"TFEL/Config/TFELConfig.hxx" 21 #include"TFEL/Math/Kriging/KrigingVariable.hxx" 22 23 namespace tfel 24 { 25 26 namespace math 27 { 28 29 /*! 30 * Partial specialisation in 2D 31 * \param T : numeric type 32 * \param NM : nugget model 33 */ 34 template<typename T, 35 typename NM> 36 struct KrigingDefaultModel<2u,T,NM> 37 : public NM 38 { 39 static TFEL_MATH_INLINE T onetfel::math::KrigingDefaultModel40 one(const typename KrigingVariable<2u,T>::type&) 41 { 42 return T(1); 43 } 44 45 static TFEL_MATH_INLINE T xtfel::math::KrigingDefaultModel46 x(const typename KrigingVariable<2u,T>::type& v) 47 { 48 return v(0); 49 } 50 51 static TFEL_MATH_INLINE T ytfel::math::KrigingDefaultModel52 y(const typename KrigingVariable<2u,T>::type& v) 53 { 54 return v(1); 55 } 56 57 static TFEL_MATH_INLINE T covariancetfel::math::KrigingDefaultModel58 covariance(const typename KrigingVariable<2u,T>::type& v) 59 { 60 using namespace std; 61 T h2 = v(0)*v(0)+v(1)*v(1); 62 if(h2<10*numeric_limits<T>::epsilon()){ 63 return T(0); 64 } 65 return 0.5*h2*log(h2); 66 } // end of covariance 67 68 typedef T (*Drifts)(const typename KrigingVariable<2u,T>::type&); 69 70 static const unsigned short nb = 3u; /* number of drifts */ 71 static const Drifts drifts[3u]; 72 }; 73 74 template<typename T, 75 typename NM> 76 const typename KrigingDefaultModel<2u,T,NM>::Drifts 77 KrigingDefaultModel<2u,T,NM>::drifts[3u] = {KrigingDefaultModel<2u,T,NM>::one, 78 KrigingDefaultModel<2u,T,NM>::x, 79 KrigingDefaultModel<2u,T,NM>::y}; 80 81 } // end of namespace math 82 83 } // end of namespace tfel 84 85 #endif /* LIB_TFEL_MATH_KRIGINGDEFAULTMODEL2D_HXX */ 86 87