// System.out.println("********* width "+width);
// create a random symmetric matrix
SimpleMatrix A = SimpleMatrix.wrap(RandomMatrices.createSymmetric(width,-1,1,rand));
TridiagonalDecompositionHouseholderOrig decomp = new TridiagonalDecompositionHouseholderOrig();
decomp.decompose(A.getMatrix());
D1Submatrix64F Ab = insertIntoBlock(offX,offY,A,r);
D1Submatrix64F V = new D1Submatrix64F(new BlockMatrix64F(r,offX+A.numCols(),r));
V.col0 = offX;
V.row1 = Ab.row1-Ab.row0;
int gammaOffset = offX;
double gammas[] = new double[gammaOffset+A.numCols()];
TridiagonalBlockHelper.tridiagUpperRow(r,Ab,gammas,V);
DenseMatrix64F expected = decomp.getQT();
// see if the decomposed matrix is the same
for( int i = 0; i < r; i++ ) {
for( int j = i; j < width; j++ ) {
assertEquals(i+" "+j,expected.get(i,j),Ab.get(i,j),1e-8);
}
}
// check the gammas
for( int i = 0; i < Math.min(width-1,r); i++ ) {
assertEquals(decomp.getGamma(i+1),gammas[i+gammaOffset],1e-8);
}
}
}