lessthanoptimal / ejml

A fast and easy to use linear algebra library written in Java for dense, sparse, real, and complex matrices.
https://ejml.org
565 stars 118 forks source link

Reduced Row Echelon Form Bug #115

Closed KayakDov closed 3 years ago

KayakDov commented 3 years ago

The following code does not yield reduced row echelon form.

DMatrixRMaj matrix = new DMatrixRMaj(2, 3, true, new double[]{0,2,2,0,0,2}); System.out.println(CommonOps_DDRM.rref(matrix, -1, null));

Prints: Type = DDRM , rows = 2 , cols = 3 0.0000E+00 1.0000E+00 1.0000E+00 0.0000E+00 0.0000E+00 2.0000E+00

but the first non zero element on each row should be 1.

lessthanoptimal commented 3 years ago

Deleted first reply since I can't apparently read. Looking into this.

lessthanoptimal commented 3 years ago

Fixed the issue. Combination of bad test coverage of bad default value for number of columns. Thanks for pointing out the problem. I'm surprised this went unnoticed for so long!

https://github.com/lessthanoptimal/ejml/pull/130

Also apologies for taking so long to look into this and missing it in the last release.