/** * {@inheritDoc} */ public double[] getRow(int row) { return getRowVector(row).toArray(); }
/** * {@inheritDoc} */ public double get(int row, int col) { return getRowVector(row).get(col); }
/** * {@inheritDoc} */ public double get(int row, int col) { return getRowVector(row).get(col); }
/** * {@inheritDoc} */ public double[] getRow(int row) { return getRowVector(row).toArray(); }
/** * Returns the sum of all rows hash codes. */ public int hashCode() { int hash = 0; for (int i = 0; i < rows(); ++i) hash += getRowVector(i).hashCode(); return hash; }
/** * Returns the sum of all rows hash codes. */ public int hashCode() { int hash = 0; for (int i = 0; i < rows(); ++i) hash += getRowVector(i).hashCode(); return hash; }
/** * {@inheritDoc} */ public double[][] toDenseArray() { double[][] m = new double[rows()][columns()]; for (int r = 0; r < rows(); ++r) { m[r] = getRowVector(r).toArray(); } return m; }
/** * {@inheritDoc} */ public double[][] toDenseArray() { double[][] m = new double[rows()][columns()]; for (int r = 0; r < rows(); ++r) { m[r] = getRowVector(r).toArray(); } return m; } }
/** * {@inheritDoc} */ public DoubleVector getColumnVector(int column) { DoubleVector col = new DenseVector(rows()); for (int r = 0; r < rows(); ++r) col.set(r, getRowVector(r).get(column)); return col; }
/** * Returns {@code} if the object is a {@link Matrix} with the same * dimensions as whose values are equivalent. Value equivalence is computed * using {@link Vector} equality on the row vectors of each matrix. */ public boolean equals(Object o) { if (o instanceof Matrix) { Matrix m = (Matrix)o; if (m.rows() == rows() && m.columns() == columns()) { for (int row = 0; row < rows(); ++row) { if (!getRowVector(row).equals(m.getRowVector(row))) return false; } } } return false; }
/** * {@inheritDoc} */ public DoubleVector getColumnVector(int column) { DoubleVector col = new DenseVector(rows()); for (int r = 0; r < rows(); ++r) col.set(r, getRowVector(r).get(column)); return col; }