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 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">
|
||||
BinomialTest P-value > 1
|
||||
</action>
|
||||
|
|
|
@ -68,7 +68,7 @@ public class RRQRDecomposition extends QRDecomposition {
|
|||
this(matrix, 0d);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Calculates the QR-decomposition of the given matrix.
|
||||
*
|
||||
* @param matrix The matrix to decompose.
|
||||
|
@ -92,18 +92,18 @@ public class RRQRDecomposition extends QRDecomposition {
|
|||
}
|
||||
|
||||
/** Perform Householder reflection for a minor A(minor, minor) of A.
|
||||
*
|
||||
* @param minor minor index
|
||||
* @param qrt transposed matrix
|
||||
*/
|
||||
@Override
|
||||
protected void performHouseholderReflection(int minor, double[][] qrt) {
|
||||
|
||||
double l2NormSquaredMax = 0;
|
||||
// Find the unreduced column with the greatest L2-Norm
|
||||
int l2NormSquaredMaxIndex = minor;
|
||||
for (int i = minor; i < qrt.length; i++) {
|
||||
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];
|
||||
}
|
||||
if (l2NormSquared > l2NormSquaredMax) {
|
||||
|
@ -122,7 +122,6 @@ public class RRQRDecomposition extends QRDecomposition {
|
|||
}
|
||||
|
||||
super.performHouseholderReflection(minor, qrt);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -244,4 +244,22 @@ public class RRQRDecompositionTest {
|
|||
RRQRDecomposition qr = new RRQRDecomposition(m);
|
||||
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