Refine search
@Test public void testDenseVector() { Vector vec1 = new DenseVector(3); Vector vec2 = new DenseVector(3); doTestVectors(vec1, vec2); }
@Test(expected = CardinalityException.class) public void testAssignColumnCardinality() { double[] data = {2.1, 3.2}; test.assignColumn(1, new DenseVector(data)); }
@Test(expected = CardinalityException.class) public void testAssignRowCardinality() { double[] data = {2.1, 3.2, 4.3}; test.assignRow(1, new DenseVector(data)); }
@Test public void testIteratorDense() { testIterator(new DenseVector(99)); testEmptyAllIterator(new DenseVector(0)); testExample1NonZeroIterator(new DenseVector(13)); }
@Test public void testEmptyAggregate2() { assertEquals(3.0, new DenseVector(new double[]{1}).aggregate( new DenseVector(new double[]{2}), Functions.MIN, Functions.PLUS), EPSILON); assertEquals(0, new DenseVector(new double[0]).aggregate(new DenseVector(new double[0]), Functions.MIN, Functions.PLUS), 0); }
@Test(expected = CardinalityException.class) public void testAssignRowCardinality() { double[] data = {2.1, 3.2, 4.3}; test.assignRow(1, new DenseVector(data)); }
@Test(expected = CardinalityException.class) public void testAssignColumnCardinality() { double[] data = {2.1, 3.2}; test.assignColumn(1, new DenseVector(data)); }
@Test(expected = CardinalityException.class) public void testAssignVectorCardinality() { Vector other = new DenseVector(test.size() - 1); test.assign(other); }
@Test(expected = CardinalityException.class) public void testAssignVectorCardinality() { Vector other = new DenseVector(test.size() - 1); test.assign(other); }
@Test(expected = CardinalityException.class) public void testTimesVectorCardinality() { test.times(new DenseVector(test.size() + 1)); }
@Test(expected = CardinalityException.class) public void testTimesVectorCardinality() { test.times(new DenseVector(test.size() + 1)); }
@Test(expected = CardinalityException.class) public void testDotCardinality() { test.dot(new DenseVector(test.size() + 1)); }
@Test(expected = CardinalityException.class) public void testDotCardinality() { test.dot(new DenseVector(test.size() + 1)); }
@Test(expected = CardinalityException.class) public void testPlusVectorCardinality() { test.plus(new DenseVector(test.size() + 1)); }
@Test(expected = CardinalityException.class) public void testPlusVectorCardinality() { test.plus(new DenseVector(test.size() + 1)); }
@Test public void testEmptyAggregate1() { assertEquals(1.0, new DenseVector(new double[]{1}).aggregate(Functions.MIN, Functions.IDENTITY), EPSILON); assertEquals(1.0, new DenseVector(new double[]{2, 1}).aggregate(Functions.MIN, Functions.IDENTITY), EPSILON); assertEquals(0, new DenseVector(new double[0]).aggregate(Functions.MIN, Functions.IDENTITY), 0); }
@Test(expected = CardinalityException.class) public void testTimesVector() { Vector vectorA = new DenseVector(vectorAValues); Vector testTimesVectorA = test.times(vectorA); Vector expected = new DenseVector(new double[]{5.0, 11.0, 17.0}); assertTrue("Matrix times vector not equals: " + vectorA + " != " + testTimesVectorA, expected.minus(testTimesVectorA).norm(2) < 1.0e-12); test.times(testTimesVectorA); }
@Test @Repeat(iterations = 20) public void testDenseVectorWritable() throws Exception { Vector v = new DenseVector(MAX_VECTOR_SIZE); createRandom(v); doTestVectorWritableEquals(v); }
@Test public void testOrdering() { WeightedVector v1 = new WeightedVector(new DenseVector(new double[]{1, 2, 3}), 5.41, 31); WeightedVector v2 = new WeightedVector(new DenseVector(new double[]{1, 2, 3}), 5.00, 31); WeightedVector v3 = new WeightedVector(new DenseVector(new double[]{1, 3, 3}), 5.00, 31); WeightedVector v4 = v1.clone(); WeightedVectorComparator comparator = new WeightedVectorComparator(); assertTrue(comparator.compare(v1, v2) > 0); assertTrue(comparator.compare(v3, v1) < 0); assertTrue(comparator.compare(v3, v2) > 0); assertEquals(0, comparator.compare(v4, v1)); assertEquals(0, comparator.compare(v1, v1)); }
@Test public void testRadius() { MultiNormal gen = new MultiNormal(0.1, new DenseVector(10)); OnlineSummarizer s = new OnlineSummarizer(); for (int i = 0; i < 10000; i++) { double x = gen.sample().norm(2) / Math.sqrt(10); s.add(x); } assertEquals(0.1, s.getMean(), 0.01); } }