Details

Bug

Status: Closed

Major

Resolution: Fixed

3.1

None

JAVA
Description
In the method getQT() of TriDiagonalTransformer we have:
public RealMatrix getQT() {
if (cachedQt == null) {
final int m = householderVectors.length;
cachedQt = MatrixUtils.createRealMatrix(m, m);
// build up first part of the matrix by applying Householder transforms
for (int k = m  1; k >= 1; k) {
final double[] hK = householderVectors[k  1];
cachedQt.setEntry(k, k, 1);
final double inv = 1.0 / (secondary[k  1] * hK[k]);
if (hK[k] != 0.0) {
double beta = 1.0 / secondary[k  1];
The faulty line is : final double inv = 1.0 / (secondary[k  1] * hK[k]);
It should be put after the test for the zero, eg:
public RealMatrix getQT() {
if (cachedQt == null) {
final int m = householderVectors.length;
cachedQt = MatrixUtils.createRealMatrix(m, m);
// build up first part of the matrix by applying Householder transforms
for (int k = m  1; k >= 1; k) {
final double[] hK = householderVectors[k  1];
cachedQt.setEntry(k, k, 1);
if (hK[k] != 0.0) {
final double inv = 1.0 / (secondary[k  1] * hK[k]);
double beta = 1.0 / secondary[k  1];