Пример #1
0
        public static RationalCoFactorInfo GetCoFactor(RationalSquareMatrix symIn, int Column)
        {
            RationalCoFactorInfo cfi = new RationalCoFactorInfo();

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

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

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

            cfi.Minor           = new RationalSquareMatrix(symIn.Rows - 1, symIn.Columns - 1, symList);
            cfi.Minor.MinorName = symIn.MinorName;
            return(cfi);
        }
Пример #2
0
        public static List <RationalCoFactorInfo> GetAllMatrixCoFactors(RationalSquareMatrix ParentMatrix)
        {
            List <RationalCoFactorInfo> cfList = RationalSquareMatrix.GetCoFactors(ParentMatrix);

            ParentMatrix.MinorName = "M1";
            if (cfList[0].Minor.Rows == 2) //At two go back
            {
                return(cfList);
            }
            int inc = 0;
            RationalCoFactorInfo        cfi         = null;
            RationalCoFactorInfo        cfiChild    = null;
            List <RationalCoFactorInfo> cfListChild = null;
            string TopMinorName = string.Empty;

            while (inc < cfList.Count)
            {
                if (cfi == null)
                {
                    cfi                 = cfList[inc];
                    TopMinorName        = "M" + (inc + 1).ToString();
                    cfi.Minor.MinorName = TopMinorName;
                }
                else if (cfi != null && cfi.ListOfLists.Count == 0) //init value
                {
                    List <RationalCoFactorInfo> cfListTmp = RationalSquareMatrix.GetCoFactors(cfi.Minor);
                    cfi.ListOfLists.Add(cfListTmp);
                    cfListChild = new List <RationalCoFactorInfo>(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 <RationalCoFactorInfo> cfListTmp = null;
                    cfiChild = new RationalCoFactorInfo();
                    foreach (RationalCoFactorInfo cfiC in cfListChild)
                    {
                        cfListTmp = RationalSquareMatrix.GetCoFactors(cfiC.Minor);
                        cfi.ListOfLists.Add(cfListTmp);
                        cfiChild.ListOfLists.Add(cfListTmp);
                    }

                    cfListChild = new List <RationalCoFactorInfo>();
                    foreach (List <RationalCoFactorInfo> cfl in cfiChild.ListOfLists)
                    {
                        foreach (RationalCoFactorInfo 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);
        }