public void testCrossProduct() {
   Matrix result = test.cross(test);
   assertEquals("row size", test.size(), result.size()[0]);
   assertEquals("col size", test.size(), result.size()[1]);
   for (int row = 0; row < result.size()[0]; row++) {
     for (int col = 0; col < result.size()[1]; col++) {
       assertEquals(
           "cross[" + row + "][" + col + ']',
           test.getQuick(row) * test.getQuick(col),
           result.getQuick(row, col));
     }
   }
 }
 public void testAssignVector() throws Exception {
   Vector other = new DenseVector(test.size());
   test.assign(other);
   for (int i = 0; i < values.length; i++) {
     assertEquals("value[" + i + ']', 0.0, test.getQuick(i));
   }
 }
 public void testAssignDoubleArray() throws Exception {
   double[] array = new double[test.size()];
   test.assign(array);
   for (int i = 0; i < values.length; i++) {
     assertEquals("value[" + i + ']', 0.0, test.getQuick(i));
   }
 }
 public void testAssignBinaryFunction3() throws Exception {
   test.assign(mult(4));
   for (int i = 0; i < values.length; i++) {
     if (i % 2 == 0) {
       assertEquals("get [" + i + ']', 0.0, test.get(i));
     } else {
       assertEquals("value[" + i + ']', values[i - 1] * 4, test.getQuick(i));
     }
   }
 }
Exemple #5
0
 @Override
 public Matrix assignRow(int row, Vector other) {
   if (columnSize() != other.size()) {
     throw new CardinalityException(columnSize(), other.size());
   }
   if (row < 0 || row >= rowSize()) {
     throw new IndexException(row, rowSize());
   }
   for (int col = 0; col < columnSize(); col++) {
     values[row][col] = other.getQuick(col);
   }
   return this;
 }
Exemple #6
0
 @Override
 public Matrix assignColumn(int column, Vector other) {
   if (rowSize() != other.size()) {
     throw new CardinalityException(rowSize(), other.size());
   }
   if (column < 0 || column >= columnSize()) {
     throw new IndexException(column, columnSize());
   }
   for (int row = 0; row < rowSize(); row++) {
     values[row][column] = other.getQuick(row);
   }
   return this;
 }
 public void testAssignUnaryFunction() {
   test.assign(NEGATE);
   for (int i = 1; i < values.length; i += 2) {
     assertEquals("value[" + i + ']', -values[i], test.getQuick(i + 2));
   }
 }
 public void testAssignDouble() {
   test.assign(0);
   for (int i = 0; i < values.length; i++) {
     assertEquals("value[" + i + ']', 0.0, test.getQuick(i));
   }
 }