List of utility methods to do Matrix Copy
boolean[][] | copyMatrix(boolean[][] matrix) copy Matrix int maxY = matrix.length; int maxX = matrix[0].length; boolean[][] copy = new boolean[maxY][maxX]; for (int y = 0; y < maxY; y++) { for (int x = 0; x < maxX; x++) { copy[y][x] = matrix[y][x]; return copy; |
boolean[][] | copyMatrix(boolean[][] old) copy Matrix return copyMatrix(old, old.length);
|
double[][] | copyMatrix(final double[][] c) copy Matrix final double[][] a = new double[c.length][]; for (int i = 0; i < c.length; ++i) { a[i] = new double[c[i].length]; for (int j = 0; j < c[i].length; ++j) { a[i][j] = c[i][j]; return a; ... |
void | copyMatrix(final double[][] src, final double[][] dest, int n) Copies a quadratic matrix from one array to another without any safety checks. assert hasShape(src, n, n); assert hasShape(dest, n, n); assert src != dest; for (int i = 0; i < n; i++) { System.arraycopy(src[i], 0, dest[i], 0, n); |
double[][] | copyMatrix(final int rowsCount, final int columnsCount, final double[][] origMatrix) copy Matrix final double[][] copiedMatrix = new double[rowsCount][columnsCount]; for (int i = 0; i <= rowsCount; i++) { copiedMatrix[i] = new double[columnsCount]; System.arraycopy(origMatrix[i], 0, copiedMatrix[i], 0, columnsCount); return copiedMatrix; |
void | copyMatrix(float[] origin, float destination[]) copy Matrix System.arraycopy(origin, 0, destination, 0, origin.length); |
void | copyMatrixBlock(final double[][] src, int i_src, int j_src, final double[][] dest, int i_dest, int j_dest, int rows, int cols) Copies a block from one matrix to another assert src != null; assert dest != null; assert src != dest; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { dest[i_dest + i][j_dest + j] = src[i_src + i][j_src + j]; |
double[][] | copyMatrixEliminateRowAndColumn(double[][] matrix, int rowToEliminate, int colToEliminate) copy Matrix Eliminate Row And Column double[][] newMatrix = new double[matrix.length - 1][matrix[0].length - 1]; for (int r = 0; r < matrix.length; r++) { if (r == rowToEliminate) { continue; for (int c = 0; c < matrix.length; c++) { if (c == colToEliminate) { continue; ... |
float[] | copyMatrixRow(final float[] m_in, final int m_in_off, final int row, final float[] v_out, final int v_out_off) Copy the named row of the given column-major matrix to v_out. v_out[0 + v_out_off] = m_in[row + 0 * 4 + m_in_off]; v_out[1 + v_out_off] = m_in[row + 1 * 4 + m_in_off]; v_out[2 + v_out_off] = m_in[row + 2 * 4 + m_in_off]; if (v_out.length > 3 + v_out_off) { v_out[3 + v_out_off] = m_in[row + 3 * 4 + m_in_off]; return v_out; |
int[][] | matrixCopy(int[][] matrix) matrix Copy if (matrix == null) { return null; int[][] result = new int[matrix.length][]; for (int i = 0; i < matrix.length; ++i) { result[i] = Arrays.copyOf(matrix[i], matrix[i].length); return result; ... |