Esempio n. 1
0
        public static SymbolMatrix C3()
        {
            List <string> kgL = new List <string>
            {
                "a", "b", "c",
                "c", "a", "b",
                "b", "c", "a"
            };

            SymbolMatrix retVal = new SymbolMatrix(3, 3);
            int          cnt    = 0;

            for (int rows = 0; rows < retVal.Rows; rows++)
            {
                for (int cols = 0; cols < retVal.Columns; cols++)
                {
                    Symbol sym = new Symbol(kgL[cnt++]);
                    sym.IsExpression   = true;
                    retVal[rows, cols] = sym;
                }
            }

            retVal.FullRep = @"C_3 = " + retVal.ToLatex();
            return(retVal);
        }
Esempio n. 2
0
        public static SymbolMatrix C3(List <string> variables)
        {
            List <string> kgL = new List <string>
            {
                "a", "b", "c",
                "c", "a", "b",
                "b", "c", "a"
            };

            List <string> mapper = kgL.Take(3).ToList();

            SymbolMatrix retVal = new SymbolMatrix(3, 3);
            int          cnt    = 0;

            for (int rowCount = 0; rowCount < retVal.Rows; rowCount++)
            {
                for (int colCount = 0; colCount < retVal.Columns; colCount++)
                {
                    int ind = mapper.FindIndex(t => t == kgL[cnt]);

                    Symbol sym = new Symbol(variables[ind]);
                    cnt++;
                    sym.IsExpression           = true;
                    retVal[rowCount, colCount] = sym;
                }
            }

            retVal.FullRep = @"C_3 = " + retVal.ToLatex();
            return(retVal);
        }
Esempio n. 3
0
        public static SymbolMatrix RightChiralQuaternion()
        {
            List <string> kgL = new List <string>
            {
                "a", "b", "c", "d",
                "-b", "a", "d", "-c",
                "-c", "-d", "a", "b",
                "-d", "c", "-b", "a"
            };

            SymbolMatrix retval = new SymbolMatrix(4, 4);

            int cnt = 0;

            for (int rowCount = 0; rowCount < retval.Rows; rowCount++)
            {
                for (int colCount = 0; colCount < retval.Columns; colCount++)
                {
                    Symbol sym = new Symbol(kgL[cnt++]);
                    sym.IsExpression           = true;
                    retval[rowCount, colCount] = sym;
                }
            }

            retval.FullRep = @"\mathbb{H}_{R\chi} = " + retval.ToLatex();
            return(retval);
        }
Esempio n. 4
0
        public static SymbolMatrix C4RowColumn()
        {
            List <string> kgL = new List <string>
            {
                "a", "b", "c", "d",
                "e", "f", "g", "h",
                "i", "j", "k", "l",
                "m", "n", "o", "p",
            };

            SymbolMatrix retVal = new SymbolMatrix(4, 4);
            int          cnt    = 0;

            for (int rowCount = 0; rowCount < retVal.Rows; rowCount++)
            {
                for (int colCount = 0; colCount < retVal.Columns; colCount++)
                {
                    Symbol sym = new Symbol(kgL[cnt++]);
                    sym.IsExpression           = true;
                    retVal[rowCount, colCount] = sym;
                }
            }

            retVal.FullRep = @"C_4 = " + retVal.ToLatex();
            return(retVal);
        }
Esempio n. 5
0
        public static SymbolMatrix KleinGroup()
        {
            List <string> kgL = new List <string>
            {
                "a", "b", "c", "d",
                "b", "a", "d", "c",
                "c", "d", "a", "b",
                "d", "c", "b", "a"
            };

            SymbolMatrix retVal = new SymbolMatrix(4, 4);

            int cnt = 0;

            for (int rowCount = 0; rowCount < retVal.Rows; rowCount++)
            {
                for (int colCount = 0; colCount < retVal.Columns; colCount++)
                {
                    Symbol sym = new Symbol(kgL[cnt++]);
                    sym.IsExpression           = true;
                    retVal[rowCount, colCount] = sym;
                }
            }

            retVal.FullRep = @"C_2\;\times\;C_2 = " + retVal.ToLatex();
            return(retVal);
        }
Esempio n. 6
0
        public static SymbolMatrix operator /(SymbolMatrix a, SymbolMatrix b)
        {
            SymbolMatrix retVal = new SymbolMatrix(a.Rows, a.Columns);

            for (int rowCount = 0; rowCount < retVal.Rows; rowCount++)
            {
                for (int colCount = 0; colCount < retVal.Columns; colCount++)
                {
                    for (int retColCount = 0; retColCount < retVal.Columns; retColCount++)
                    {
                        retVal.InternalRep[rowCount, colCount] += a.InternalRep[rowCount, retColCount] / b.InternalRep[retColCount, colCount];
                    }
                }
            }

            StringBuilder sb = new StringBuilder();

            sb.Append(a.ToLatex());
            sb.Append(b.ToLatex());
            sb.Append(" = ");
            sb.Append(retVal.ToLatex());

            retVal.FullRep = sb.ToString();
            return(retVal);
        }
