Clean up linear serialization tests
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@780521 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5881224dcf
commit
6fecb32ad6
|
@ -1252,25 +1252,9 @@ public final class DenseFieldMatrixTest extends TestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void testSerial() {
|
public void testSerial() {
|
||||||
try {
|
DenseFieldMatrix<Fraction> m = new DenseFieldMatrix<Fraction>(testData);
|
||||||
File test = File.createTempFile("DFM",".ser");
|
assertEquals(m,TestUtils.serializeAndRecover(m));
|
||||||
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(test));
|
|
||||||
DenseFieldMatrix<Fraction> m = new DenseFieldMatrix<Fraction>(testData);
|
|
||||||
out.writeObject(m);
|
|
||||||
out.close();
|
|
||||||
ObjectInputStream in = new ObjectInputStream(new FileInputStream(test));
|
|
||||||
DenseFieldMatrix<Fraction> nm = (DenseFieldMatrix<Fraction>)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 DefaultFieldMatrixChangingVisitor<Fraction> {
|
private static class SetVisitor extends DefaultFieldMatrixChangingVisitor<Fraction> {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.io.ObjectOutputStream;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.apache.commons.math.TestUtils;
|
||||||
import org.apache.commons.math.linear.decomposition.LUDecompositionImpl;
|
import org.apache.commons.math.linear.decomposition.LUDecompositionImpl;
|
||||||
import org.apache.commons.math.linear.decomposition.NonSquareMatrixException;
|
import org.apache.commons.math.linear.decomposition.NonSquareMatrixException;
|
||||||
|
|
||||||
|
@ -1163,23 +1164,8 @@ public final class DenseRealMatrixTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSerial() {
|
public void testSerial() {
|
||||||
try {
|
DenseRealMatrix m = new DenseRealMatrix(testData);
|
||||||
File test = File.createTempFile("DRM",".ser");
|
assertEquals(m,TestUtils.serializeAndRecover(m));
|
||||||
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 class SetVisitor extends DefaultRealMatrixChangingVisitor {
|
||||||
|
|
|
@ -939,25 +939,9 @@ public final class FieldMatrixImplTest extends TestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void testSerial() {
|
public void testSerial() {
|
||||||
try {
|
FieldMatrixImpl<Fraction> m = new FieldMatrixImpl<Fraction>(testData);
|
||||||
File test = File.createTempFile("FMI",".ser");
|
assertEquals(m,TestUtils.serializeAndRecover(m));
|
||||||
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(test));
|
|
||||||
FieldMatrixImpl<Fraction> m = new FieldMatrixImpl<Fraction>(testData);
|
|
||||||
out.writeObject(m);
|
|
||||||
out.close();
|
|
||||||
ObjectInputStream in = new ObjectInputStream(new FileInputStream(test));
|
|
||||||
FieldMatrixImpl<Fraction> nm = (FieldMatrixImpl<Fraction>)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 DefaultFieldMatrixChangingVisitor<Fraction> {
|
private static class SetVisitor extends DefaultFieldMatrixChangingVisitor<Fraction> {
|
||||||
|
|
|
@ -31,6 +31,7 @@ import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.apache.commons.math.Field;
|
import org.apache.commons.math.Field;
|
||||||
import org.apache.commons.math.FieldElement;
|
import org.apache.commons.math.FieldElement;
|
||||||
|
import org.apache.commons.math.TestUtils;
|
||||||
import org.apache.commons.math.fraction.Fraction;
|
import org.apache.commons.math.fraction.Fraction;
|
||||||
import org.apache.commons.math.fraction.FractionField;
|
import org.apache.commons.math.fraction.FractionField;
|
||||||
|
|
||||||
|
@ -618,25 +619,9 @@ public class FieldVectorImplTest extends TestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void testSerial() {
|
public void testSerial() {
|
||||||
try {
|
FieldVectorImpl<Fraction> v = new FieldVectorImpl<Fraction>(vec1);
|
||||||
File test = File.createTempFile("FVI",".ser");
|
assertEquals(v,TestUtils.serializeAndRecover(v));
|
||||||
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(test));
|
|
||||||
FieldVectorImpl<Fraction> v = new FieldVectorImpl<Fraction>(vec1);
|
|
||||||
out.writeObject(v);
|
|
||||||
out.close();
|
|
||||||
ObjectInputStream in = new ObjectInputStream(new FileInputStream(test));
|
|
||||||
FieldVectorImpl<Fraction> nv = (FieldVectorImpl<Fraction>)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 equals */
|
/** verifies that two vectors are equals */
|
||||||
|
|
|
@ -942,23 +942,8 @@ public final class RealMatrixImplTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSerial() {
|
public void testSerial() {
|
||||||
try {
|
RealMatrixImpl m = new RealMatrixImpl(testData);
|
||||||
File test = File.createTempFile("RMI",".ser");
|
assertEquals(m,TestUtils.serializeAndRecover(m));
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import org.apache.commons.math.TestUtils;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
@ -1176,23 +1179,8 @@ public class RealVectorImplTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSerial() {
|
public void testSerial() {
|
||||||
try {
|
RealVectorImpl v = new RealVectorImpl(new double[] { 0, 1, 2 });
|
||||||
File test = File.createTempFile("RVI",".ser");
|
assertEquals(v,TestUtils.serializeAndRecover(v));
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.apache.commons.math.TestUtils;
|
||||||
import org.apache.commons.math.linear.decomposition.LUDecompositionImpl;
|
import org.apache.commons.math.linear.decomposition.LUDecompositionImpl;
|
||||||
import org.apache.commons.math.linear.decomposition.NonSquareMatrixException;
|
import org.apache.commons.math.linear.decomposition.NonSquareMatrixException;
|
||||||
|
|
||||||
|
@ -649,23 +650,8 @@ public final class SparseRealMatrixTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSerial() {
|
public void testSerial() {
|
||||||
try {
|
OpenMapRealMatrix m = createSparseMatrix(testData);
|
||||||
File test = File.createTempFile("OMRM",".ser");
|
assertEquals(m,TestUtils.serializeAndRecover(m));
|
||||||
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
|
// --------------- -----------------Protected methods
|
||||||
|
|
|
@ -23,6 +23,9 @@ import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import org.apache.commons.math.TestUtils;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
@ -1100,23 +1103,8 @@ public class SparseRealVectorTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSerial() {
|
public void testSerial() {
|
||||||
try {
|
OpenMapRealVector v = new OpenMapRealVector(new double[] { 0, 1, 2 });
|
||||||
File test = File.createTempFile("OMV",".ser");
|
assertEquals(v,TestUtils.serializeAndRecover(v));
|
||||||
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) */
|
/** verifies that two vectors are close (sup norm) */
|
||||||
|
|
Loading…
Reference in New Issue