Ejemplo n.º 1
0
        public static int Test_RationalSquareMatrix()
        {
            RationalFactory rf  = new RationalFactory();
            RealFactory     rff = new RealFactory();

            RationalSquareMatrix A = rf[3, 3,
                                        "1", "2", "-2",
                                        "-1", "1", "3",
                                        "2", "-1", "2"
                                     ];

            SquareRealMatrix SA = rff[3, 3,
                                      7, 2, -2,
                                      3, 1, 3,
                                      8, -1, 2
                                  ];
            RationalVector rv = rf["7", "3", "8"];

            StringBuilder sb = new StringBuilder();//Start building latex

            sb.Append(@"\begin{aligned}");

            sb.AppendFormat(@"&A = {0}", A.ToLatex() + @" \\ \\"); //display A matrix
            A[0] = rv;
            sb.AppendFormat(@"&Ab = {0}", A.ToLatex());            //display Vec A
            sb.AppendFormat(@"&Det = {0}", SA.Determinant());      //display Vec A
            sb.Append(@"\end{aligned}");

            HtmlOutputMethods.WriteLatexEqToHtmlAndLaunch(sb.ToString(), "Test_VecOperator.html"); //display Latex via mathjax

            return(0);
        }
Ejemplo n.º 2
0
        public static int Test_KroneckerSum()
        {
            RealFactory      rf = new RealFactory();
            SquareRealMatrix A  = rf[2, 2,
                                     1, -1,
                                     0, 2
                                  ];

            SquareRealMatrix B = rf[2, 2,
                                    1, 0,
                                    2, -1
                                 ];

            StringBuilder sb = new StringBuilder();//Start building latex

            sb.Append(@"\begin{aligned}");

            sb.AppendFormat(@"&A = {0}\;B = {1}", A.ToLatex(), B.ToLatex() + @" \\ \\");
            sb.AppendFormat(@"&C = A\;\oplus\;B = {0}", SquareRealMatrix.KroneckerSum(A, B).ToLatex());

            sb.Append(@"\end{aligned}");

            HtmlOutputMethods.WriteLatexEqToHtmlAndLaunch(sb.ToString(), "Test_KroneckerSum.html"); //display Latex via mathjax

            return(0);
        }
Ejemplo n.º 3
0
        public static int Test_VecOperator()
        {
            RealFactory rf = new RealFactory(); //create a real factory

            SquareRealMatrix A = rf[2, 2,       //create a 2 X 2 real matrix
                                    1, 2,
                                    3, 4
                                 ];

            RealVector    VecA = A.Vec("A");          //use Vec operator giving the matrix a name
            StringBuilder sb   = new StringBuilder(); //Start building latex

            sb.Append(@"\begin{aligned}");

            sb.AppendFormat(@"&A = {0}", A.ToLatex() + @" \\ \\"); //display A matrix
            sb.AppendFormat(@"&{0}", VecA.ToLatex("F"));           //display Vec A
            sb.Append(@"\end{aligned}");

            HtmlOutputMethods.WriteLatexEqToHtmlAndLaunch(sb.ToString(), "Test_VecOperator.html"); //display Latex via mathjax

            return(0);
        }
Ejemplo n.º 4
0
        public static int Test_TraceFunction()
        {
            RealFactory rf = new RealFactory(); //create a real factory

            SquareRealMatrix A = rf[3, 3,       //create a 3 X 3 real matrix
                                    1, 2, 3,
                                    7, 8, 9,
                                    6, 5, 4
                                 ];

            StringBuilder sb = new StringBuilder();//Start building latex

            sb.Append(@"\begin{aligned}");

            sb.AppendFormat(@"&A = {0}", A.ToLatex() + @" \\ \\");  //display A matrix
            sb.AppendFormat(@"&tr A = {0}", A.Trace() + @" \\ \\"); //display trace
            sb.Append(@"\end{aligned}");

            HtmlOutputMethods.WriteLatexEqToHtmlAndLaunch(sb.ToString(), "Test_TraceFunction.html"); //display Latex via mathjax

            return(0);
        }