コード例 #1
0
        public static int Test_RationalSymbolMatrixOperations()
        {
            SymbolFactory sf = new SymbolFactory(SymbolType.Rational);

            SymbolMatrix A1 = sf[2, 2, //create a 2 X 2 symbol matrix with rationals
                                 "1/2", "1/5",
                                 "2/3", "7/8"
                              ];


            SymbolMatrix A2 = sf[2, 2, //create a 2 X 2 symbol with rationals
                                 "1/4", "7/9",
                                 "3/10", "4/7"
                              ];

            SymbolMatrix  symMul = A1 * A2;             //multiply the matrices
            StringBuilder sb     = new StringBuilder(); //Start building latex

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

            sb.AppendFormat(@"&{0}", (A1 * A2).ToLatex("F") + @" \\ \\");
            sb.AppendFormat(@"&{0}", (A1 + A2).ToLatex("F") + @" \\ \\");
            sb.AppendFormat(@"&{0}", (A1 - A2).ToLatex("F"));

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

            HtmlOutputMethods.WriteLatexEqToHtmlAndLaunch(sb.ToString(), "Test_RationalSymbolMatrixOperations.html"); //display Latex via mathjax
            return(0);
        }
コード例 #2
0
        public Symbol(string exp)
        {
            TokenFactory tokes = new TokenFactory();

            Expression = exp;
            tokes.ParseExpression(exp);
            Tokens     = tokes.TokenList;
            symbolType = SymbolType.Expression;
            Discover();
            IsOperator   = false;
            IsExpression = false;

            if (Parent == null)
            {
                Parent = new SymbolFactory(SymbolType.Expression);
            }
        }
コード例 #3
0
        public static int Test_ParseSymbols()
        {
            TokenFactory tokes = new TokenFactory();

            //TokenFactory tokes = new TokenFactory();
            tokes.Variables.Add("x");

            SymbolFactory sf = new SymbolFactory(SymbolType.Expression, tokes);

            Symbol sym = sf["e(xy^2)"];

            Console.WriteLine(sym.Expression);
            Console.WriteLine(sym.HashTokenString);
            //Console.WriteLine(ArithmeticStatePattern.Add(sym));

            //Console.WriteLine(DerivativeStatePattern.DF(sym));

            /*
             * tokes.ParseExpression("2xsin(2x)");
             * int cnt = 0;
             * int j = 0;
             * for (j = 0; j < tokes.TokenList.Count; j++)
             * {
             *  Token t = tokes.TokenList[j];
             *  Console.WriteLine("{0}. Type = {1}, value = {2}, symbol end {3}", cnt++, t.Type, t.Value, t.SymbolEnd);
             *
             * }
             *
             *
             * Symbol sym = tokes.DF(tokes.symbolList[0]);
             *
             * for (j = 0; j < sym.Tokens.Count; j++)
             * {
             *  Token t = sym.Tokens[j];
             *  Console.WriteLine("{0}. Type = {1}, value = {2}, symbol end {3}", cnt++, t.Type, t.Value, t.SymbolEnd);
             *
             * }
             *
             */


            return(0);
        }