You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2008/12/21 22:23:18 UTC

svn commit: r728507 - in /commons/proper/math/trunk/src: java/org/apache/commons/math/linear/TriDiagonalTransformer.java test/org/apache/commons/math/linear/EigenDecompositionImplTest.java

Author: luc
Date: Sun Dec 21 13:23:18 2008
New Revision: 728507

URL: http://svn.apache.org/viewvc?rev=728507&view=rev
Log:
reverted some changes introduced yesterday, as they lead to unexpected test failures

Modified:
    commons/proper/math/trunk/src/java/org/apache/commons/math/linear/TriDiagonalTransformer.java
    commons/proper/math/trunk/src/test/org/apache/commons/math/linear/EigenDecompositionImplTest.java

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/TriDiagonalTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/TriDiagonalTransformer.java?rev=728507&r1=728506&r2=728507&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/TriDiagonalTransformer.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/TriDiagonalTransformer.java Sun Dec 21 13:23:18 2008
@@ -106,33 +106,38 @@
         if (cachedQt == null) {
 
             final int m = householderVectors.length;
-            cachedQt = MatrixUtils.createRealMatrix(m, m);
+            final double[][] qtData  = new double[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];
                 final double inv = 1.0 / (secondary[k - 1] * hK[k]);
-                cachedQt.setEntry(k, k, 1);
+                qtData[k][k] = 1;
                 if (hK[k] != 0.0) {
+                    final double[] qtK = qtData[k];
                     double beta = 1.0 / secondary[k - 1];
-                    cachedQt.setEntry(k, k, 1 + beta * hK[k]);
+                    qtK[k] = 1 + beta * hK[k];
                     for (int i = k + 1; i < m; ++i) {
-                        cachedQt.setEntry(k, i, beta * hK[i]);
+                        qtK[i] = beta * hK[i];
                     }
                     for (int j = k + 1; j < m; ++j) {
+                        final double[] qtJ = qtData[j];
                         beta = 0;
                         for (int i = k + 1; i < m; ++i) {
-                            beta += cachedQt.getEntry(j, i) * hK[i];
+                            beta += qtJ[i] * hK[i];
                         }
                         beta *= inv;
-                        cachedQt.setEntry(j, k, beta * hK[k]);
+                        qtJ[k] = beta * hK[k];
                         for (int i = k + 1; i < m; ++i) {
-                            cachedQt.addToEntry(j, i, beta * hK[i]);
+                            qtJ[i] += beta * hK[i];
                         }
                     }
                 }
             }
-            cachedQt.setEntry(0, 0, 1);
+            qtData[0][0] = 1;
+
+            // cache the matrix for subsequent calls
+            cachedQt = new RealMatrixImpl(qtData, false);
 
         }
 
@@ -150,17 +155,21 @@
         if (cachedT == null) {
 
             final int m = main.length;
-            cachedT = MatrixUtils.createRealMatrix(m, m);
+            double[][] tData = new double[m][m];
             for (int i = 0; i < m; ++i) {
-                cachedT.setEntry(i, i, main[i]);
+                double[] tDataI = tData[i];
+                tDataI[i] = main[i];
                 if (i > 0) {
-                    cachedT.setEntry(i, i - 1, secondary[i - 1]);
+                    tDataI[i - 1] = secondary[i - 1];
                 }
                 if (i < main.length - 1) {
-                    cachedT.setEntry(i, i + 1, secondary[i]);
+                    tDataI[i + 1] = secondary[i];
                 }
             }
 
+            // cache the matrix for subsequent calls
+            cachedT = new RealMatrixImpl(tData, false);
+
         }
 
         // return the cached matrix

Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/EigenDecompositionImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/EigenDecompositionImplTest.java?rev=728507&r1=728506&r2=728507&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/linear/EigenDecompositionImplTest.java (original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/linear/EigenDecompositionImplTest.java Sun Dec 21 13:23:18 2008
@@ -366,7 +366,8 @@
             } while (norm2 * size < 0.01);
         }
 
-        return MatrixUtils.createRealMatrix(data);
+        //return MatrixUtils.createRealMatrix(data);
+        return new RealMatrixImpl(data, false);
 
     }