Skip to content

Commit

Permalink
solving some cpp checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Iximiel committed Feb 5, 2025
1 parent b0bd23d commit 437bee3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/tools/Tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class TensorTyped:
/// Auxiliary private function for constructor
template<typename... Args>
constexpr void auxiliaryConstructor(T first,Args... arg);
template <int n_, int m_>
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)
Expand Down Expand Up @@ -138,10 +140,12 @@ class TensorTyped:
/// get i-th row
constexpr VectorTyped<T,m> getRow(unsigned i)const;
/// returns the determinant
template<int m_=m, int n_=n,typename = is3x3<m_,n_>>
constexpr T determinant()const;
/// return an identity tensor
static constexpr TensorTyped<T,n,n> identity();
/// return the matrix inverse
template<int m_=m, int n_=n,typename = is3x3<m_,n_>>
constexpr TensorTyped inverse()const;
/// return the transpose matrix
constexpr TensorTyped<T,m,n> transpose()const;
Expand Down Expand Up @@ -337,8 +341,8 @@ constexpr TensorTyped<T,n,m> operator/(const TensorTyped<T,n,m>&t1,J s) {
}

template<typename T, unsigned n, unsigned m>
template<int m_, int n_,typename>
constexpr inline T TensorTyped<T,n,m>::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]
Expand Down Expand Up @@ -369,8 +373,8 @@ constexpr TensorTyped<T,m,n> TensorTyped<T,n,m>::transpose()const {
}

template<typename T, unsigned n, unsigned m>
template<int m_, int n_,typename>
constexpr inline TensorTyped<T,n,m> TensorTyped<T,n,m>::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++)
Expand Down

0 comments on commit 437bee3

Please sign in to comment.