commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From celes...@apache.org
Subject svn commit: r1172472 - in /commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear: BlockFieldMatrixTest.java FieldMatrixImplTest.java SparseFieldMatrixTest.java
Date Mon, 19 Sep 2011 06:18:41 GMT
Author: celestin
Date: Mon Sep 19 06:18:40 2011
New Revision: 1172472

URL: http://svn.apache.org/viewvc?rev=1172472&view=rev
Log:
Replaced call to FieldDecompositionSolver<T>.solve(T[]) by FieldDecompositionSolver<T>.solve(FieldVector<T>).
This is in accordance with JIRA MATH-661.

Modified:
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BlockFieldMatrixTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldMatrixImplTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BlockFieldMatrixTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BlockFieldMatrixTest.java?rev=1172472&r1=1172471&r2=1172472&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BlockFieldMatrixTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BlockFieldMatrixTest.java
Mon Sep 19 06:18:40 2011
@@ -543,8 +543,13 @@ public final class BlockFieldMatrixTest 
                 {new Fraction(4), new Fraction(-3), new Fraction(-5)}
         };
         FieldMatrix<Fraction> coefficients = new BlockFieldMatrix<Fraction>(coefficientsData);
-        Fraction[] constants = {new Fraction(1), new Fraction(-2), new Fraction(1)};
-        Fraction[] solution = new FieldLUDecompositionImpl<Fraction>(coefficients).getSolver().solve(constants);
+        Fraction[] constants = {
+            new Fraction(1), new Fraction(-2), new Fraction(1)
+        };
+        Fraction[] solution;
+        solution = new FieldLUDecompositionImpl<Fraction>(coefficients)
+            .getSolver()
+            .solve(new ArrayFieldVector<Fraction>(constants, false)).toArray();
         Assert.assertEquals(new Fraction(2).multiply(solution[0]).
                      add(new Fraction(3).multiply(solution[1])).
                      subtract(new Fraction(2).multiply(solution[2])),

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldMatrixImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldMatrixImplTest.java?rev=1172472&r1=1172471&r2=1172472&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldMatrixImplTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldMatrixImplTest.java
Mon Sep 19 06:18:40 2011
@@ -204,30 +204,30 @@ public final class FieldMatrixImplTest {
         FieldMatrix<Fraction> mInv = new Array2DRowFieldMatrix<Fraction>(testDataInv);
         FieldMatrix<Fraction> mPlusInv = new Array2DRowFieldMatrix<Fraction>(testDataPlusInv);
         FieldMatrix<Fraction> identity = new Array2DRowFieldMatrix<Fraction>(id);
-        
-        TestUtils.assertEquals(m.power(0), identity);        
-        TestUtils.assertEquals(mInv.power(0), identity);        
+
+        TestUtils.assertEquals(m.power(0), identity);
+        TestUtils.assertEquals(mInv.power(0), identity);
         TestUtils.assertEquals(mPlusInv.power(0), identity);
-        
-        TestUtils.assertEquals(m.power(1), m);        
-        TestUtils.assertEquals(mInv.power(1), mInv);        
-        TestUtils.assertEquals(mPlusInv.power(1), mPlusInv); 
-        
+
+        TestUtils.assertEquals(m.power(1), m);
+        TestUtils.assertEquals(mInv.power(1), mInv);
+        TestUtils.assertEquals(mPlusInv.power(1), mPlusInv);
+
         FieldMatrix<Fraction> C1 = m.copy();
         FieldMatrix<Fraction> C2 = mInv.copy();
         FieldMatrix<Fraction> C3 = mPlusInv.copy();
-        
+
         // stop at 5 to avoid overflow
         for (int i = 2; i <= 5; ++i) {
             C1 = C1.multiply(m);
             C2 = C2.multiply(mInv);
             C3 = C3.multiply(mPlusInv);
-            
-            TestUtils.assertEquals(m.power(i), C1);        
-            TestUtils.assertEquals(mInv.power(i), C2);        
-            TestUtils.assertEquals(mPlusInv.power(i), C3);            
+
+            TestUtils.assertEquals(m.power(i), C1);
+            TestUtils.assertEquals(mInv.power(i), C2);
+            TestUtils.assertEquals(mPlusInv.power(i), C3);
         }
-        
+
         try {
             FieldMatrix<Fraction> mNotSquare = new Array2DRowFieldMatrix<Fraction>(testData2T);
             mNotSquare.power(2);
@@ -235,7 +235,7 @@ public final class FieldMatrixImplTest {
         } catch (NonSquareMatrixException ex) {
             // ignored
         }
-        
+
         try {
             m.power(-1);
             Assert.fail("Expecting IllegalArgumentException");
@@ -406,8 +406,13 @@ public final class FieldMatrixImplTest {
                 {new Fraction(4), new Fraction(-3), new Fraction(-5)}
         };
         FieldMatrix<Fraction> coefficients = new Array2DRowFieldMatrix<Fraction>(coefficientsData);
-        Fraction[] constants = {new Fraction(1), new Fraction(-2), new Fraction(1)};
-        Fraction[] solution = new FieldLUDecompositionImpl<Fraction>(coefficients).getSolver().solve(constants);
+        Fraction[] constants = {
+            new Fraction(1), new Fraction(-2), new Fraction(1)
+        };
+        Fraction[] solution;
+        solution = new FieldLUDecompositionImpl<Fraction>(coefficients)
+            .getSolver()
+            .solve(new ArrayFieldVector<Fraction>(constants, false)).toArray();
         Assert.assertEquals(new Fraction(2).multiply(solution[0]).
                      add(new Fraction(3).multiply(solution[1])).
                      subtract(new Fraction(2).multiply(solution[2])), constants[0]);

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java?rev=1172472&r1=1172471&r2=1172472&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java
Mon Sep 19 06:18:40 2011
@@ -396,7 +396,10 @@ public class SparseFieldMatrixTest {
                 { new Fraction(4), new Fraction(-3), new Fraction(-5) } };
         FieldMatrix<Fraction> coefficients = createSparseMatrix(coefficientsData);
         Fraction[] constants = { new Fraction(1), new Fraction(-2), new Fraction(1) };
-        Fraction[] solution = new FieldLUDecompositionImpl<Fraction>(coefficients).getSolver().solve(constants);
+        Fraction[] solution;
+        solution = new FieldLUDecompositionImpl<Fraction>(coefficients)
+            .getSolver()
+            .solve(new ArrayFieldVector<Fraction>(constants, false)).toArray();
         Assert.assertEquals((new Fraction(2).multiply((solution[0])).add(new Fraction(3).multiply(solution[1])).subtract(new
Fraction(2).multiply(solution[2]))).doubleValue(),
                 constants[0].doubleValue(), 1E-12);
         Assert.assertEquals(((new Fraction(-1).multiply(solution[0])).add(new Fraction(7).multiply(solution[1])).add(new
Fraction(6).multiply(solution[2]))).doubleValue(),



Mime
View raw message