/// <summary> /// Saves this matrix to a file in a CSV format. /// For the file format <see cref="MatrixIO"/>. /// </summary> /// <param name="fileName"></param> public void saveToFileCSV(string fileName) { if (mat is DMatrix) { MatrixIO.saveCSV((DMatrix)mat, fileName); } else if (mat is FMatrix) { MatrixIO.saveCSV((FMatrix)mat, fileName); } else { throw new InvalidOperationException("Unknown or unsupported matrix type."); } }
public static void csv() { DMatrixRMaj A = new DMatrixRMaj(2, 3, true, new double[] { 1, 2, 3, 4, 5, 6 }); try { MatrixIO.saveCSV(A, "matrix_file.csv"); DMatrixRMaj B = (DMatrixRMaj)MatrixIO.loadCSV("matrix_file.csv"); B.print(); } catch (IOException e) { throw new InvalidOperationException(e.Message, e); } }