commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1403648 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructure.java test/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructureTest.java
Date Tue, 30 Oct 2012 09:52:10 GMT
Author: luc
Date: Tue Oct 30 09:52:09 2012
New Revision: 1403648

URL: http://svn.apache.org/viewvc?rev=1403648&view=rev
Log:
streamlined deserialization of DerivativeStructure

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructure.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructureTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructure.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructure.java?rev=1403648&r1=1403647&r2=1403648&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructure.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructure.java
Tue Oct 30 09:52:09 2012
@@ -887,9 +887,7 @@ public class DerivativeStructure impleme
          * @return replacement {@link DerivativeStructure}
          */
         private Object readResolve() {
-            final DerivativeStructure ds = new DerivativeStructure(variables, order);
-            System.arraycopy(data, 0, ds.data, 0, ds.data.length);
-            return ds;
+            return new DerivativeStructure(variables, order, data);
         }
 
     }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructureTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructureTest.java?rev=1403648&r1=1403647&r2=1403648&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructureTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructureTest.java
Tue Oct 30 09:52:09 2012
@@ -1128,6 +1128,15 @@ public class DerivativeStructureTest {
         TestUtils.assertEquals(derivatives, xRef.add(yRef.subtract(zRef)).getAllDerivatives(),
1.0e-15);
     }
 
+    @Test
+    public void testSerialization() {
+        DerivativeStructure a = new DerivativeStructure(3, 2, 0, 1.3);
+        DerivativeStructure b = (DerivativeStructure) TestUtils.serializeAndRecover(a);
+        Assert.assertEquals(a.getFreeParameters(), b.getFreeParameters());
+        Assert.assertEquals(a.getOrder(), b.getOrder());
+        checkEquals(a, b, 1.0e-15);
+    }
+
     private void checkF0F1(DerivativeStructure ds, double value, double...derivatives) {
 
         // check dimension



Mime
View raw message