Ejemplo n.º 1
0
 private void ClearExtrapolation()
 {
     for (int i = 0; i < extrapolators.Length; i++)
     {
         extrapolators[i].Clear();
     }
     errorExtrapolator.Clear();
 }
Ejemplo n.º 2
0
 public virtual void Clear()
 {
     extrapolator.Clear();
 }
Ejemplo n.º 3
0
 public void Clear()
 {
     yExtrapolator.Clear();
     ypExtrapolator.Clear();
 }
Ejemplo n.º 4
0
        public override void Step()
        {
            yExtrapolator.Clear();
            ypExtrapolator.Clear();

            int work = 1;

            double bestEfficiency = 0.0;
            double bestFactor     = 1.0;
            int    bestK          = -1;

            for (int k = 0; k < N.Length; k++)
            {
                double y1, yp1;
                TrialStep(N[k], out y1, out yp1);
                yExtrapolator.Add(MoreMath.Sqr(1.0 / N[k]), y1);
                ypExtrapolator.Add(MoreMath.Sqr(1.0 / N[k]), yp1);

                work += N[k];

                if (k < 1)
                {
                    continue;
                }

                UncertainValue yEstimate = yExtrapolator.Estimate;

                double error = yEstimate.Uncertainty;

                double tol = Settings.ComputePrecision(yEstimate.Value);

                double factor = Math.Pow(tol / error, 1.0 / (2 * k + 1));

                double efficiency = factor / work;

                if (((k + 1) < N.Length) && (efficiency > bestEfficiency))
                {
                    bestEfficiency = efficiency;
                    bestFactor     = factor;
                    bestK          = k;
                }


                if (error <= tol)
                {
                    X          += DeltaX;
                    Y           = yEstimate.Value;
                    YPrime      = ypExtrapolator.Estimate.Value;
                    YPrimePrime = Evaluate(X, Y);

                    if ((k + 2) < N.Length)
                    {
                        double extrapolatedError      = MoreMath.Sqr(1.0 * N[0] / N[k + 1]) * error;
                        int    extrapolatedWork       = work + N[k + 1];
                        double extrapolatedFactor     = Math.Pow(tol / extrapolatedError, 1.0 / (2 * k + 3));
                        double extrapolatedEfficiency = extrapolatedFactor / extrapolatedWork;

                        if (extrapolatedEfficiency > bestEfficiency)
                        {
                            bestEfficiency = extrapolatedEfficiency;
                            bestFactor     = extrapolatedFactor;
                            bestK          = k + 1;
                        }
                    }

                    break;
                }
            }

            if (bestFactor < 0.2)
            {
                bestFactor = 0.2;
            }
            if (bestFactor > 5.0)
            {
                bestFactor = 5.0;
            }
            DeltaX *= 0.9375 * bestFactor;
        }