Quantcast
Channel: Math.NET Numerics
Viewing all articles
Browse latest Browse all 971

Commented Issue: SparseMatrix.SubMatrix() throws IndexOutOfRangeException [5671]

$
0
0
Hi,

I'm still using your nice library and I've found a little bug again, this time in the SubMatrix() method for sparse matrices.
If you do something like this:
var matrix = new SparseMatrix(10, 10, 1.0);
var sub = matrix.SubMatrix(8, 2, 0, 2);

then the method will throw an IndexOutOfRangeException. This is due to a little typo in one of the boundary checks:
var endIndex = row < _rowIndex.Length - 1 ? _rowIndex[i + 1] : NonZerosCount;
should really be:
var endIndex = i < _rowIndex.Length - 1 ? _rowIndex[i + 1] : NonZerosCount;
(row being the index of the smaller to-be-output submatrix's row, whereas i is the index of the matrix's row currently being parsed).

Hope it helps!

Cheers and good luck. ;)
Comments: Fixed in changeset d2a96e1f16bb

Viewing all articles
Browse latest Browse all 971

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>