/// <summary> /// Saves this matrix to a file as a serialized binary object. /// </summary> /// <exception cref="IOException"/> /// <see cref="MatrixIO.saveBin(DMatrix, string)"/> public void saveToFileBinary(string fileName) { if (mat is DMatrix) { MatrixIO.saveBin((DMatrix)mat, fileName); } else if (mat is FMatrix) { MatrixIO.saveBin((FMatrix)mat, fileName); } else { throw new InvalidOperationException("Unknown or unsupported matrix type."); } }
public static void serializedBinary() { DMatrixRMaj A = new DMatrixRMaj(2, 3, true, new double[] { 1, 2, 3, 4, 5, 6 }); try { MatrixIO.saveBin(A, "matrix_file.data"); DMatrixRMaj B = MatrixIO.loadBin <DMatrixRMaj>("matrix_file.data"); B.print(); } catch (IOException e) { throw new InvalidOperationException(e.Message, e); } }