mitsuki31 / jmatrix

A lightweight Java library for basic introduction to matrix and linear algebra concepts.
https://mitsuki31.github.io/jmatrix/
Apache License 2.0
1 stars 0 forks source link

Bad logical expression in the `insertRow` method #109

Closed mitsuki31 closed 4 months ago

mitsuki31 commented 4 months ago

There's a bad logic inside the body insertRow method on row index checker.

https://github.com/mitsuki31/jmatrix/blob/ebd80dd78cc2eec1a34b2591f46c5d9ce0d5fc11/src/main/java/com/mitsuki/jmatrix/Matrix.java#L958-L963

It should be like this:

-    } else if (row < 0 || row > mRows) {  // Check for the index is out of bounds
+    } else if (row < 0 || row >= mRows) {  // Check for the index is out of bounds

Where the given row must be lower than (and not equals) to mRows (the total rows of the matrix).

Originally posted by @mitsuki31 in https://github.com/mitsuki31/jmatrix/pull/108#pullrequestreview-2088119376

mitsuki31 commented 4 months ago

Moved the issue to #110