Esempio n. 7
0
        /***************************Operators**********************************/

        private static SymbolMatrix MultiplyRational(SymbolMatrix a, SymbolMatrix b)
        {
            SymbolMatrix retVal = new SymbolMatrix(a.Rows, a.Columns);

            retVal.SymbolMatrixSymbolType = SymbolType.Rational;

            for (int rowCount = 0; rowCount < retVal.Rows; rowCount++)
            {
                for (int colCount = 0; colCount < retVal.Columns; colCount++)
                {
                    for (int retColCount = 0; retColCount < retVal.Columns; retColCount++)
                    {
                        Rational inter = Rational.Parse(retVal.InternalRep[rowCount, colCount].Expression);
                        inter += Rational.Parse(a.InternalRep[rowCount, retColCount].Expression) * Rational.Parse(b.InternalRep[retColCount, colCount].Expression);
                        Symbol sym = new Symbol(inter.ToString());
                        sym.LatexString = inter.ToLatex();
                        retVal.InternalRep[rowCount, colCount] = sym;
                    }
                }
            }

            StringBuilder sb = new StringBuilder();

            sb.Append(a.ToLatex());
            sb.Append(b.ToLatex());
            sb.Append(" = ");
            sb.Append(retVal.ToLatex());

            retVal.FullRep = sb.ToString();

            return(retVal);
        }
        public static int Test_D3()
        {
            SymbolMatrix  D3 = SymbolMatrixUtilities.D3();
            StringBuilder sb = new StringBuilder();//Start building latex

            sb.AppendFormat(@"{0}", D3.ToLatex());

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

            return(0);
        }
        public static int Test_Flip()
        {
            SymbolMatrix C3Flip = SymbolMatrixUtilities.C3().Flip().ReName(new List <string> {
                "d", "e", "f"
            });
            StringBuilder sb = new StringBuilder();//Start building latex

            sb.Append(@"\begin{aligned}");
            sb.AppendFormat(@"&{0} \\ \\", SymbolMatrixUtilities.C3().ToLatex());
            sb.AppendFormat(@"&{0}", C3Flip.ToLatex());
            sb.Append(@"\end{aligned}");

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

            return(0);
        }
        public static int Test_Symbol_Groups()
        {
            SymbolMatrix smK  = SymbolMatrixUtilities.KleinGroup(); //Get kleingroup cayle table
            SymbolMatrix smQL = SymbolMatrixUtilities.LeftChiralQuaternion();
            SymbolMatrix smQR = SymbolMatrixUtilities.RightChiralQuaternion();

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

            sb.Append(@"\begin{aligned}");
            sb.AppendFormat(@"&{0} \\ \\", smK.ToLatex("F"));
            sb.AppendFormat(@"&{0} \\ \\", smQL.ToLatex("F"));
            sb.AppendFormat(@"&{0}", smQR.ToLatex("F"));
            sb.Append(@"\end{aligned}");

            HtmlOutputMethods.WriteLatexEqToHtmlAndLaunch(sb.ToString(), "Test_KleinGroup.html"); //display Latex via mathjax
            return(0);
        }
