static_assert

This commit is contained in:
2020-08-19 16:48:08 +03:00
parent ccd6a9888f
commit 05607ccf0e
6 changed files with 13 additions and 4 deletions

View File

@@ -30,6 +30,7 @@
template<typename T>
inline bool _PIMathMatrixNullCompare(const T v) {
static_assert(std::is_floating_point<T>::value, "Type must be floating point");
return (piAbs(v) < T(1E-200));
}
@@ -59,6 +60,9 @@ class PIP_EXPORT PIMathMatrixT {
typedef PIMathMatrixT<Cols, Rows, Type> _CMatrixI;
typedef PIMathVectorT<Rows, Type> _CMCol;
typedef PIMathVectorT<Cols, Type> _CMRow;
static_assert(std::is_arithmetic<Type>::value, "Type must be arithmetic");
static_assert(Rows > 0, "Row count must be > 0");
static_assert(Cols > 0, "Column count must be > 0");
public:
PIMathMatrixT() {resize(Rows, Cols);}
PIMathMatrixT(const PIVector<Type> & val) {resize(Rows, Cols); int i = 0; PIMM_FOR_I_WB(r, c) m[r][c] = val[i++];}
@@ -156,10 +160,7 @@ public:
}
_CMatrix & invert(bool * ok = 0) {
if (Cols != Rows) {
if (ok != 0) *ok = false;
return *this;
}
static_assert(Cols == Rows, "Only square matrix invertable");
_CMatrix mtmp = _CMatrix::identity(), smat(*this);
bool ndet;
uint crow;