示例#1
0
        public void Factorize(CoordinationalMatrix M)
        {
            FA = (CoordinationalMatrix)M.Clone();
            var rows = FA.GetMatrixRows();

            if (Math.Abs(FA[0, 0]) < 1.0E-14)
            {
                return;
            }

            foreach (var i in rows)
            {
                double sumD   = 0;
                var    cols_i = FA.GetMatrixColumnsForRow(i);
                foreach (var j in cols_i)
                {
                    if (j >= i)
                    {
                        break;
                    }
                    double sumL = 0, sumU = 0;
                    foreach (var k in cols_i)
                    {
                        if (k > j - 1)
                        {
                            break;
                        }

                        sumL += FA[i, k] * FA[k, j];
                    }
                    FA.Set(i, j, (M[i, j] - sumL) / FA[j, j]);
                    foreach (var k in FA.GetMatrixRowsForColumn(j))
                    {
                        if (k > j - 1)
                        {
                            break;
                        }
                        sumU += FA[k, i] * FA[j, k];
                    }

                    FA.Set(j, i, (M[j, i] - sumU));
                    sumD += FA[i, j] * FA[j, i];
                }
                FA.Set(i, i, M[i, i] - sumD);
            }
        }