Beispiel #1
0
        public static CoFactorInfo GetCoFactor(SymbolMatrix symIn, int Column)
        {
            CoFactorInfo cfi = new CoFactorInfo();

            cfi.Sign = (int)Math.Pow(-1, Column + 1);
            SymbolVector col = symIn[Column - 1];

            cfi.CoFactor = col[0];
            List <Symbol> symList = new List <Symbol>();

            for (int rowCount = 1; rowCount < symIn.Rows; rowCount++)
            {
                for (int colCount = 0; colCount < symIn.Columns; colCount++)
                {
                    if (colCount + 1 != Column)
                    {
                        symList.Add(symIn[rowCount, colCount]);
                    }
                }
            }

            cfi.Minor = new SymbolMatrix(symIn.Rows - 1, symIn.Columns - 1, symList);
            return(cfi);
        }
Beispiel #2
0
        public static List <CoFactorInfo> GetAllMatrixCoFactors(SymbolMatrix ParentMatrix)
        {
            List <CoFactorInfo> cfList = SymbolMatrix.GetCoFactors(ParentMatrix);

            if (cfList[0].Minor.Rows == 2) //At two go back
            {
                return(cfList);
            }
            int                 inc         = 0;
            CoFactorInfo        cfi         = null;
            CoFactorInfo        cfiChild    = null;
            List <CoFactorInfo> cfListChild = null;

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

                    cfListChild = new List <CoFactorInfo>();
                    foreach (List <CoFactorInfo> cfl in cfiChild.ListOfLists)
                    {
                        foreach (CoFactorInfo cfiC in cfl)
                        {
                            cfListChild.Add(cfiC);
                        }
                    }

                    cfiChild = null;

                    if (cfListChild[0].Minor.Rows == 2) //end of line
                    {
                        cfList[inc] = cfi;
                        cfi         = null;
                        inc++;
                    }
                }
            }

            return(cfList);
        }