added a test ensuring the part of the symmetric matrix below the diagonal is never used
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_0@701810 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
50f694b7a0
commit
fcb63bbdac
|
@ -17,6 +17,8 @@
|
|||
|
||||
package org.apache.commons.math.linear;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
@ -66,6 +68,26 @@ public class TriDiagonalTransformerTest extends TestCase {
|
|||
assertEquals(0, norm, 4.0e-15);
|
||||
}
|
||||
|
||||
public void testNoAccessBelowDiagonal() {
|
||||
checkNoAccessBelowDiagonal(testSquare5);
|
||||
checkNoAccessBelowDiagonal(testSquare3);
|
||||
}
|
||||
|
||||
private void checkNoAccessBelowDiagonal(double[][] data) {
|
||||
double[][] modifiedData = new double[data.length][];
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
modifiedData[i] = data[i].clone();
|
||||
Arrays.fill(modifiedData[i], 0, i, Double.NaN);
|
||||
}
|
||||
RealMatrix matrix = new RealMatrixImpl(modifiedData, false);
|
||||
TriDiagonalTransformer transformer = new TriDiagonalTransformer(matrix);
|
||||
RealMatrix q = transformer.getQ();
|
||||
RealMatrix qT = transformer.getQT();
|
||||
RealMatrix t = transformer.getT();
|
||||
double norm = q.multiply(t).multiply(qT).subtract(new RealMatrixImpl(data, false)).getNorm();
|
||||
assertEquals(0, norm, 4.0e-15);
|
||||
}
|
||||
|
||||
public void testQOrthogonal() {
|
||||
checkOrthogonal(new TriDiagonalTransformer(new RealMatrixImpl(testSquare5, false)).getQ());
|
||||
checkOrthogonal(new TriDiagonalTransformer(new RealMatrixImpl(testSquare3, false)).getQ());
|
||||
|
|
Loading…
Reference in New Issue