}
private void checkMatricesValues(double[][] matrix, double[][] qRef,
double[] mainDiagnonal,
double[] secondaryDiagonal) {
TriDiagonalTransformer transformer =
new TriDiagonalTransformer(MatrixUtils.createRealMatrix(matrix));
// check values against known references
RealMatrix q = transformer.getQ();
assertEquals(0, q.subtract(MatrixUtils.createRealMatrix(qRef)).getNorm(), 1.0e-14);
RealMatrix t = transformer.getT();
double[][] tData = new double[mainDiagnonal.length][mainDiagnonal.length];
for (int i = 0; i < mainDiagnonal.length; ++i) {
tData[i][i] = mainDiagnonal[i];
if (i > 0) {
tData[i][i - 1] = secondaryDiagonal[i - 1];
}
if (i < secondaryDiagonal.length) {
tData[i][i + 1] = secondaryDiagonal[i];
}
}
assertEquals(0, t.subtract(MatrixUtils.createRealMatrix(tData)).getNorm(), 1.0e-14);
// check the same cached instance is returned the second time
assertTrue(q == transformer.getQ());
assertTrue(t == transformer.getT());
}