/** * Creates the interpolation (prolongation) matrix based on the * non-smoothed aggregates */ private SparseCCDoubleMatrix2D createInterpolationMatrix(int[] pt, int c) { SparseCCMDoubleMatrix2D If = new SparseCCMDoubleMatrix2D(pt.length, c); for (int i = 0; i < pt.length; ++i) if (pt[i] != -1) If.setQuick(i, pt[i], 1); return (SparseCCDoubleMatrix2D) (new SparseCCDoubleMatrix2D(If.rows(), If.columns()).assign(If)); }
/** * Returns a new matrix that has the same elements as this matrix, but is in * a column-compressed modified form. This method creates a new object (not * a view), so changes in the returned matrix are NOT reflected in this * matrix. * * @return this matrix in a column-compressed modified form */ public SparseCCMDoubleMatrix2D getColumnCompressedModified() { SparseCCMDoubleMatrix2D A = new SparseCCMDoubleMatrix2D(rows, columns); int nnz = cardinality(); long[] keys = elements.keys().elements(); double[] values = elements.values().elements(); for (int i = 0; i < nnz; i++) { int row = (int) (keys[i] / columns); int column = (int) (keys[i] % columns); A.setQuick(row, column, values[i]); } return A; }
public DoubleMatrix2D like(int rows, int columns) { return new SparseCCMDoubleMatrix2D(rows, columns); } }
/** * Constructs a matrix with a given number of rows and columns. All entries * are initially <tt>0</tt>. * * @param rows * the number of rows the matrix shall have. * @param columns * the number of columns the matrix shall have. * @throws IllegalArgumentException * if * <tt>rows<0 || columns<0 || (double)columns*rows > Integer.MAX_VALUE</tt> * . */ public SparseCCMDoubleMatrix2D(int rows, int columns) { super(null); try { setUp(rows, columns); } catch (IllegalArgumentException exc) { // we can hold rows*columns>Integer.MAX_VALUE cells ! if (!"matrix too large".equals(exc.getMessage())) throw exc; } elements = new SparseDoubleMatrix1D[columns]; for (int i = 0; i < columns; ++i) elements[i] = new SparseDoubleMatrix1D(rows); }
/** * Returns a new matrix that has the same elements as this matrix, but is in * a column-compressed modified form. This method creates a new object (not * a view), so changes in the returned matrix are NOT reflected in this * matrix. * * @return this matrix in a column-compressed modified form */ public SparseCCMDoubleMatrix2D getColumnCompressedModified() { SparseCCMDoubleMatrix2D A = new SparseCCMDoubleMatrix2D(rows, columns); int nnz = cardinality(); long[] keys = elements.keys().elements(); double[] values = elements.values().elements(); for (int i = 0; i < nnz; i++) { int row = (int) (keys[i] / columns); int column = (int) (keys[i] % columns); A.setQuick(row, column, values[i]); } return A; }
public DoubleMatrix2D like(int rows, int columns) { return new SparseCCMDoubleMatrix2D(rows, columns); } }
/** * Constructs a matrix with a given number of rows and columns. All entries * are initially <tt>0</tt>. * * @param rows * the number of rows the matrix shall have. * @param columns * the number of columns the matrix shall have. * @throws IllegalArgumentException * if * <tt>rows<0 || columns<0 || (double)columns*rows > Integer.MAX_VALUE</tt> * . */ public SparseCCMDoubleMatrix2D(int rows, int columns) { super(null); try { setUp(rows, columns); } catch (IllegalArgumentException exc) { // we can hold rows*columns>Integer.MAX_VALUE cells ! if (!"matrix too large".equals(exc.getMessage())) throw exc; } elements = new SparseDoubleMatrix1D[columns]; for (int i = 0; i < columns; ++i) elements[i] = new SparseDoubleMatrix1D(rows); }
/** * Creates the interpolation (prolongation) matrix based on the * non-smoothed aggregates */ private SparseCCDoubleMatrix2D createInterpolationMatrix(int[] pt, int c) { SparseCCMDoubleMatrix2D If = new SparseCCMDoubleMatrix2D(pt.length, c); for (int i = 0; i < pt.length; ++i) if (pt[i] != -1) If.setQuick(i, pt[i], 1); return (SparseCCDoubleMatrix2D) (new SparseCCDoubleMatrix2D(If.rows(), If.columns()).assign(If)); }