Ok, so laking add/subtract tests now. I'll try to add later, but checking in the existing tests so that [math] will at least build.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@775787 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
William Barker 2009-05-18 01:05:39 +00:00
parent 5ce6c81490
commit f3f0fcc1e4
2 changed files with 68 additions and 68 deletions

View File

@ -24,7 +24,7 @@ import org.apache.commons.math.linear.decomposition.LUDecompositionImpl;
import org.apache.commons.math.linear.decomposition.NonSquareMatrixException; import org.apache.commons.math.linear.decomposition.NonSquareMatrixException;
/** /**
* Test cases for the {@link SparseRealMatrix} class. * Test cases for the {@link OpenMapRealMatrix} class.
* *
* @version $Revision$ $Date: 2008-11-07 06:48:13 -0800 (Fri, 07 Nov * @version $Revision$ $Date: 2008-11-07 06:48:13 -0800 (Fri, 07 Nov
* 2008) $ * 2008) $
@ -117,8 +117,8 @@ public final class SparseRealMatrixTest extends TestCase {
/** test dimensions */ /** test dimensions */
public void testDimensions() { public void testDimensions() {
SparseRealMatrix m = createSparseMatrix(testData); OpenMapRealMatrix m = createSparseMatrix(testData);
SparseRealMatrix m2 = createSparseMatrix(testData2); OpenMapRealMatrix m2 = createSparseMatrix(testData2);
assertEquals("testData row dimension", 3, m.getRowDimension()); assertEquals("testData row dimension", 3, m.getRowDimension());
assertEquals("testData column dimension", 3, m.getColumnDimension()); assertEquals("testData column dimension", 3, m.getColumnDimension());
assertTrue("testData is square", m.isSquare()); assertTrue("testData is square", m.isSquare());
@ -129,21 +129,21 @@ public final class SparseRealMatrixTest extends TestCase {
/** test copy functions */ /** test copy functions */
public void testCopyFunctions() { public void testCopyFunctions() {
SparseRealMatrix m1 = createSparseMatrix(testData); OpenMapRealMatrix m1 = createSparseMatrix(testData);
RealMatrix m2 = m1.copy(); RealMatrix m2 = m1.copy();
assertTrue(m2 instanceof SparseRealMatrix); assertTrue(m2 instanceof OpenMapRealMatrix);
assertEquals((m2), m1); assertEquals((m2), m1);
SparseRealMatrix m3 = createSparseMatrix(testData); OpenMapRealMatrix m3 = createSparseMatrix(testData);
RealMatrix m4 = m3.copy(); RealMatrix m4 = m3.copy();
assertTrue(m4 instanceof SparseRealMatrix); assertTrue(m4 instanceof OpenMapRealMatrix);
assertEquals((m4), m3); assertEquals((m4), m3);
} }
/** test add */ /** test add */
public void testAdd() { public void testAdd() {
SparseRealMatrix m = createSparseMatrix(testData); OpenMapRealMatrix m = createSparseMatrix(testData);
SparseRealMatrix mInv = createSparseMatrix(testDataInv); OpenMapRealMatrix mInv = createSparseMatrix(testDataInv);
SparseRealMatrix mDataPlusInv = createSparseMatrix(testDataPlusInv); OpenMapRealMatrix mDataPlusInv = createSparseMatrix(testDataPlusInv);
RealMatrix mPlusMInv = m.add(mInv); RealMatrix mPlusMInv = m.add(mInv);
for (int row = 0; row < m.getRowDimension(); row++) { for (int row = 0; row < m.getRowDimension(); row++) {
for (int col = 0; col < m.getColumnDimension(); col++) { for (int col = 0; col < m.getColumnDimension(); col++) {
@ -156,8 +156,8 @@ public final class SparseRealMatrixTest extends TestCase {
/** test add failure */ /** test add failure */
public void testAddFail() { public void testAddFail() {
SparseRealMatrix m = createSparseMatrix(testData); OpenMapRealMatrix m = createSparseMatrix(testData);
SparseRealMatrix m2 = createSparseMatrix(testData2); OpenMapRealMatrix m2 = createSparseMatrix(testData2);
try { try {
m.add(m2); m.add(m2);
fail("IllegalArgumentException expected"); fail("IllegalArgumentException expected");
@ -168,16 +168,16 @@ public final class SparseRealMatrixTest extends TestCase {
/** test norm */ /** test norm */
public void testNorm() { public void testNorm() {
SparseRealMatrix m = createSparseMatrix(testData); OpenMapRealMatrix m = createSparseMatrix(testData);
SparseRealMatrix m2 = createSparseMatrix(testData2); OpenMapRealMatrix m2 = createSparseMatrix(testData2);
assertEquals("testData norm", 14d, m.getNorm(), entryTolerance); assertEquals("testData norm", 14d, m.getNorm(), entryTolerance);
assertEquals("testData2 norm", 7d, m2.getNorm(), entryTolerance); assertEquals("testData2 norm", 7d, m2.getNorm(), entryTolerance);
} }
/** test m-n = m + -n */ /** test m-n = m + -n */
public void testPlusMinus() { public void testPlusMinus() {
SparseRealMatrix m = createSparseMatrix(testData); OpenMapRealMatrix m = createSparseMatrix(testData);
SparseRealMatrix n = createSparseMatrix(testDataInv); OpenMapRealMatrix n = createSparseMatrix(testDataInv);
assertClose("m-n = m + -n", m.subtract(n), assertClose("m-n = m + -n", m.subtract(n),
n.scalarMultiply(-1d).add(m), entryTolerance); n.scalarMultiply(-1d).add(m), entryTolerance);
try { try {
@ -190,10 +190,10 @@ public final class SparseRealMatrixTest extends TestCase {
/** test multiply */ /** test multiply */
public void testMultiply() { public void testMultiply() {
SparseRealMatrix m = createSparseMatrix(testData); OpenMapRealMatrix m = createSparseMatrix(testData);
SparseRealMatrix mInv = createSparseMatrix(testDataInv); OpenMapRealMatrix mInv = createSparseMatrix(testDataInv);
SparseRealMatrix identity = createSparseMatrix(id); OpenMapRealMatrix identity = createSparseMatrix(id);
SparseRealMatrix m2 = createSparseMatrix(testData2); OpenMapRealMatrix m2 = createSparseMatrix(testData2);
assertClose("inverse multiply", m.multiply(mInv), identity, assertClose("inverse multiply", m.multiply(mInv), identity,
entryTolerance); entryTolerance);
assertClose("inverse multiply", m.multiply(new DenseRealMatrix(testDataInv)), identity, assertClose("inverse multiply", m.multiply(new DenseRealMatrix(testDataInv)), identity,
@ -308,9 +308,9 @@ public final class SparseRealMatrixTest extends TestCase {
RealMatrix m5 = createSparseMatrix(d5); RealMatrix m5 = createSparseMatrix(d5);
assertClose("m3*m4=m5", m4.preMultiply(m3), m5, entryTolerance); assertClose("m3*m4=m5", m4.preMultiply(m3), m5, entryTolerance);
SparseRealMatrix m = createSparseMatrix(testData); OpenMapRealMatrix m = createSparseMatrix(testData);
SparseRealMatrix mInv = createSparseMatrix(testDataInv); OpenMapRealMatrix mInv = createSparseMatrix(testDataInv);
SparseRealMatrix identity = createSparseMatrix(id); OpenMapRealMatrix identity = createSparseMatrix(id);
assertClose("inverse multiply", m.preMultiply(mInv), identity, assertClose("inverse multiply", m.preMultiply(mInv), identity,
entryTolerance); entryTolerance);
assertClose("inverse multiply", mInv.preMultiply(m), identity, assertClose("inverse multiply", mInv.preMultiply(m), identity,
@ -542,9 +542,9 @@ public final class SparseRealMatrixTest extends TestCase {
} }
public void testEqualsAndHashCode() { public void testEqualsAndHashCode() {
SparseRealMatrix m = createSparseMatrix(testData); OpenMapRealMatrix m = createSparseMatrix(testData);
SparseRealMatrix m1 = (SparseRealMatrix) m.copy(); OpenMapRealMatrix m1 = (OpenMapRealMatrix) m.copy();
SparseRealMatrix mt = (SparseRealMatrix) m.transpose(); OpenMapRealMatrix mt = (OpenMapRealMatrix) m.transpose();
assertTrue(m.hashCode() != mt.hashCode()); assertTrue(m.hashCode() != mt.hashCode());
assertEquals(m.hashCode(), m1.hashCode()); assertEquals(m.hashCode(), m1.hashCode());
assertEquals(m, m); assertEquals(m, m);
@ -555,15 +555,15 @@ public final class SparseRealMatrixTest extends TestCase {
} }
public void testToString() { public void testToString() {
SparseRealMatrix m = createSparseMatrix(testData); OpenMapRealMatrix m = createSparseMatrix(testData);
assertEquals("SparseRealMatrix{{1.0,2.0,3.0},{2.0,5.0,3.0},{1.0,0.0,8.0}}", assertEquals("OpenMapRealMatrix{{1.0,2.0,3.0},{2.0,5.0,3.0},{1.0,0.0,8.0}}",
m.toString()); m.toString());
m = new SparseRealMatrix(1, 1); m = new OpenMapRealMatrix(1, 1);
assertEquals("SparseRealMatrix{{0.0}}", m.toString()); assertEquals("OpenMapRealMatrix{{0.0}}", m.toString());
} }
public void testSetSubMatrix() throws Exception { public void testSetSubMatrix() throws Exception {
SparseRealMatrix m = createSparseMatrix(testData); OpenMapRealMatrix m = createSparseMatrix(testData);
m.setSubMatrix(detData2, 1, 1); m.setSubMatrix(detData2, 1, 1);
RealMatrix expected = createSparseMatrix(new double[][] { RealMatrix expected = createSparseMatrix(new double[][] {
{ 1.0, 2.0, 3.0 }, { 2.0, 1.0, 3.0 }, { 1.0, 2.0, 4.0 } }); { 1.0, 2.0, 3.0 }, { 2.0, 1.0, 3.0 }, { 1.0, 2.0, 4.0 } });
@ -580,7 +580,7 @@ public final class SparseRealMatrixTest extends TestCase {
assertEquals(expected, m); assertEquals(expected, m);
// javadoc example // javadoc example
SparseRealMatrix matrix = OpenMapRealMatrix matrix =
createSparseMatrix(new double[][] { createSparseMatrix(new double[][] {
{ 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 0, 1, 2 } }); { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 0, 1, 2 } });
matrix.setSubMatrix(new double[][] { { 3, 4 }, { 5, 6 } }, 1, 1); matrix.setSubMatrix(new double[][] { { 3, 4 }, { 5, 6 } }, 1, 1);
@ -617,7 +617,7 @@ public final class SparseRealMatrixTest extends TestCase {
// expected // expected
} }
try { try {
new SparseRealMatrix(0, 0); new OpenMapRealMatrix(0, 0);
fail("expecting IllegalArgumentException"); fail("expecting IllegalArgumentException");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
// expected // expected
@ -661,8 +661,8 @@ public final class SparseRealMatrixTest extends TestCase {
} }
} }
private SparseRealMatrix createSparseMatrix(double[][] data) { private OpenMapRealMatrix createSparseMatrix(double[][] data) {
SparseRealMatrix matrix = new SparseRealMatrix(data.length, data[0].length); OpenMapRealMatrix matrix = new OpenMapRealMatrix(data.length, data[0].length);
for (int row = 0; row < data.length; row++) { for (int row = 0; row < data.length; row++) {
for (int col = 0; col < data[row].length; col++) { for (int col = 0; col < data[row].length; col++) {
matrix.setEntry(row, col, data[row][col]); matrix.setEntry(row, col, data[row][col]);

View File

@ -22,7 +22,7 @@ import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
/** /**
* Test cases for the {@link SparseRealVector} class. * Test cases for the {@link OpenMapRealVector} class.
* *
* @version $Revision: 728186 $ $Date$ * @version $Revision: 728186 $ $Date$
*/ */
@ -101,7 +101,7 @@ public class SparseRealVectorTest extends TestCase {
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
out[i] = data[i] * d; out[i] = data[i] * d;
} }
return new SparseRealVector(out); return new OpenMapRealVector(out);
} }
public RealVector mapMultiplyToSelf(double d) { public RealVector mapMultiplyToSelf(double d) {
@ -466,14 +466,14 @@ public class SparseRealVectorTest extends TestCase {
public void testConstructors() { public void testConstructors() {
SparseRealVector v0 = new SparseRealVector(); OpenMapRealVector v0 = new OpenMapRealVector();
assertEquals("testData len", 0, v0.getDimension()); assertEquals("testData len", 0, v0.getDimension());
SparseRealVector v1 = new SparseRealVector(7); OpenMapRealVector v1 = new OpenMapRealVector(7);
assertEquals("testData len", 7, v1.getDimension()); assertEquals("testData len", 7, v1.getDimension());
assertEquals("testData is 0.0 ", 0.0, v1.getEntry(6)); assertEquals("testData is 0.0 ", 0.0, v1.getEntry(6));
SparseRealVector v3 = new SparseRealVector(vec1); OpenMapRealVector v3 = new OpenMapRealVector(vec1);
assertEquals("testData len", 3, v3.getDimension()); assertEquals("testData len", 3, v3.getDimension());
assertEquals("testData is 2.0 ", 2.0, v3.getEntry(1)); assertEquals("testData is 2.0 ", 2.0, v3.getEntry(1));
@ -489,25 +489,25 @@ public class SparseRealVectorTest extends TestCase {
// fail("wrong exception caught"); // fail("wrong exception caught");
//} //}
RealVector v5_i = new SparseRealVector(dvec1); RealVector v5_i = new OpenMapRealVector(dvec1);
assertEquals("testData len", 9, v5_i.getDimension()); assertEquals("testData len", 9, v5_i.getDimension());
assertEquals("testData is 9.0 ", 9.0, v5_i.getEntry(8)); assertEquals("testData is 9.0 ", 9.0, v5_i.getEntry(8));
SparseRealVector v5 = new SparseRealVector(dvec1); OpenMapRealVector v5 = new OpenMapRealVector(dvec1);
assertEquals("testData len", 9, v5.getDimension()); assertEquals("testData len", 9, v5.getDimension());
assertEquals("testData is 9.0 ", 9.0, v5.getEntry(8)); assertEquals("testData is 9.0 ", 9.0, v5.getEntry(8));
SparseRealVector v7 = new SparseRealVector(v1); OpenMapRealVector v7 = new OpenMapRealVector(v1);
assertEquals("testData len", 7, v7.getDimension()); assertEquals("testData len", 7, v7.getDimension());
assertEquals("testData is 0.0 ", 0.0, v7.getEntry(6)); assertEquals("testData is 0.0 ", 0.0, v7.getEntry(6));
SparseRealVectorTestImpl v7_i = new SparseRealVectorTestImpl(vec1); SparseRealVectorTestImpl v7_i = new SparseRealVectorTestImpl(vec1);
SparseRealVector v7_2 = new SparseRealVector(v7_i); OpenMapRealVector v7_2 = new OpenMapRealVector(v7_i);
assertEquals("testData len", 3, v7_2.getDimension()); assertEquals("testData len", 3, v7_2.getDimension());
assertEquals("testData is 0.0 ", 2.0d, v7_2.getEntry(1)); assertEquals("testData is 0.0 ", 2.0d, v7_2.getEntry(1));
SparseRealVector v8 = new SparseRealVector(v1); OpenMapRealVector v8 = new OpenMapRealVector(v1);
assertEquals("testData len", 7, v8.getDimension()); assertEquals("testData len", 7, v8.getDimension());
assertEquals("testData is 0.0 ", 0.0, v8.getEntry(6)); assertEquals("testData is 0.0 ", 0.0, v8.getEntry(6));
@ -515,9 +515,9 @@ public class SparseRealVectorTest extends TestCase {
public void testDataInOut() { public void testDataInOut() {
SparseRealVector v1 = new SparseRealVector(vec1); OpenMapRealVector v1 = new OpenMapRealVector(vec1);
SparseRealVector v2 = new SparseRealVector(vec2); OpenMapRealVector v2 = new OpenMapRealVector(vec2);
SparseRealVector v4 = new SparseRealVector(vec4); OpenMapRealVector v4 = new OpenMapRealVector(vec4);
SparseRealVectorTestImpl v2_t = new SparseRealVectorTestImpl(vec2); SparseRealVectorTestImpl v2_t = new SparseRealVectorTestImpl(vec2);
RealVector v_append_1 = v1.append(v2); RealVector v_append_1 = v1.append(v2);
@ -548,7 +548,7 @@ public class SparseRealVectorTest extends TestCase {
fail("wrong exception caught"); fail("wrong exception caught");
} }
SparseRealVector v_set1 = (SparseRealVector) v1.copy(); OpenMapRealVector v_set1 = (OpenMapRealVector) v1.copy();
v_set1.setEntry(1, 11.0); v_set1.setEntry(1, 11.0);
assertEquals("testData is 11.0 ", 11.0, v_set1.getEntry(1)); assertEquals("testData is 11.0 ", 11.0, v_set1.getEntry(1));
try { try {
@ -560,7 +560,7 @@ public class SparseRealVectorTest extends TestCase {
fail("wrong exception caught"); fail("wrong exception caught");
} }
SparseRealVector v_set2 = (SparseRealVector) v4.copy(); OpenMapRealVector v_set2 = (OpenMapRealVector) v4.copy();
v_set2.setSubVector(3, v1); v_set2.setSubVector(3, v1);
assertEquals("testData is 1.0 ", 1.0, v_set2.getEntry(3)); assertEquals("testData is 1.0 ", 1.0, v_set2.getEntry(3));
assertEquals("testData is 7.0 ", 7.0, v_set2.getEntry(6)); assertEquals("testData is 7.0 ", 7.0, v_set2.getEntry(6));
@ -573,7 +573,7 @@ public class SparseRealVectorTest extends TestCase {
fail("wrong exception caught"); fail("wrong exception caught");
} }
SparseRealVector v_set3 = (SparseRealVector) v1.copy(); OpenMapRealVector v_set3 = (OpenMapRealVector) v1.copy();
v_set3.set(13.0); v_set3.set(13.0);
assertEquals("testData is 13.0 ", 13.0, v_set3.getEntry(2)); assertEquals("testData is 13.0 ", 13.0, v_set3.getEntry(2));
@ -586,7 +586,7 @@ public class SparseRealVectorTest extends TestCase {
fail("wrong exception caught"); fail("wrong exception caught");
} }
SparseRealVector v_set4 = (SparseRealVector) v4.copy(); OpenMapRealVector v_set4 = (OpenMapRealVector) v4.copy();
v_set4.setSubVector(3, v2_t); v_set4.setSubVector(3, v2_t);
assertEquals("testData is 1.0 ", 4.0, v_set4.getEntry(3)); assertEquals("testData is 1.0 ", 4.0, v_set4.getEntry(3));
assertEquals("testData is 7.0 ", 7.0, v_set4.getEntry(6)); assertEquals("testData is 7.0 ", 7.0, v_set4.getEntry(6));
@ -603,7 +603,7 @@ public class SparseRealVectorTest extends TestCase {
} }
public void testMapFunctions() { public void testMapFunctions() {
SparseRealVector v1 = new SparseRealVector(vec1); OpenMapRealVector v1 = new OpenMapRealVector(vec1);
//octave = v1 .+ 2.0 //octave = v1 .+ 2.0
RealVector v_mapAdd = v1.mapAdd(2.0d); RealVector v_mapAdd = v1.mapAdd(2.0d);
@ -783,7 +783,7 @@ public class SparseRealVectorTest extends TestCase {
assertClose("compare vectors" ,result_mapTanToSelf,v_mapTanToSelf.getData(),normTolerance); assertClose("compare vectors" ,result_mapTanToSelf,v_mapTanToSelf.getData(),normTolerance);
double[] vat_a = {0d, 0.5d, 1.0d}; double[] vat_a = {0d, 0.5d, 1.0d};
SparseRealVector vat = new SparseRealVector(vat_a); OpenMapRealVector vat = new OpenMapRealVector(vat_a);
//octave = acos(vat) //octave = acos(vat)
RealVector v_mapAcos = vat.mapAcos(); RealVector v_mapAcos = vat.mapAcos();
@ -830,7 +830,7 @@ public class SparseRealVectorTest extends TestCase {
assertClose("compare vectors" ,result_mapInvToSelf,v_mapInvToSelf.getData(),normTolerance); assertClose("compare vectors" ,result_mapInvToSelf,v_mapInvToSelf.getData(),normTolerance);
double[] abs_a = {-1.0d, 0.0d, 1.0d}; double[] abs_a = {-1.0d, 0.0d, 1.0d};
SparseRealVector abs_v = new SparseRealVector(abs_a); OpenMapRealVector abs_v = new OpenMapRealVector(abs_a);
//octave = abs(abs_v) //octave = abs(abs_v)
RealVector v_mapAbs = abs_v.mapAbs(); RealVector v_mapAbs = abs_v.mapAbs();
@ -855,7 +855,7 @@ public class SparseRealVectorTest extends TestCase {
assertClose("compare vectors" ,result_mapSqrtToSelf,v_mapSqrtToSelf.getData(),normTolerance); assertClose("compare vectors" ,result_mapSqrtToSelf,v_mapSqrtToSelf.getData(),normTolerance);
double[] cbrt_a = {-2.0d, 0.0d, 2.0d}; double[] cbrt_a = {-2.0d, 0.0d, 2.0d};
SparseRealVector cbrt_v = new SparseRealVector(cbrt_a); OpenMapRealVector cbrt_v = new OpenMapRealVector(cbrt_a);
//octave = ??? //octave = ???
RealVector v_mapCbrt = cbrt_v.mapCbrt(); RealVector v_mapCbrt = cbrt_v.mapCbrt();
@ -869,7 +869,7 @@ public class SparseRealVectorTest extends TestCase {
assertClose("compare vectors" ,result_mapCbrtToSelf,v_mapCbrtToSelf.getData(),normTolerance); assertClose("compare vectors" ,result_mapCbrtToSelf,v_mapCbrtToSelf.getData(),normTolerance);
double[] ceil_a = {-1.1d, 0.9d, 1.1d}; double[] ceil_a = {-1.1d, 0.9d, 1.1d};
SparseRealVector ceil_v = new SparseRealVector(ceil_a); OpenMapRealVector ceil_v = new OpenMapRealVector(ceil_a);
//octave = ceil(ceil_v) //octave = ceil(ceil_v)
RealVector v_mapCeil = ceil_v.mapCeil(); RealVector v_mapCeil = ceil_v.mapCeil();
@ -931,9 +931,9 @@ public class SparseRealVectorTest extends TestCase {
} }
public void testBasicFunctions() { public void testBasicFunctions() {
SparseRealVector v1 = new SparseRealVector(vec1); OpenMapRealVector v1 = new OpenMapRealVector(vec1);
SparseRealVector v2 = new SparseRealVector(vec2); OpenMapRealVector v2 = new OpenMapRealVector(vec2);
SparseRealVector v_null = new SparseRealVector(vec_null); OpenMapRealVector v_null = new OpenMapRealVector(vec_null);
SparseRealVectorTestImpl v2_t = new SparseRealVectorTestImpl(vec2); SparseRealVectorTestImpl v2_t = new SparseRealVectorTestImpl(vec2);
@ -970,7 +970,7 @@ public class SparseRealVectorTest extends TestCase {
assertEquals("compare values ",3d, d_getLInfDistance_2 ); assertEquals("compare values ",3d, d_getLInfDistance_2 );
//octave = v1 + v2 //octave = v1 + v2
SparseRealVector v_add = v1.add(v2); OpenMapRealVector v_add = v1.add(v2);
double[] result_add = {5d, 7d, 9d}; double[] result_add = {5d, 7d, 9d};
assertClose("compare vect" ,v_add.getData(),result_add,normTolerance); assertClose("compare vect" ,v_add.getData(),result_add,normTolerance);
@ -980,7 +980,7 @@ public class SparseRealVectorTest extends TestCase {
assertClose("compare vect" ,v_add_i.getData(),result_add_i,normTolerance); assertClose("compare vect" ,v_add_i.getData(),result_add_i,normTolerance);
//octave = v1 - v2 //octave = v1 - v2
SparseRealVector v_subtract = v1.subtract(v2); OpenMapRealVector v_subtract = v1.subtract(v2);
double[] result_subtract = {-3d, -3d, -3d}; double[] result_subtract = {-3d, -3d, -3d};
assertClose("compare vect" ,v_subtract.getData(),result_subtract,normTolerance); assertClose("compare vect" ,v_subtract.getData(),result_subtract,normTolerance);
@ -1033,7 +1033,7 @@ public class SparseRealVectorTest extends TestCase {
fail("wrong exception caught"); fail("wrong exception caught");
} }
SparseRealVector v_unitize = (SparseRealVector)v1.copy(); OpenMapRealVector v_unitize = (OpenMapRealVector)v1.copy();
v_unitize.unitize(); v_unitize.unitize();
assertClose("compare vect" ,v_unitVector_2.getData(),v_unitize.getData(),normTolerance); assertClose("compare vect" ,v_unitVector_2.getData(),v_unitize.getData(),normTolerance);
try { try {
@ -1056,7 +1056,7 @@ public class SparseRealVectorTest extends TestCase {
} }
public void testMisc() { public void testMisc() {
SparseRealVector v1 = new SparseRealVector(vec1); OpenMapRealVector v1 = new OpenMapRealVector(vec1);
String out1 = v1.toString(); String out1 = v1.toString();
assertTrue("some output ", out1.length()!=0); assertTrue("some output ", out1.length()!=0);
@ -1074,7 +1074,7 @@ public class SparseRealVectorTest extends TestCase {
public void testPredicates() { public void testPredicates() {
SparseRealVector v = new SparseRealVector(new double[] { 0, 1, 2 }); OpenMapRealVector v = new OpenMapRealVector(new double[] { 0, 1, 2 });
assertFalse(v.isNaN()); assertFalse(v.isNaN());
v.setEntry(1, Double.NaN); v.setEntry(1, Double.NaN);
@ -1087,9 +1087,9 @@ public class SparseRealVectorTest extends TestCase {
assertTrue(v.isInfinite()); assertTrue(v.isInfinite());
v.setEntry(0, 0); v.setEntry(0, 0);
assertEquals(v, new SparseRealVector(new double[] { 0, 1, 2 })); assertEquals(v, new OpenMapRealVector(new double[] { 0, 1, 2 }));
assertNotSame(v, new SparseRealVector(new double[] { 0, 1, 2 + Math.ulp(2)})); assertNotSame(v, new OpenMapRealVector(new double[] { 0, 1, 2 + Math.ulp(2)}));
assertNotSame(v, new SparseRealVector(new double[] { 0, 1, 2, 3 })); assertNotSame(v, new OpenMapRealVector(new double[] { 0, 1, 2, 3 }));
} }