vkostyukov / la4j

Linear Algebra for Java
http://la4j.org
Apache License 2.0
371 stars 109 forks source link

Matrix multiplication bug: "1 does not equal to 1." #288

Open bramhaag opened 6 years ago

bramhaag commented 6 years ago

I got a rather interesting stacktrace:

Exception in thread "main" java.lang.IllegalArgumentException: The number of rows in the left-hand matrix should be equal to the number of columns in the right-hand matrix: 1 does not equal to 1.
    at org.la4j.operation.ooplace.OoPlaceMatricesMultiplication.ensureApplicableTo(OoPlaceMatricesMultiplication.java:209)
    at org.la4j.operation.MatrixMatrixOperation$1.ensureApplicableTo(MatrixMatrixOperation.java:64)
    at org.la4j.matrix.DenseMatrix.apply(DenseMatrix.java:173)
    at org.la4j.matrix.DenseMatrix.apply(DenseMatrix.java:179)
    at org.la4j.Matrix.multiply(Matrix.java:619)

1 does not equal to 1 in particular is interesting here. It appears that in the error message, Matrix#rows() and Matrix#columns are reversed compared to the if statement, see this

I've made #289 to fix this issue.