[regression] Add an assertion on the number of entries of matrices used

in models
This commit is contained in:
Émilie Feral
2019-05-03 15:51:43 +02:00
parent b8c92bf686
commit c1c280762f
2 changed files with 2 additions and 2 deletions

View File

@@ -170,6 +170,7 @@ int Model::solveLinearSystem(double * solutions, double * coefficients, double *
for (int i = 0; i < n * n; i++) {
coefficientsSave[i] = coefficients[i];
}
assert(k_maxNumberOfCoefficients < Matrix::k_maxNumberOfCoefficients);
int inverseResult = Matrix::ArrayInverse(coefficients, n, n);
int numberOfMatrixModifications = 0;
while (inverseResult < 0 && numberOfMatrixModifications < k_maxMatrixInversionFixIterations) {

View File

@@ -84,10 +84,9 @@ public:
/* createInverse can be called on any matrix reduce or not, approximate or not. */
Expression inverse(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const;
#endif
private:
// TODO: find another solution for inverse and determinant (avoid capping the matrix)
static constexpr int k_maxNumberOfCoefficients = 100;
private:
MatrixNode * node() const { return static_cast<MatrixNode *>(Expression::node()); }
void setNumberOfRows(int rows) { assert(rows >= 0); node()->setNumberOfRows(rows); }
void setNumberOfColumns(int columns) { assert(columns >= 0); node()->setNumberOfColumns(columns); }