diff --git a/Sofa/framework/Type/src/sofa/type/Mat.h b/Sofa/framework/Type/src/sofa/type/Mat.h index 320c2a0eb7d..be6a3befa12 100644 --- a/Sofa/framework/Type/src/sofa/type/Mat.h +++ b/Sofa/framework/Type/src/sofa/type/Mat.h @@ -32,7 +32,7 @@ namespace // anonymous { template - constexpr real rabs(const real r) + real rabs(const real r) { if constexpr (std::is_signed()) return std::abs(r); @@ -41,7 +41,7 @@ namespace // anonymous } template - constexpr real equalsZero(const real r, const real epsilon = std::numeric_limits::epsilon()) + real equalsZero(const real r, const real epsilon = std::numeric_limits::epsilon()) { return rabs(r) <= epsilon; } @@ -65,8 +65,8 @@ class Mat : public fixed_array, L> typedef VecNoInit LineNoInit; typedef Vec Col; - static const Size nbLines = L; - static const Size nbCols = C; + static constexpr Size nbLines = L; + static constexpr Size nbCols = C; constexpr Mat() noexcept { @@ -389,7 +389,7 @@ class Mat : public fixed_array, L> } - constexpr bool isSymmetric() const + bool isSymmetric() const { for (Size i=0; i, L> return true; } - constexpr bool isDiagonal() const noexcept + bool isDiagonal() const noexcept { for (Size i=0; i& m) noexcept // one-norm of a 3 x 3 matrix template -constexpr real oneNorm(const Mat<3,3,real>& A) +real oneNorm(const Mat<3,3,real>& A) { real norm = 0.0; for (sofa::Size i=0; i<3; i++) @@ -813,7 +813,7 @@ constexpr real oneNorm(const Mat<3,3,real>& A) // inf-norm of a 3 x 3 matrix template -constexpr real infNorm(const Mat<3,3,real>& A) +real infNorm(const Mat<3,3,real>& A) { real norm = 0.0; for (sofa::Size i=0; i<3; i++) @@ -847,7 +847,7 @@ constexpr Vec diagonal(const Mat& m) /// Matrix inversion (general case). template -[[nodiscard]] constexpr bool invertMatrix(Mat& dest, const Mat& from) +[[nodiscard]] bool invertMatrix(Mat& dest, const Mat& from) { sofa::Size i{0}, j{0}, k{0}; Vec r, c, row, col; diff --git a/Sofa/framework/Type/src/sofa/type/Vec.h b/Sofa/framework/Type/src/sofa/type/Vec.h index e36a44a464d..e090a3d5e8f 100644 --- a/Sofa/framework/Type/src/sofa/type/Vec.h +++ b/Sofa/framework/Type/src/sofa/type/Vec.h @@ -39,7 +39,7 @@ namespace sofa::type namespace // anonymous { template - constexpr real rabs(const real r) + real rabs(const real r) { if constexpr (std::is_signed()) return std::abs(r); @@ -441,7 +441,7 @@ class Vec : public sofa::type::fixed_array } /// Euclidean norm. - constexpr ValueType norm() const noexcept + ValueType norm() const noexcept { return ValueType(std::sqrt(norm2())); } @@ -449,7 +449,7 @@ class Vec : public sofa::type::fixed_array /// l-norm of the vector /// The type of norm is set by parameter l. /// Use l<0 for the infinite norm. - constexpr ValueType lNorm( int l ) const + ValueType lNorm( int l ) const { if( l==2 ) return norm(); // euclidian norm else if( l<0 ) // infinite norm @@ -504,21 +504,21 @@ class Vec : public sofa::type::fixed_array /// Normalize the vector. /// returns false iff the norm is too small - constexpr bool normalize(ValueType threshold=std::numeric_limits::epsilon()) noexcept + bool normalize(ValueType threshold=std::numeric_limits::epsilon()) noexcept { return normalizeWithNorm(norm(),threshold); } /// Normalize the vector with a failsafe. /// If the norm is too small, the vector becomes the failsafe. - constexpr void normalize(Vec failsafe, ValueType threshold=std::numeric_limits::epsilon()) noexcept + void normalize(Vec failsafe, ValueType threshold=std::numeric_limits::epsilon()) noexcept { if( !normalize(threshold) ) *this=failsafe; } /// Return the normalized vector. /// @warning 'this' is not normalized. - constexpr Vec normalized() const noexcept + Vec normalized() const noexcept { Vec r(*this); r.normalize(); @@ -526,7 +526,7 @@ class Vec : public sofa::type::fixed_array } /// return true if norm()==1 - constexpr bool isNormalized( ValueType threshold=std::numeric_limits::epsilon()*(ValueType)10 ) const + bool isNormalized( ValueType threshold=std::numeric_limits::epsilon()*(ValueType)10 ) const { return rabs( norm2() - static_cast(1) ) <= threshold; }