commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billbar...@apache.org
Subject svn commit: r778058 - in /commons/proper/math/trunk/src: java/org/apache/commons/math/linear/ test/org/apache/commons/math/linear/
Date Sat, 23 May 2009 22:57:26 GMT
Author: billbarker
Date: Sat May 23 22:57:26 2009
New Revision: 778058

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

Modified:
    commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealVector.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVector.java
    commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealVectorImplTest.java
    commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealVectorTest.java

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealVector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealVector.java?rev=778058&r1=778057&r2=778058&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealVector.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealVector.java
Sat May 23 22:57:26 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.math.linear;
 
+import java.io.Serializable;
+
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.util.OpenIntToDoubleHashMap;
 import org.apache.commons.math.util.OpenIntToDoubleHashMap.Iterator;
@@ -25,7 +27,7 @@
  * @version $Revision: 728186 $ $Date$
  * @since 2.0
 */
-public class OpenMapRealVector implements SparseRealVector {
+public class OpenMapRealVector implements SparseRealVector, Serializable {
 
     /** Serializable version identifier. */
     private static final long serialVersionUID = 8772222695580707260L;

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVector.java?rev=778058&r1=778057&r2=778058&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVector.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVector.java Sat
May 23 22:57:26 2009
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.math.linear;
 
-import java.io.Serializable;
-
 /**
  * Interface defining a real-valued vector with basic algebraic operations.
  * <p>
@@ -41,7 +39,7 @@
  * @version $Revision$ $Date$
  * @since 2.0
  */
-public interface RealVector extends Serializable {
+public interface RealVector {
 
     /**
      * Returns a (deep) copy of this.

Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealVectorImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealVectorImplTest.java?rev=778058&r1=778057&r2=778058&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealVectorImplTest.java
(original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealVectorImplTest.java
Sat May 23 22:57:26 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.io.Serializable;
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -1169,6 +1175,27 @@
 
     }
 
+    public void testSerial()  {
+        try {
+            File test = File.createTempFile("RVI",".ser");
+            ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(test));
+            RealVectorImpl v = new RealVectorImpl(new double[] { 0, 1, 2 });
+            out.writeObject(v);
+            out.close();
+            ObjectInputStream in = new ObjectInputStream(new FileInputStream(test));
+            RealVectorImpl nv = (RealVectorImpl)in.readObject();
+            in.close();
+            test.delete();
+            assertEquals(v,nv);
+            
+        } catch (IOException e) {
+            fail("IOException: "+e);
+        } catch (ClassNotFoundException e) {
+            fail("Can't happen: "+e);
+        }
+    }
+    
+    
     /** verifies that two vectors are close (sup norm) */
     protected void assertClose(String msg, double[] m, double[] n,
             double tolerance) {

Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealVectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealVectorTest.java?rev=778058&r1=778057&r2=778058&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealVectorTest.java
(original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealVectorTest.java
Sat May 23 22:57:26 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.io.Serializable;
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -1093,6 +1099,26 @@
 
     }
 
+    public void testSerial()  {
+        try {
+            File test = File.createTempFile("OMV",".ser");
+            ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(test));
+            OpenMapRealVector v = new OpenMapRealVector(new double[] { 0, 1, 2 });
+            out.writeObject(v);
+            out.close();
+            ObjectInputStream in = new ObjectInputStream(new FileInputStream(test));
+            OpenMapRealVector nv = (OpenMapRealVector)in.readObject();
+            in.close();
+            test.delete();
+            assertEquals(v,nv);
+            
+        } catch (IOException e) {
+            fail("IOException: "+e);
+        } catch (ClassNotFoundException e) {
+            fail("Can't happen: "+e);
+        }
+    }
+    
     /** verifies that two vectors are close (sup norm) */
     protected void assertClose(String msg, double[] m, double[] n,
             double tolerance) {



Mime
View raw message