1 /*! 2 * \file include/TFEL/Math/T2toST2/StensorT2toST2ProductExpr.hxx 3 * \brief 4 * \author Thomas Helfer 5 * \brief 05 juin 2014 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_STENSORT2TOST2PRODUCTEXPR_HXX 15 #define LIB_TFEL_MATH_STENSORT2TOST2PRODUCTEXPR_HXX 16 17 #include"TFEL/Config/TFELConfig.hxx" 18 19 #include"TFEL/Math/General/EmptyRunTimeProperties.hxx" 20 #include"TFEL/Math/Stensor/StensorConcept.hxx" 21 #include"TFEL/Math/Tensor/TensorConcept.hxx" 22 23 namespace tfel 24 { 25 26 namespace math 27 { 28 29 //! Empty structure used for partial specialisation of the 30 //! Expr class 31 template<unsigned short N> 32 struct StensorT2toST2ProductExpr 33 {}; // end of struct StensorT2toST2ProductExpr 34 35 /*! 36 * Partial specialisation 37 */ 38 template<typename TensorResultType> 39 struct Expr<TensorResultType,StensorT2toST2ProductExpr<1u> > 40 : public TensorConcept<Expr<TensorResultType,StensorT2toST2ProductExpr<1u> > >, 41 public fsarray<TensorDimeToSize<TensorTraits<TensorResultType>::dime>::value, 42 typename TensorTraits<TensorResultType>::NumType> 43 { 44 //! a simple alias 45 typedef EmptyRunTimeProperties RunTimeProperties; 46 //! a simple alias 47 typedef typename TensorTraits<TensorResultType>::NumType value_type; 48 //! a simple check 49 TFEL_STATIC_ASSERT((TensorTraits<TensorResultType>::dime==1u)); 50 /*! 51 * \param[in] a : first term of the product 52 * \param[in] b : second term of the product 53 */ 54 template<typename StensorType, 55 typename T2toST2Type> 56 TFEL_MATH_INLINE Exprtfel::math::Expr57 Expr(const StensorType& a, 58 const T2toST2Type& b) 59 { 60 //! a simple check 61 TFEL_STATIC_ASSERT((tfel::meta::Implements<T2toST2Type,T2toST2Concept>::cond)); 62 //! a simple check 63 TFEL_STATIC_ASSERT((tfel::meta::Implements<StensorType,StensorConcept>::cond)); 64 //! a simple check 65 TFEL_STATIC_ASSERT((T2toST2Traits<T2toST2Type>::dime==1u)); 66 //! a simple check 67 TFEL_STATIC_ASSERT((StensorTraits<StensorType>::dime==1u)); 68 this->v[0]=b(0,0)*a(0)+b(1,0)*a(1)+b(2,0)*a(2); 69 this->v[1]=b(0,1)*a(0)+b(1,1)*a(1)+b(2,1)*a(2); 70 this->v[2]=b(0,2)*a(0)+b(1,2)*a(1)+b(2,2)*a(2); 71 } // end of Expr 72 /*! 73 * \brief access operator 74 * \param[in] i : index 75 */ 76 TFEL_MATH_INLINE const value_type& operator ()tfel::math::Expr77 operator()(const unsigned short i) const 78 { 79 return this->v[i]; 80 } // end of operator() 81 /*! 82 * \return the runtime properties 83 */ 84 TFEL_MATH_INLINE RunTimeProperties getRunTimePropertiestfel::math::Expr85 getRunTimeProperties() const 86 { 87 return RunTimeProperties(); 88 } 89 }; // end of struct Expr<TensorResultType,T2SStensorT2toST2ProductExp> 90 91 /*! 92 * Partial specialisation 93 */ 94 template<typename TensorResultType> 95 struct Expr<TensorResultType,StensorT2toST2ProductExpr<2u> > 96 : public TensorConcept<Expr<TensorResultType,StensorT2toST2ProductExpr<2u> > >, 97 public fsarray<TensorDimeToSize<TensorTraits<TensorResultType>::dime>::value, 98 typename TensorTraits<TensorResultType>::NumType> 99 { 100 //! a simple alias 101 typedef EmptyRunTimeProperties RunTimeProperties; 102 //! a simple alias 103 typedef typename TensorTraits<TensorResultType>::NumType value_type; 104 //! a simple check 105 TFEL_STATIC_ASSERT((TensorTraits<TensorResultType>::dime==2u)); 106 /*! 107 * \param[in] a : first term of the product 108 * \param[in] b : second term of the product 109 */ 110 template<typename StensorType, 111 typename T2toST2Type> 112 TFEL_MATH_INLINE Exprtfel::math::Expr113 Expr(const StensorType& a, 114 const T2toST2Type& b) 115 { 116 //! a simple check 117 TFEL_STATIC_ASSERT((tfel::meta::Implements<T2toST2Type,T2toST2Concept>::cond)); 118 //! a simple check 119 TFEL_STATIC_ASSERT((tfel::meta::Implements<StensorType,StensorConcept>::cond)); 120 //! a simple check 121 TFEL_STATIC_ASSERT((T2toST2Traits<T2toST2Type>::dime==2u)); 122 //! a simple check 123 TFEL_STATIC_ASSERT((StensorTraits<StensorType>::dime==2u)); 124 this->v[0]=b(3,0)*a[3]+b(2,0)*a[2]+b(1,0)*a[1]+b(0,0)*a[0]; 125 this->v[1]=b(3,1)*a[3]+b(2,1)*a[2]+b(1,1)*a[1]+b(0,1)*a[0]; 126 this->v[2]=b(3,2)*a[3]+b(2,2)*a[2]+b(1,2)*a[1]+b(0,2)*a[0]; 127 this->v[3]=b(3,3)*a[3]+b(2,3)*a[2]+b(1,3)*a[1]+b(0,3)*a[0]; 128 this->v[4]=b(3,4)*a[3]+b(2,4)*a[2]+b(1,4)*a[1]+b(0,4)*a[0]; 129 } // end of Expr 130 /*! 131 * \brief access operator 132 * \param[in] i : index 133 */ 134 TFEL_MATH_INLINE const value_type& operator ()tfel::math::Expr135 operator()(const unsigned short i) const 136 { 137 return this->v[i]; 138 } // end of operator() 139 /*! 140 * \return the runtime properties 141 */ 142 TFEL_MATH_INLINE RunTimeProperties getRunTimePropertiestfel::math::Expr143 getRunTimeProperties() const 144 { 145 return RunTimeProperties(); 146 } 147 }; // end of struct Expr<TensorResultType,T2SStensorT2toST2ProductExp> 148 149 /*! 150 * Partial specialisation 151 */ 152 template<typename TensorResultType> 153 struct Expr<TensorResultType,StensorT2toST2ProductExpr<3u> > 154 : public TensorConcept<Expr<TensorResultType,StensorT2toST2ProductExpr<3u> > >, 155 public fsarray<TensorDimeToSize<TensorTraits<TensorResultType>::dime>::value, 156 typename TensorTraits<TensorResultType>::NumType> 157 { 158 //! a simple alias 159 typedef EmptyRunTimeProperties RunTimeProperties; 160 //! a simple alias 161 typedef typename TensorTraits<TensorResultType>::NumType value_type; 162 //! a simple check 163 TFEL_STATIC_ASSERT((TensorTraits<TensorResultType>::dime==3u)); 164 /*! 165 * \param[in] a : first term of the product 166 * \param[in] b : second term of the product 167 */ 168 template<typename StensorType, 169 typename T2toST2Type> 170 TFEL_MATH_INLINE Exprtfel::math::Expr171 Expr(const StensorType& a, 172 const T2toST2Type& b) 173 { 174 //! a simple check 175 TFEL_STATIC_ASSERT((tfel::meta::Implements<T2toST2Type,T2toST2Concept>::cond)); 176 //! a simple check 177 TFEL_STATIC_ASSERT((tfel::meta::Implements<StensorType,StensorConcept>::cond)); 178 //! a simple check 179 TFEL_STATIC_ASSERT((T2toST2Traits<T2toST2Type>::dime==3u)); 180 //! a simple check 181 TFEL_STATIC_ASSERT((StensorTraits <StensorType>::dime==3u)); 182 this->v[0]=b(5,0)*a[5]+b(4,0)*a[4]+b(3,0)*a[3]+b(2,0)*a[2]+b(1,0)*a[1]+b(0,0)*a[0]; 183 this->v[1]=b(5,1)*a[5]+b(4,1)*a[4]+b(3,1)*a[3]+b(2,1)*a[2]+b(1,1)*a[1]+b(0,1)*a[0]; 184 this->v[2]=b(5,2)*a[5]+b(4,2)*a[4]+b(3,2)*a[3]+b(2,2)*a[2]+b(1,2)*a[1]+b(0,2)*a[0]; 185 this->v[3]=b(5,3)*a[5]+b(4,3)*a[4]+b(3,3)*a[3]+b(2,3)*a[2]+b(1,3)*a[1]+b(0,3)*a[0]; 186 this->v[4]=b(5,4)*a[5]+b(4,4)*a[4]+b(3,4)*a[3]+b(2,4)*a[2]+b(1,4)*a[1]+b(0,4)*a[0]; 187 this->v[5]=b(5,5)*a[5]+b(4,5)*a[4]+b(3,5)*a[3]+b(2,5)*a[2]+b(1,5)*a[1]+b(0,5)*a[0]; 188 this->v[6]=b(5,6)*a[5]+b(4,6)*a[4]+b(3,6)*a[3]+b(2,6)*a[2]+b(1,6)*a[1]+b(0,6)*a[0]; 189 this->v[7]=b(5,7)*a[5]+b(4,7)*a[4]+b(3,7)*a[3]+b(2,7)*a[2]+b(1,7)*a[1]+b(0,7)*a[0]; 190 this->v[8]=b(5,8)*a[5]+b(4,8)*a[4]+b(3,8)*a[3]+b(2,8)*a[2]+b(1,8)*a[1]+b(0,8)*a[0]; 191 } // end of Expr 192 /*! 193 * \brief access operator 194 * \param[in] i : index 195 */ 196 TFEL_MATH_INLINE const value_type& operator ()tfel::math::Expr197 operator()(const unsigned short i) const 198 { 199 return this->v[i]; 200 } // end of operator() 201 /*! 202 * \return the runtime properties 203 */ 204 TFEL_MATH_INLINE RunTimeProperties getRunTimePropertiestfel::math::Expr205 getRunTimeProperties() const 206 { 207 return RunTimeProperties(); 208 } 209 }; // end of struct Expr<TensorResultType,T2SStensorT2toST2ProductExp> 210 211 } // end of namespace math 212 213 } // end of namespace tfel 214 215 #endif /* LIB_TFEL_MATH_STENSORT2TOST2PRODUCTEXPR_HXX */ 216 217