Tridiagonal QR decomposition has a faulty test for zero... -----------------------------------------------------------
Key: MATH-652 URL: https://issues.apache.org/jira/browse/MATH-652 Project: Commons Math Issue Type: Bug Affects Versions: 3.1 Environment: JAVA Reporter: greg sterijevski Fix For: 3.1 Attachments: tridiagonal 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]; -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira