MATH-1417: Incorrect loop start.
Thanks to Jean-François Lecomte for the report and the fix.
This commit is contained in:
parent
7a7b390528
commit
ed1ce82d82
|
@ -54,6 +54,9 @@ If the output is not quite correct, check for invisible trailing spaces!
|
||||||
</release>
|
</release>
|
||||||
|
|
||||||
<release version="4.0" date="XXXX-XX-XX" description="">
|
<release version="4.0" date="XXXX-XX-XX" description="">
|
||||||
|
<action dev="erans" type="fix" issue="MATH-1417" due-to="Jean-Francois Lecomte">
|
||||||
|
"RRQRDecomposition": bug in method "performHouseholderReflection".
|
||||||
|
</action>
|
||||||
<action dev="kinow" type="fix" issue="MATH-1381" due-to="Kexin Xie">
|
<action dev="kinow" type="fix" issue="MATH-1381" due-to="Kexin Xie">
|
||||||
BinomialTest P-value > 1
|
BinomialTest P-value > 1
|
||||||
</action>
|
</action>
|
||||||
|
|
|
@ -92,18 +92,18 @@ public class RRQRDecomposition extends QRDecomposition {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Perform Householder reflection for a minor A(minor, minor) of A.
|
/** Perform Householder reflection for a minor A(minor, minor) of A.
|
||||||
|
*
|
||||||
* @param minor minor index
|
* @param minor minor index
|
||||||
* @param qrt transposed matrix
|
* @param qrt transposed matrix
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void performHouseholderReflection(int minor, double[][] qrt) {
|
protected void performHouseholderReflection(int minor, double[][] qrt) {
|
||||||
|
|
||||||
double l2NormSquaredMax = 0;
|
double l2NormSquaredMax = 0;
|
||||||
// Find the unreduced column with the greatest L2-Norm
|
// Find the unreduced column with the greatest L2-Norm
|
||||||
int l2NormSquaredMaxIndex = minor;
|
int l2NormSquaredMaxIndex = minor;
|
||||||
for (int i = minor; i < qrt.length; i++) {
|
for (int i = minor; i < qrt.length; i++) {
|
||||||
double l2NormSquared = 0;
|
double l2NormSquared = 0;
|
||||||
for (int j = 0; j < qrt[i].length; j++) {
|
for (int j = minor; j < qrt[i].length; j++) {
|
||||||
l2NormSquared += qrt[i][j] * qrt[i][j];
|
l2NormSquared += qrt[i][j] * qrt[i][j];
|
||||||
}
|
}
|
||||||
if (l2NormSquared > l2NormSquaredMax) {
|
if (l2NormSquared > l2NormSquaredMax) {
|
||||||
|
@ -122,7 +122,6 @@ public class RRQRDecomposition extends QRDecomposition {
|
||||||
}
|
}
|
||||||
|
|
||||||
super.performHouseholderReflection(minor, qrt);
|
super.performHouseholderReflection(minor, qrt);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -244,4 +244,22 @@ public class RRQRDecompositionTest {
|
||||||
RRQRDecomposition qr = new RRQRDecomposition(m);
|
RRQRDecomposition qr = new RRQRDecomposition(m);
|
||||||
Assert.assertEquals(2, qr.getRank(1e-14));
|
Assert.assertEquals(2, qr.getRank(1e-14));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MATH-1417
|
||||||
|
@Test
|
||||||
|
public void testRank3() {
|
||||||
|
double[][] d = {
|
||||||
|
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
{0, 1, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
{0, 0, 1, 0, 0, 0, 0, 0, 0},
|
||||||
|
{0, 0, 1, 0, 0, 0, 0, 0, 0},
|
||||||
|
{0, 0, 1, 0, 0, 0, 0, 0, 0},
|
||||||
|
{0, 0, 0, 1, 0, 0, 0, 0, 0},
|
||||||
|
{0, 0, 0, 0, 0, 0, 1, 0, 0},
|
||||||
|
{0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
RealMatrix m = new Array2DRowRealMatrix(d);
|
||||||
|
RRQRDecomposition qr = new RRQRDecomposition(m.transpose());
|
||||||
|
Assert.assertEquals(4, qr.getRank(1e-14));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue