Ejemplo n.º 1
0
 @Test(expected = IllegalArgumentException.class)
 public void testMultiplyAbnormal() {
   double[] arr1 = new double[] {1, 2, 3};
   double[] arr2 = new double[] {4, 5};
   DoubleVector vec1 = new DenseDoubleVector(arr1);
   DoubleVector vec2 = new DenseDoubleVector(arr2);
   vec1.multiply(vec2);
 }
Ejemplo n.º 2
0
 @Test(expected = IllegalArgumentException.class)
 public void testVectorMultiplyMatrixAbnormal() {
   DoubleVector vec = new DenseDoubleVector(new double[] {1, 2, 3});
   DoubleMatrix mat =
       new DenseDoubleMatrix(
           new double[][] {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}});
   vec.multiply(mat);
 }
Ejemplo n.º 3
0
 @Test(expected = IllegalArgumentException.class)
 public void testMultiplyWithException() {
   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.multiply(vec2);
 }
Ejemplo n.º 4
0
 @Test
 public void testMultiplyNormal() {
   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[] {4, 10, 18};
   assertArrayEquals(arrExp, vec1.multiply(vec2).toArray(), 0.000001);
 }
Ejemplo n.º 5
0
  @Test
  public void testVectorMultiplyMatrix() {
    DoubleVector vec = new DenseDoubleVector(new double[] {1, 2, 3});
    DoubleMatrix mat =
        new DenseDoubleMatrix(new double[][] {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}});
    double[] expectedRes = new double[] {38, 44, 50, 56};

    assertArrayEquals(expectedRes, vec.multiply(mat).toArray(), 0.000001);
  }