cloneMatrix method
Clones a matrix
: Returns a new matrix with same contents.
Implementation
List<List<double>> cloneMatrix(List<List<double>> matrix) {
int nrows = matrix[0].length;
int ncols = matrix.length;
List<List<double>> clone = createMatrix(nrows, ncols, 0.0);
for (int i = 0; i < nrows; i++) {
for (int k = 0; k < ncols; k++) {
clone[i][k] = matrix[i][k];
}
}
return clone;
}