示例#1
0
        public void Recalculate(List <double> initXs, List <double> initYs, int exp)
        {
            var a = new double[exp, exp];
            var b = new double[exp];

            this.exp = exp;

            for (var j = 0; j < exp; j++)
            {
                var f = 0.0;
                for (var i = 0; i < initXs.Count; i++)
                {
                    f += initYs[i] * Math.Pow(initXs[i], j);
                }
                b[j] = f;
                for (var k = 0; k < exp; k++)
                {
                    var c = 0.0;
                    for (var i = 0; i < initXs.Count; i++)
                    {
                        c += Math.Pow(initXs[i], k + j);
                    }
                    a[j, k] = c;
                }
            }

            eq = new LinearEquation(a, b);
            eq.Gauss();
        }
示例#2
0
        public ConditionFinder(double[,] a, double[] b)
        {
            equation = new LinearEquation(a, b);
            equation.Gauss();

            var bWithDelta = (double[])b.Clone();

            SetDelta(bWithDelta);

            equationWithDelta = new LinearEquation(a, bWithDelta);
            equationWithDelta.Gauss();

            Condition = (VectorNorm(equationWithDelta.x) / VectorNorm(equation.x) * VectorNorm(b) / VectorNorm(bWithDelta));
        }