Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-652

Tridiagonal QR decomposition has a faulty test for zero...

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1
    • Fix Version/s: 3.0
    • Environment:

      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];

        Attachments

        1. tridiagonal
          0.9 kB
          greg sterijevski

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gsteri1 greg sterijevski
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified