commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r780309 - /commons/proper/math/trunk/src/java/org/apache/commons/math/ode/NordsieckTransformer.java
Date Sat, 30 May 2009 18:38:23 GMT
Author: luc
Date: Sat May 30 18:38:23 2009
New Revision: 780309

URL: http://svn.apache.org/viewvc?rev=780309&view=rev
Log:
use the conversion functions from MatrixUtils

Modified:
    commons/proper/math/trunk/src/java/org/apache/commons/math/ode/NordsieckTransformer.java

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/ode/NordsieckTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/ode/NordsieckTransformer.java?rev=780309&r1=780308&r2=780309&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/ode/NordsieckTransformer.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/ode/NordsieckTransformer.java
Sat May 30 18:38:23 2009
@@ -21,12 +21,11 @@
 import java.math.BigInteger;
 
 import org.apache.commons.math.fraction.BigFraction;
-import org.apache.commons.math.linear.DefaultFieldMatrixPreservingVisitor;
 import org.apache.commons.math.linear.FieldMatrix;
 import org.apache.commons.math.linear.FieldMatrixImpl;
 import org.apache.commons.math.linear.InvalidMatrixException;
+import org.apache.commons.math.linear.MatrixUtils;
 import org.apache.commons.math.linear.RealMatrix;
-import org.apache.commons.math.linear.RealMatrixImpl;
 import org.apache.commons.math.linear.decomposition.FieldDecompositionSolver;
 import org.apache.commons.math.linear.decomposition.FieldLUDecompositionImpl;
 
@@ -116,17 +115,12 @@
 
         // from Nordsieck to multistep
         final FieldMatrix<BigFraction> bigNtoM = buildNordsieckToMultistep(p, q, r,
s);
-        Convertor convertor = new Convertor();
-        bigNtoM.walkInOptimizedOrder(convertor);
-        nordsieckToMultistep = convertor.getConvertedMatrix();
+        nordsieckToMultistep = MatrixUtils.bigFractionMatrixToRealMatrix(bigNtoM);
 
         // from multistep to Nordsieck
         final FieldDecompositionSolver<BigFraction> solver =
             new FieldLUDecompositionImpl<BigFraction>(bigNtoM).getSolver();
-        final FieldMatrix<BigFraction> bigMtoN = solver.getInverse();
-        convertor = new Convertor();
-        bigMtoN.walkInOptimizedOrder(convertor);
-        multistepToNordsieck = convertor.getConvertedMatrix();
+        multistepToNordsieck = MatrixUtils.bigFractionMatrixToRealMatrix(solver.getInverse());
 
     }
 
@@ -185,39 +179,6 @@
 
     }
 
-    /** Convertor for {@link FieldMatrix}/{@link BigFraction}. */
-    private static class Convertor extends DefaultFieldMatrixPreservingVisitor<BigFraction>
{
-
-        /** Converted array. */
-        private double[][] data;
-
-        /** Simple constructor. */
-        public Convertor() {
-            super(BigFraction.ZERO);
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public void start(int rows, int columns,
-                          int startRow, int endRow, int startColumn, int endColumn) {
-            data = new double[rows][columns];
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public void visit(int row, int column, BigFraction value) {
-            data[row][column] = value.doubleValue();
-        }
-
-        /** Get the converted matrix.
-         * @return converted matrix
-         */
-        RealMatrix getConvertedMatrix() {
-            return new RealMatrixImpl(data, false);
-        }
-
-    }
-
     /**
      * Transform a scalar state history from multistep form to Nordsieck form.
      * <p>



Mime
View raw message