コード例 #1
0
ファイル: RombergIntegrator.cs プロジェクト: 15831944/Essence
        /// <summary>
        /// {@inheritDoc} </summary>
        protected internal override double DoIntegrate()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int m = getMaximalIterationCount() + 1;
            int m = GetMaximalIterationCount() + 1;

            double[] previousRow = new double[m];
            double[] currentRow  = new double[m];

            TrapezoidIntegrator qtrap = new TrapezoidIntegrator();

            currentRow[0] = qtrap.Stage(this, 0);
            IncrementCount();
            double olds = currentRow[0];

            while (true)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int i = getIterations();
                int i = GetIterations();

                // switch rows
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double[] tmpRow = previousRow;
                double[] tmpRow = previousRow;
                previousRow = currentRow;
                currentRow  = tmpRow;

                currentRow[0] = qtrap.Stage(this, i);
                IncrementCount();
                for (int j = 1; j <= i; j++)
                {
                    // Richardson extrapolation coefficient
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double r = (1L << (2 * j)) - 1;
                    double r = (1L << (2 * j)) - 1;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double tIJm1 = currentRow[j - 1];
                    double tIJm1 = currentRow[j - 1];
                    currentRow[j] = tIJm1 + (tIJm1 - previousRow[j - 1]) / r;
                }
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double s = currentRow[i];
                double s = currentRow[i];
                if (i >= GetMinimalIterationCount())
                {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double delta = org.apache.commons.math3.util.FastMath.abs(s - olds);
                    double delta = FastMath.Abs(s - olds);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double rLimit = getRelativeAccuracy() * (org.apache.commons.math3.util.FastMath.abs(olds) + org.apache.commons.math3.util.FastMath.abs(s)) * 0.5;
                    double rLimit = GetRelativeAccuracy() * (FastMath.Abs(olds) + FastMath.Abs(s)) * 0.5;
                    if ((delta <= rLimit) || (delta <= GetAbsoluteAccuracy()))
                    {
                        return(s);
                    }
                }
                olds = s;
            }
        }
コード例 #2
0
        /// <summary>
        /// {@inheritDoc} </summary>
        protected internal override double DoIntegrate()
        {
            TrapezoidIntegrator qtrap = new TrapezoidIntegrator();

            if (this.MinimalIterationCount == 1)
            {
                return((4 * qtrap.Stage(this, 1) - qtrap.Stage(this, 0)) / 3.0);
            }

            // Simpson's rule requires at least two trapezoid stages.
            double olds = 0;
            double oldt = qtrap.Stage(this, 0);

            while (true)
            {
                double t = qtrap.Stage(this, this.iterations.Count);
                this.iterations.IncrementCount();
                double s = (4 * t - oldt) / 3.0;
                if (this.iterations.Count >= this.MinimalIterationCount)
                {
                    double delta  = FastMath.Abs(s - olds);
                    double rLimit = this.RelativeAccuracy * (FastMath.Abs(olds) + FastMath.Abs(s)) * 0.5;
                    if ((delta <= rLimit) || (delta <= this.AbsoluteAccuracy))
                    {
                        return(s);
                    }
                }
                olds = s;
                oldt = t;
            }
        }
コード例 #3
0
ファイル: RombergIntegrator.cs プロジェクト: 15831944/Essence
        /// <summary>
        /// {@inheritDoc} </summary>
        protected internal override double DoIntegrate()
        {
            int m = this.iterations.MaximalCount + 1;

            double[] previousRow = new double[m];
            double[] currentRow  = new double[m];

            TrapezoidIntegrator qtrap = new TrapezoidIntegrator();

            currentRow[0] = qtrap.Stage(this, 0);
            this.iterations.IncrementCount();
            double olds = currentRow[0];

            while (true)
            {
                int i = this.iterations.Count;

                // switch rows
                double[] tmpRow = previousRow;
                previousRow = currentRow;
                currentRow  = tmpRow;

                currentRow[0] = qtrap.Stage(this, i);
                this.iterations.IncrementCount();
                for (int j = 1; j <= i; j++)
                {
                    // Richardson extrapolation coefficient
                    double r     = (1L << (2 * j)) - 1;
                    double tIJm1 = currentRow[j - 1];
                    currentRow[j] = tIJm1 + (tIJm1 - previousRow[j - 1]) / r;
                }
                double s = currentRow[i];
                if (i >= this.MinimalIterationCount)
                {
                    double delta  = FastMath.Abs(s - olds);
                    double rLimit = this.RelativeAccuracy * (FastMath.Abs(olds) + FastMath.Abs(s)) * 0.5;
                    if ((delta <= rLimit) || (delta <= this.AbsoluteAccuracy))
                    {
                        return(s);
                    }
                }
                olds = s;
            }
        }
コード例 #4
0
        /// <summary>
        /// {@inheritDoc} </summary>
        protected internal override double DoIntegrate()
        {
            TrapezoidIntegrator qtrap = new TrapezoidIntegrator();

            if (GetMinimalIterationCount() == 1)
            {
                return((4 * qtrap.Stage(this, 1) - qtrap.Stage(this, 0)) / 3.0);
            }

            // Simpson's rule requires at least two trapezoid stages.
            double olds = 0;
            double oldt = qtrap.Stage(this, 0);

            while (true)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double t = qtrap.stage(this, getIterations());
                double t = qtrap.Stage(this, GetIterations());
                IncrementCount();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double s = (4 * t - oldt) / 3.0;
                double s = (4 * t - oldt) / 3.0;
                if (GetIterations() >= GetMinimalIterationCount())
                {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double delta = org.apache.commons.math3.util.FastMath.abs(s - olds);
                    double delta = FastMath.Abs(s - olds);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double rLimit = getRelativeAccuracy() * (org.apache.commons.math3.util.FastMath.abs(olds) + org.apache.commons.math3.util.FastMath.abs(s)) * 0.5;
                    double rLimit = GetRelativeAccuracy() * (FastMath.Abs(olds) + FastMath.Abs(s)) * 0.5;
                    if ((delta <= rLimit) || (delta <= GetAbsoluteAccuracy()))
                    {
                        return(s);
                    }
                }
                olds = s;
                oldt = t;
            }
        }