commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billbar...@apache.org
Subject svn commit: r778071 - in /commons/proper/math/trunk/src: java/org/apache/commons/math/linear/ test/org/apache/commons/math/linear/
Date Sun, 24 May 2009 00:02:54 GMT
Author: billbarker
Date: Sun May 24 00:02:54 2009
New Revision: 778071

URL: http://svn.apache.org/viewvc?rev=778071&view=rev
Log:
Serializable changes for RealMatrix

Modified:
    commons/proper/math/trunk/src/java/org/apache/commons/math/linear/AbstractRealMatrix.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealMatrix.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealMatrix.java
    commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseRealMatrixTest.java
    commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java
    commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealMatrixTest.java

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/AbstractRealMatrix.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/AbstractRealMatrix.java?rev=778071&r1=778070&r2=778071&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/AbstractRealMatrix.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/AbstractRealMatrix.java
Sun May 24 00:02:54 2009
@@ -34,11 +34,9 @@
  * @version $Revision$ $Date$
  * @since 2.0
  */
-public abstract class AbstractRealMatrix implements RealMatrix, Serializable {
+public abstract class AbstractRealMatrix implements RealMatrix {
+    
     
-    /** Serializable version identifier. */
-    private static final long serialVersionUID = -3665653040524315561L;
-
     /** Cached LU solver.
      * @deprecated as of release 2.0, since all methods using this are deprecated
      */

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealMatrix.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealMatrix.java?rev=778071&r1=778070&r2=778071&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealMatrix.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealMatrix.java
Sun May 24 00:02:54 2009
@@ -17,6 +17,8 @@
 
 package org.apache.commons.math.linear;
 
+import java.io.Serializable;
+
 import org.apache.commons.math.util.OpenIntToDoubleHashMap;
 
 /**
@@ -25,7 +27,7 @@
  * @version $Revision$ $Date$
  * @since 2.0
  */
-public class OpenMapRealMatrix extends AbstractRealMatrix implements SparseRealMatrix {
+public class OpenMapRealMatrix extends AbstractRealMatrix implements SparseRealMatrix, Serializable
{
 
     /** Serializable version identifier. */
     private static final long serialVersionUID = -5962461716457143437L;

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealMatrix.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealMatrix.java?rev=778071&r1=778070&r2=778071&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealMatrix.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealMatrix.java Sun
May 24 00:02:54 2009
@@ -32,7 +32,7 @@
  * 
  * @version $Revision$ $Date$
  */
-public interface RealMatrix extends AnyMatrix, Serializable {
+public interface RealMatrix extends AnyMatrix {
 
     /**
      * Create a new RealMatrix of the same type as the instance with the supplied

Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseRealMatrixTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseRealMatrixTest.java?rev=778071&r1=778070&r2=778071&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseRealMatrixTest.java
(original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseRealMatrixTest.java
Sun May 24 00:02:54 2009
@@ -16,6 +16,12 @@
  */
 package org.apache.commons.math.linear;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.Arrays;
 import java.util.Random;
 
@@ -1156,6 +1162,26 @@
 
     }
     
+    public void testSerial()  {
+        try {
+            File test = File.createTempFile("DRM",".ser");
+            ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(test));
+            DenseRealMatrix m = new DenseRealMatrix(testData);
+            out.writeObject(m);
+            out.close();
+            ObjectInputStream in = new ObjectInputStream(new FileInputStream(test));
+            DenseRealMatrix nm = (DenseRealMatrix)in.readObject();
+            in.close();
+            test.delete();
+            assertEquals(m,nm);
+            
+        } catch (IOException e) {
+            fail("IOException: "+e);
+        } catch (ClassNotFoundException e) {
+            fail("Can't happen: "+e);
+        }
+    }
+        
     private static class SetVisitor extends DefaultRealMatrixChangingVisitor {
         private static final long serialVersionUID = 1773444180892369386L;
         @Override

Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java?rev=778071&r1=778070&r2=778071&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java
(original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java
Sun May 24 00:02:54 2009
@@ -16,6 +16,13 @@
  */
 package org.apache.commons.math.linear;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
@@ -933,6 +940,27 @@
         }
 
     }
+
+    public void testSerial()  {
+        try {
+            File test = File.createTempFile("RMI",".ser");
+            ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(test));
+            RealMatrixImpl m = new RealMatrixImpl(testData);
+            out.writeObject(m);
+            out.close();
+            ObjectInputStream in = new ObjectInputStream(new FileInputStream(test));
+            RealMatrixImpl nm = (RealMatrixImpl)in.readObject();
+            in.close();
+            test.delete();
+            assertEquals(m,nm);
+            
+        } catch (IOException e) {
+            fail("IOException: "+e);
+        } catch (ClassNotFoundException e) {
+            fail("Can't happen: "+e);
+        }
+    }
+    
     
     private static class SetVisitor extends DefaultRealMatrixChangingVisitor {
         private static final long serialVersionUID = -5082825244208703349L;

Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealMatrixTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealMatrixTest.java?rev=778071&r1=778070&r2=778071&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealMatrixTest.java
(original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealMatrixTest.java
Sun May 24 00:02:54 2009
@@ -16,6 +16,13 @@
  */
 package org.apache.commons.math.linear;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
@@ -641,6 +648,26 @@
 
     }
 
+    public void testSerial()  {
+        try {
+            File test = File.createTempFile("OMRM",".ser");
+            ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(test));
+            OpenMapRealMatrix m = createSparseMatrix(testData);
+            out.writeObject(m);
+            out.close();
+            ObjectInputStream in = new ObjectInputStream(new FileInputStream(test));
+            OpenMapRealMatrix nm = (OpenMapRealMatrix)in.readObject();
+            in.close();
+            test.delete();
+            assertEquals(m,nm);
+
+        } catch (IOException e) {
+            fail("IOException: "+e);
+        } catch (ClassNotFoundException e) {
+            fail("Can't happen: "+e);
+        }
+    }
+
     // --------------- -----------------Protected methods
 
     /** verifies that two matrices are close (1-norm) */
@@ -670,4 +697,6 @@
         }
         return matrix;
     }
+
+
 }



Mime
View raw message