Example #1
0
        private void 文本矩阵读取试验ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DateTime from  = DateTime.Now;
            int      order = 98;

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

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

            MatrixUtil.SaveToText(matrix, path);

            TimeSpan write = DateTime.Now - from;

            from = DateTime.Now;
            double[][] newMatrix = MatrixUtil.ReadFromText(path);
            TimeSpan   read      = DateTime.Now - from;
            string     msg       = ""
                                   + "是否相等:" + MatrixUtil.IsEqual(newMatrix, matrix)
                                   + "阶次:" + order + "\r\n"
                                   + "创建:" + create.TotalSeconds + "\r\n"
                                   + "写入:" + write.TotalSeconds + "\r\n"
                                   + "读取:" + read.TotalSeconds + "\r\n";

            MessageBox.Show(msg);
        }
Example #2
0
        private void button_randomGen_Click(object sender, EventArgs e)
        {
            DateTime from = DateTime.Now;
            int      row  = this.namedIntControl_row.GetValue();
            int      col  = this.namedIntControl_col.GetValue();

            double[][]    matrix   = MatrixUtil.CreateRandom(row, col);
            Matrix        mat      = new Matrix(matrix);
            var           prefix   = namedStringControl_prefName.GetValue();
            List <string> rowNames = new List <string>();

            for (int i = 0; i < row; i++)
            {
                rowNames.Add(prefix + i.ToString("000"));
            }
            List <string> colNames = new List <string>();

            for (int i = 0; i < col; i++)
            {
                colNames.Add(prefix + i.ToString("000"));
            }

            mat.RowNames = rowNames;
            mat.ColNames = colNames;

            var span = DateTime.Now - from;

            log.Info("耗时:" + span.TotalSeconds + " s ," + span);

            DataBind(mat);
        }
Example #3
0
        private void button_randomGen_Click(object sender, EventArgs e)
        {
            DateTime from  = DateTime.Now;
            int      order = 100;
            int      row   = this.namedIntControl_row.GetValue();
            int      col   = this.namedIntControl_col.GetValue();
            var      name  = namedStringControl_name.GetValue();

            double[][]    matrix   = MatrixUtil.CreateRandom(row, col);
            Matrix        mat      = new Matrix(matrix);
            var           prefix   = namedStringControl_prefName.GetValue();
            List <string> rowNames = new List <string>();

            for (int i = 0; i < row; i++)
            {
                rowNames.Add(prefix + i.ToString("000"));
            }
            List <string> colNames = new List <string>();

            for (int i = 0; i < col; i++)
            {
                colNames.Add(prefix + i.ToString("000"));
            }

            mat.RowNames = rowNames;
            mat.ColNames = colNames;


            double[][] rigth = MatrixUtil.CreateRandom(row, 1);
            Matrix     rmat  = new Matrix(rigth);

            rmat.RowNames = rowNames;
            Matrix QofU = Matrix.CreateIdentity(row);

            QofU.ColNames = rowNames;
            QofU.RowNames = rowNames;

            var equa = new MatrixEquation(mat, rmat)
            {
                Name = name, QofU = QofU
            };

            DataBind(equa);
        }
Example #4
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);
        }