@Override protected Matrix matrixLike(int rows, int columns) { return matrix.like(rows, columns); }
@Override public Matrix like() { return m.like(rows, columns); }
@Override public Matrix like(int rows, int columns) { return m.like(rows,columns); }
@Override public Matrix like(int rows, int columns) { return matrix.like(rows, columns); }
/** * Return the eigenvector matrix * * @return V */ public Matrix getV() { return v.like().assign(v); }
/** * Return an empty matrix of the same underlying class as the receiver * * @return a Matrix */ @Override public Matrix like() { return new PivotedMatrix(base.like()); }
/** * Returns an empty matrix of the same underlying class as the receiver and of the specified * size. * * @param rows the int number of rows * @param columns the int number of columns */ @Override public Matrix like(int rows, int columns) { return new PivotedMatrix(base.like(rows, columns)); }
@Override public Vector like(int cardinality) { return matrix.like(cardinality, 1).viewColumn(0); }
/** * Return an empty vector of the same underlying class as the receiver * * @return a Vector */ @Override public Vector like() { return matrix.like(size(), 1).viewColumn(0); }
@Test(expected = CardinalityException.class) public void testTimesMatrixCardinality() { Matrix other = test.like(5, 8); test.times(other); }
@Override public Matrix timesLeft(Matrix that) { if (that.numCols() != diagonal.size()) { throw new IllegalArgumentException( "Incompatible number of rows in the left operand of matrix-matrix multiplication."); } Matrix m = that.like(); for (int col = 0; col < diagonal.size(); col++) { m.assignColumn(col, that.viewColumn(col).times(diagonal.getQuick(col))); } return m; }
@Override public Matrix timesRight(Matrix that) { if (that.numRows() != diagonal.size()) { throw new IllegalArgumentException("Incompatible number of rows in the right operand of matrix multiplication."); } Matrix m = that.like(); for (int row = 0; row < diagonal.size(); row++) { m.assignRow(row, that.viewRow(row).times(diagonal.getQuick(row))); } return m; }
@Test(expected = CardinalityException.class) public void testTimesMatrixCardinality() { Matrix other = test.like(5, 8); test.times(other); }
@Test public void testLikeIntInt() { Matrix like = test.like(4, 4); assertSame("type", like.getClass(), test.getClass()); assertEquals("rows", 4, like.rowSize()); assertEquals("columns", 4, like.columnSize()); }
@Test public void testLike() { Matrix like = test.like(); assertSame("type", like.getClass(), test.getClass()); assertEquals("rows", test.rowSize(), like.rowSize()); assertEquals("columns", test.columnSize(), like.columnSize()); }
@Override public Matrix matrixFactory(double[][] values) { Matrix base = new DenseMatrix(values); // for general tests, we just make a scrambled matrix and fill it // with the standard data. Then we can test the details of the // row and/or column swapping separately. PivotedMatrix pm = new PivotedMatrix(base.like()); pm.swap(0, 1); pm.swapRows(1, 2); pm.assign(base); return pm; }
@Test public void testLikeIntInt() { Matrix like = test.like(4, 4); assertTrue("type", like instanceof DenseMatrix); assertEquals("rows", 4, like.rowSize()); assertEquals("columns", 4, like.columnSize()); }
@Test public void testAssignMatrix() { Matrix value = test.like(); value.assign(test); for (int row = 0; row < test.rowSize(); row++) { for (int col = 0; col < test.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', test.getQuick(row, col), value.getQuick(row, col), EPSILON); } } }
@Test public void testAssignMatrix() { Matrix value = test.like(); value.assign(test); for (int row = 0; row < test.rowSize(); row++) { for (int col = 0; col < test.columnSize(); col++) { assertEquals("value[" + row + "][" + col + ']', test.getQuick(row, col), value.getQuick(row, col), EPSILON); } } }
@Test public void testLike() { Matrix like = test.like(); assertTrue("type", like instanceof DenseMatrix); assertEquals("rows", test.rowSize(), like.rowSize()); assertEquals("columns", test.columnSize(), like.columnSize()); }