/** * Generic, but slow, conversion function. * * @param input Input matrix. * @param output Output matrix. */ public static void convert(DMatrix input, DMatrix output) { if (output is ReshapeMatrix) { ((ReshapeMatrix)output).reshape(input.NumRows, input.NumCols); } else { if (input.NumRows != output.NumRows) { throw new ArgumentException("Number of rows do not match"); } if (input.NumCols != output.NumCols) { throw new ArgumentException("Number of columns do not match"); } } for (int i = 0; i < input.NumRows; i++) { for (int j = 0; j < input.NumCols; j++) { output.unsafe_set(i, j, input.unsafe_get(i, j)); } } }
/** * Generic, but slow, conversion function. * * @param input Input matrix. * @param output Output matrix. */ public static void convert(DMatrix input, DMatrix output) { if (input.getNumRows() != output.getNumRows()) { throw new ArgumentException("Number of rows do not match"); } if (input.getNumCols() != output.getNumCols()) { throw new ArgumentException("Number of columns do not match"); } for (int i = 0; i < input.getNumRows(); i++) { for (int j = 0; j < input.getNumCols(); j++) { output.unsafe_set(i, j, input.unsafe_get(i, j)); } } }