Esempio n. 11
0
        public static SymbolMatrix KroneckerProduct(SymbolMatrix a, SymbolMatrix b)
        {
            int          Rows    = a.Rows * b.Rows;    // calculate number of rows.
            int          Columns = a.Columns * b.Rows; // calculate number of columns
            int          incC    = 0;                  // increment variable for column of b matrix
            int          incR    = 0;                  // increment variable for row of b matrix
            int          incAMC  = 0;                  // increment variable for column of a matrix
            int          incAMR  = 0;                  // increment variable for row of a matrix
            SymbolMatrix retVal  = new SymbolMatrix(Rows, Columns);
            int          rowCount;
            int          colCount;
            string       exp = string.Empty;

            for (rowCount = 0; rowCount < retVal.Rows; rowCount++)
            {
                if (incR > b.Rows - 1)           // reached end of rows of b matrix
                {
                    incR = 0;
                    incAMR++;
                }
                incAMC = 0;
                for (colCount = 0; colCount < retVal.Columns; colCount++)
                {
                    exp = a[incAMR, incAMC].Expression + b[incR, incC].Expression;
                    incC++;
                    if (incC > b.Columns - 1)    // reached end of columns of b matrix
                    {
                        incC = 0;
                        incAMC++;
                    }

                    retVal[rowCount, colCount] = new Symbol(exp);
                }
                incR++;
            }

            retVal.FullRep = a.ToLatex() + @"\;\otimes\;" + b.ToLatex() + " = " + retVal.ToLatex(); //produce latex string
            return(retVal);
        }
        public static int Test_MultiplyRationalSymbolMatrix()
        {
            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.AppendFormat(@"{0}", symMul.ToLatex("F"));

            HtmlOutputMethods.WriteLatexEqToHtmlAndLaunch(sb.ToString(), "Test_Multiply_Rational_Symbol_Matrix.html"); //display Latex via mathjax
            return(0);
        }
        public static int Test_Symbol_Determinant()
        {
            //SymbolMatrix C3 = SymbolMatrixUtilities.C3RowColumn();
            //Symbol det = C3.Determinant();
            //Symbol det = SymbolMatrixUtilities.C4RowColumn().Determinant();
            //SymbolMatrix smK = SymbolMatrixUtilities.KleinGroup(); //Get kleingroup cayle table
            //Symbol det = smK.Determinant();


            SymbolMatrix        smK    = SymbolMatrixUtilities.C3RowColumn();
            List <CoFactorInfo> cfList = SymbolMatrix.GetAllMatrixCoFactors(smK);
            StringBuilder       sb     = new StringBuilder();//Start building latex

            sb.Append(@"\begin{aligned}");
            sb.AppendFormat(@"&{0} \\ \\", smK.ToLatex());

            /*
             * int inc = 0;
             * CoFactorInfo cfi = null;
             *
             * while(inc < cfList.Count)
             * {
             *  if(cfi == null)
             *  {
             *      cfi = cfList[inc];
             *  }
             *  else if(cfi != null && cfi.ListOfLists.Count == 0) //init value
             *  {
             *      List<CoFactorInfo> cfListChild = SymbolMatrix.GetCoFactors(cfi.Minor);
             *      cfi.ListOfLists.Add(cfListChild);
             *
             *      if(cfListChild[0].Minor.Rows == 2) //end of line
             *      {
             *          cfList[inc] = cfi;
             *          cfi = null;
             *          inc++;
             *      }
             *  }
             *  else if(cfi != null && cfi.ListOfLists.Count > 0) //have values
             *  {
             *      List<CoFactorInfo> cfListChild = SymbolMatrix.GetCoFactors(cfi.Minor);
             *      cfi.ListOfLists.Add(cfListChild);
             *
             *      if(cfListChild[0].Minor.Rows == 2) //end of line
             *      {
             *          cfList[inc] = cfi;
             *          cfi = null;
             *          inc++;
             *      }
             *
             *  }
             * }
             *
             */


            foreach (CoFactorInfo ci in cfList)
            {
                sb.AppendFormat(@"&{0} \\ \\", ci.CoFactor.Tokens[0].Value + ci.Minor.ToLatex());

                /*
                 * if (ci.Minor.Rows > 2)
                 * {
                 *  List<CoFactorInfo> cfList2 = SymbolMatrix.GetCoFactors(ci.Minor);
                 *
                 *  foreach (CoFactorInfo ci2 in cfList2)
                 *  {
                 *      sb.AppendFormat(@"&{0} \\ \\", ci.CoFactor.Tokens[0].Value + ci2.CoFactor.Tokens[0].Value + ci2.Minor.ToLatex());
                 *  }
                 * }
                 */

                foreach (List <CoFactorInfo> lstChild in ci.ListOfLists)
                {
                    foreach (CoFactorInfo ci2 in lstChild)
                    {
                        //if (ci2.Minor.Rows == 4)
                        {
                            sb.AppendFormat(@"&{0} \\ \\", ci.CoFactor.Tokens[0].Value + ci2.CoFactor.Tokens[0].Value + ci2.Minor.ToLatex());

                            /*
                             * string det = string.Format("({0} - {1})",
                             * ci2.Minor[0, 0].Tokens[0]. Value + ci2.Minor[1, 1].Tokens[0]. Value,
                             * ci2.Minor[1, 0].Tokens[0]. Value + ci2.Minor[0, 1].Tokens[0]. Value);
                             *
                             * sb.AppendFormat(@"&{0} \\ \\", ci.CoFactor.Tokens[0].Value + ci2.CoFactor.Tokens[0].Value + det);
                             */
                        }
                    }
                }
            }
            sb.Append(@"\end{aligned}");

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


            return(0);
        }