//From now on, our comments will use latex syntax
        public static int Test_ElementaryMatrix_Multiply_ElementaryMatrix()
        {
            /*
             *  E_{ij}E_{rs} = e_ie'_je_re'_s = \delta_{r j}e'_ie'_s = \delta_{j r}E_{is} \\
             *  if\;r = j \\
             *  E_{ij}E_{rs} = \delta_{j j}E_{is} = E_{is}
             *
             */
            StringBuilder    sb  = new StringBuilder();
            ElementaryMatrix E12 = new ElementaryMatrix(4, 4, "E13"); // 4 x 4 ElementaryMatrix
            ElementaryMatrix E13 = new ElementaryMatrix(4, 4, "E32"); // 4 x 4 ElementaryMatrix

            sb.Append(@"E_{ij}E_{rs} = e_ie'_je_re'_s = \delta_{r j}e'_ie'_s = \delta_{j r}E_{is} \\");
            sb.Append(@"if\;r = j \\");
            sb.Append(@"E_{ij}E_{rs} = \delta_{j j}E_{is} = E_{is} \\");
            sb.Append(@"Output\;is: \\");
            //Test Elementary Matrix * Elementary Matrix

            ElementaryMatrix em = E12 * E13;

            sb.Append(em.ToLatex("F"));

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

            return(0);
        }
        public static int Test_ElementaryMatrix_ElementaryMatrix()
        {
            ElementaryMatrix em = new ElementaryMatrix(4, 4, "E11");

            HtmlOutputMethods.WriteLatexEqToHtmlAndLaunch(em.ToLatex("F"), "Test_ElementaryMatrix_ElementaryMatrix.html");

            return(0);
        }
        public static int Test_UnitVectorProductTo_ElementaryMatrix()
        {
            UnitVectorSpace  uvs = new UnitVectorSpace(4);                                                                    //Order four Unit Vector Space
            UnitVector       e2  = uvs["e2"];                                                                                 // order 4 e2 unit vector
            UnitVector       e1  = uvs["e1"];                                                                                 //order 4 e1 unit operator
            ElementaryMatrix em  = e2 * e1;                                                                                   //product of Unit Vectors

            HtmlOutputMethods.WriteLatexEqToHtmlAndLaunch(em.ToLatex("F"), "Test_UnitVectorProductTo_ElementaryMatrix.html"); //display Latex via mathjax

            return(0);
        }
        public static ElementaryMatrix operator *(ElementaryMatrix a, ElementaryMatrix b)
        {
            ElementaryMatrix retVal = new ElementaryMatrix(a.Rows, a.Columns);

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

                        if (retVal.InternalRep[rowCount, colCount] == 1)
                        {
                            retVal.Major       = rowCount + 1;
                            retVal.Minor       = colCount + 1;
                            retVal.Name        = $"E{retVal.Major.ToString()}{retVal.Minor.ToString()}";
                            retVal.m_LatexName = $"E_{{{(retVal.Major).ToString() + (retVal.Minor).ToString()}}}";
                        }
                    }
                }
            }

            StringBuilder sb = new StringBuilder();

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

            retVal.FullRep = sb.ToString();

            return(retVal);
        }
Beispiel #5
0
        /*TODO: remove this GPG
         * public static UnitVector operator*(ElementaryMatrix em, UnitVector uv)
         * {
         *  UnitVector uvOut = null;
         *  //using following realtionships
         *  //Eij * er = ei * e'j * er
         *  // = &jr * ei where & is the Kronecker Delta
         *  UnitVectorSpace uvp = new UnitVectorSpace(uv.Order);
         *  UnitVector ei = uvp["e" + em.Major.ToString()];
         *  UnitVector ej = uvp["e" + em.Minor.ToString()];
         *  RowColumn rc = ej.IsRowOrColumn;
         *  ej.IsRowOrColumn = RowColumn.Row;
         *
         *  uvOut = ei * ej * uv;
         *  ej.IsRowOrColumn = rc; //Set it back to what it was
         *  return uvOut;
         * }
         */

        public static ElementaryMatrix operator*(UnitVector e1, UnitVector e2)
        {
            ElementaryMatrix em = null;
            RowColumn        rc = e2.IsRowOrColumn;


            if (e1.IsRowOrColumn == RowColumn.Row) //Dot product
            {
                return((ElementaryMatrix)DotProduct(e1, e2));
            }


            e2.IsRowOrColumn = RowColumn.Row; //transpose

            string emName = "E" + e1.Name[1].ToString() + e2.Name[1].ToString();

            em         = new ElementaryMatrix(e1.Order, e2.Order, emName);
            em.FullRep = em.LatexName + " = " + e1.ToLatex() + e2.ToLatex() + " = " + em.ToLatex();

            e2.IsRowOrColumn = rc; //set back to what it was
            return(em);
        }