public DoubleMatrix2D reshape(int rows, int columns) { if (rows * columns != size) { throw new IllegalArgumentException("rows*columns != size"); } DoubleMatrix2D M = new SparseDoubleMatrix2D(rows, columns); int idx = 0; for (int c = 0; c < columns; c++) { for (int r = 0; r < rows; r++) { M.setQuick(r, c, getQuick(idx++)); } } return M; }
public DoubleMatrix2D reshape(int rows, int columns) { if (rows * columns != size) { throw new IllegalArgumentException("rows*columns != size"); } DoubleMatrix2D M = new SparseDoubleMatrix2D(rows, columns); int idx = 0; for (int c = 0; c < columns; c++) { for (int r = 0; r < rows; r++) { M.setQuick(r, c, getQuick(idx++)); } } return M; }
public DoubleMatrix3D reshape(int slices, int rows, int columns) { if (slices * rows * columns != size) { throw new IllegalArgumentException("slices*rows*columns != size"); } DoubleMatrix3D M = new SparseDoubleMatrix3D(slices, rows, columns); int idx = 0; for (int s = 0; s < slices; s++) { for (int c = 0; c < columns; c++) { for (int r = 0; r < rows; r++) { M.setQuick(s, r, c, getQuick(idx++)); } } } return M; }
public DoubleMatrix3D reshape(int slices, int rows, int columns) { if (slices * rows * columns != size) { throw new IllegalArgumentException("slices*rows*columns != size"); } DoubleMatrix3D M = new SparseDoubleMatrix3D(slices, rows, columns); int idx = 0; for (int s = 0; s < slices; s++) { for (int c = 0; c < columns; c++) { for (int r = 0; r < rows; r++) { M.setQuick(s, r, c, getQuick(idx++)); } } } return M; }