示例#1
0
 /// <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.");
     }
 }
示例#2
0
        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);
            }
        }