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