Exemplo n.º 1
0
        /// <summary>
        /// Loads a new matrix from a serialized binary file.
        /// </summary>
        /// <param name="fileName"></param>
        /// <see cref="MatrixIO.loadBin{DMatrix}(string)"/>
        public static SimpleMatrixD loadBinary(string fileName)
        {
            DMatrix mat = MatrixIO.loadBin <DMatrix>(fileName);

            // see if its a DMatrixRMaj
            if (mat is DMatrixRMaj)
            {
                return(wrap(mat as DMatrixRMaj));
            }
            else
            {
                // if not convert it into one and wrap it
                return(wrap(new DMatrixRMaj(mat)));
            }
        }
Exemplo n.º 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);
            }
        }