示例#1
0
        private void 二进制矩阵读写试验ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DateTime from  = DateTime.Now;
            int      order = 100;

            double[][] matrix = MatrixUtil.CreateRandom(order);
            //double[][] matrix = MatrixUtil.CreateIdentity(order);
            TimeSpan create = DateTime.Now - from;

            from = DateTime.Now;
            string path = @"C:\matrix.bmat";

            MatrixUtil.SaveToBinary(matrix, path);

            //TimeSpan write =  DateTime.Now - from;

            //from = DateTime.Now;
            //double[][] newMatrix = MatrixUtil.FromBinary(path);
            //TimeSpan read = DateTime.Now - from;
            //string msg = ""
            //    + "阶次:" + order + "\r\n"
            //    + "创建:" + create.TotalSeconds +"\r\n"
            //    + "写入:" + write.TotalSeconds + "\r\n"
            //    + "读取:" + read.TotalSeconds + "\r\n";
            //MessageBox.Show(msg
            //    );

            //稀疏矩阵

            Geo.Algorithm.SparseMatrix sM = new Geo.Algorithm.SparseMatrix(matrix);
            path = @"C:\matrix.sbmat";
            sM.ToBinary(path);

            Geo.Algorithm.SparseMatrix s = Geo.Algorithm.SparseMatrix.FromBinary(path);
            double[][] newSmMtirix       = s.GetMatrix();
            bool       equal             = MatrixUtil.IsEqual(newSmMtirix, matrix);


            //MatrixUtil.GetFormatedText(newMatrix);
        }