Commit 6011de38 authored by Jan Philipp Haller's avatar Jan Philipp Haller
Browse files

Fixed assertion errors in ADMat.h: Multiplication of matricies with different...

Fixed assertion errors in ADMat.h: Multiplication of matricies with different outer dimensions was not possible.
parent bbcdcd64
Pipeline #326143 failed with stage
in 47 seconds
......@@ -29,7 +29,7 @@
<compiler.plugin>3.8.0</compiler.plugin>
<source.plugin>2.4</source.plugin>
<shade.plugin>2.4.3</shade.plugin>
<jacoco.plugin>0.8.1</jacoco.plugin>
<jacoco.plugin>0.8.4</jacoco.plugin>
<!-- Classifiers -->
<grammars.classifier>grammars</grammars.classifier>
......
......@@ -71,9 +71,11 @@ public class MathAbsCommand extends MathCommand {
// 0 - Why is std:: used in the first place? the other commands don't utilize the namespace
// 1 - How to determine if ipopt is used?
MathStringExpression stringExpression = new MathStringExpression("abs"+valueListString,mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
//Old
//MathStringExpression stringExpression = new MathStringExpression("std::abs"+valueListString,mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
MathStringExpression stringExpression = new MathStringExpression("abs"+valueListString,mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
......
......@@ -32,7 +32,8 @@ public:
// arithematic binary operators with matrices
inline ADMat operator+(const ADMat &matrix) {
assert(this->size() == matrix.size());
assert(this->n_rows == matrix.n_rows);
assert(this->n_cols == matrix.n_cols);
ADMat res = ADMat(*this);
for (int i = 0; i < size(); i++) {
res[i] = this->at(i) + matrix[i];
......@@ -50,7 +51,8 @@ public:
};
inline ADMat operator-(const ADMat &matrix) {
assert(this->size() == matrix.size());
assert(this->n_rows == matrix.n_rows);
assert(this->n_cols == matrix.n_cols);
ADMat res = ADMat(*this);
for (int i = 0; i < size(); i++) {
res[i] = this->at(i) - matrix[i];
......@@ -71,7 +73,7 @@ public:
inline ADMat operator*(const ADMat &matrix) {
assert(n_cols == matrix.n_rows);
assert(n_rows == matrix.n_cols);
//assert(n_rows == matrix.n_cols);
ADMat res = ADMat(n_rows, matrix.n_cols);
res.fill(0);
for (int i = 0; i < n_rows; i++) {
......@@ -86,7 +88,7 @@ public:
inline ADMat operator*(const mat &matrix) {
assert(n_cols == matrix.n_rows);
assert(n_rows == matrix.n_cols);
//assert(n_rows == matrix.n_cols);
ADMat res = ADMat(n_rows, matrix.n_cols);
res.fill(0);
for (int i = 0; i < n_rows; i++) {
......@@ -278,7 +280,7 @@ inline ADMat operator*(const double &left, const ADMat &right) {
inline ADMat operator*(const arma::subview_field<CppAD::AD<double>> &left, const arma::subview_field<CppAD::AD<double> > &right) {
assert(left.n_cols == right.n_rows);
assert(left.n_rows == right.n_cols);
//assert(left.n_rows == right.n_cols);
ADMat res = ADMat(left.n_rows, right.n_cols);
res.fill(0);
for (int i = 0; i < left.n_rows; i++) {
......@@ -293,7 +295,7 @@ inline ADMat operator*(const arma::subview_field<CppAD::AD<double>> &left, const
inline ADMat operator*(const mat &left, const ADMat &right) {
assert(left.n_cols == right.n_rows);
assert(left.n_rows == right.n_cols);
//assert(left.n_rows == right.n_cols);
ADMat res = ADMat(left.n_rows, right.n_cols);
res.fill(0);
for (int i = 0; i < left.n_rows; i++) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment