Esempio n. 1
0
 @Test(expected = IllegalArgumentException.class)
 public void testDotAbnormal() {
   double[] arr1 = new double[] {1, 2, 3};
   double[] arr2 = new double[] {4, 5};
   DoubleVector vec1 = new DenseDoubleVector(arr1);
   DoubleVector vec2 = new DenseDoubleVector(arr2);
   vec1.add(vec2);
 }
Esempio n. 2
0
 @Test(expected = IllegalArgumentException.class)
 public void testAddWithException() {
   double[] vals1 = {1, 2, 3, 4, 5, 6, 7, 8};
   double[] vals2 = {8, 7, 6, 5, 4, 3, 2, 1, 0};
   DoubleVector vec1 = new DenseDoubleVector(vals1);
   DoubleVector vec2 = new DenseDoubleVector(vals2);
   vec1.add(vec2);
 }
Esempio n. 3
0
 @Test
 public void testAddNormal() {
   double[] arr1 = new double[] {1, 2, 3};
   double[] arr2 = new double[] {4, 5, 6};
   DoubleVector vec1 = new DenseDoubleVector(arr1);
   DoubleVector vec2 = new DenseDoubleVector(arr2);
   double[] arrExp = new double[] {5, 7, 9};
   assertArrayEquals(arrExp, vec1.add(vec2).toArray(), 0.000001);
 }
Esempio n. 4
0
  @Test(expected = AssertionError.class)
  public void deepCopy() {
    double[] vals1 = {0, 1, 2, 3, 4, 5, 6, 7, 8};
    double[] vals2 = {8, 7, 6, 5, 4, 3, 2, 1, 0};
    DoubleVector vec1 = new DenseDoubleVector(vals1);
    DoubleVector vec2 = new DenseDoubleVector(vals2);

    DoubleVector vec3 = vec1.deepCopy();
    vec1 = vec1.add(vec2);
    assertEquals(vec1, vec3);
  }