diff --git a/src/tools/Tensor.h b/src/tools/Tensor.h index 595a955a69..6bb813c336 100644 --- a/src/tools/Tensor.h +++ b/src/tools/Tensor.h @@ -97,6 +97,8 @@ class TensorTyped: /// Auxiliary private function for constructor template constexpr void auxiliaryConstructor(T first,Args... arg); + template + using is3x3 = std::enable_if_t<(n_==3 && m_==3)>; public: /// Constructor accepting n*m T parameters. /// Can be used as Tensor<2,2>(1.0,2.0,3.0,4.0) @@ -138,10 +140,12 @@ class TensorTyped: /// get i-th row constexpr VectorTyped getRow(unsigned i)const; /// returns the determinant + template> constexpr T determinant()const; /// return an identity tensor static constexpr TensorTyped identity(); /// return the matrix inverse + template> constexpr TensorTyped inverse()const; /// return the transpose matrix constexpr TensorTyped transpose()const; @@ -337,8 +341,8 @@ constexpr TensorTyped operator/(const TensorTyped&t1,J s) { } template +template constexpr inline T TensorTyped::determinant()const { - static_assert(n==3&&m==3,"determinanat can be called only for 3x3 Tensors"); return d[0]*d[4]*d[8] + d[1]*d[5]*d[6] @@ -369,8 +373,8 @@ constexpr TensorTyped TensorTyped::transpose()const { } template +template constexpr inline TensorTyped TensorTyped::inverse()const { - static_assert(n==3&&m==3,"inverse can be called only for 3x3 Tensors"); TensorTyped t; T invdet=1.0/determinant(); for(unsigned i=0; i<3; i++)