Class BaseAbstractFieldUnivariateIntegrator<T extends CalculusFieldElement<T>>
java.lang.Object
org.hipparchus.analysis.integration.BaseAbstractFieldUnivariateIntegrator<T>
- Type Parameters:
T- Type of the field elements.
- All Implemented Interfaces:
FieldUnivariateIntegrator<T>
- Direct Known Subclasses:
FieldMidPointIntegrator,FieldRombergIntegrator,FieldSimpsonIntegrator,FieldTrapezoidIntegrator,IterativeLegendreFieldGaussIntegrator
public abstract class BaseAbstractFieldUnivariateIntegrator<T extends CalculusFieldElement<T>>
extends Object
implements FieldUnivariateIntegrator<T>
Provide a default implementation for several generic functions.
- Since:
- 2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleDefault absolute accuracy.static final intDefault maximal iteration count.static final intDefault minimal iteration count.static final doubleDefault relative accuracy.protected final IncrementorThe iteration count. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseAbstractFieldUnivariateIntegrator(Field<T> field, double relativeAccuracy, double absoluteAccuracy) Construct an integrator with given accuracies.protectedBaseAbstractFieldUnivariateIntegrator(Field<T> field, double relativeAccuracy, double absoluteAccuracy, int minimalIterationCount, int maximalIterationCount) Construct an integrator with given accuracies and iteration counts.protectedBaseAbstractFieldUnivariateIntegrator(Field<T> field, int minimalIterationCount, int maximalIterationCount) Construct an integrator with given iteration counts. -
Method Summary
Modifier and TypeMethodDescriptionprotected TcomputeObjectiveValue(T point) Compute the objective function value.protected abstract TMethod for implementing actual integration algorithms in derived classes.doubleGet the absolute accuracy.intGet the number of function evaluations of the last run of the integrator.getField()Get the field to which function argument and value belong.intGet the number of iterations of the last run of the integrator.protected TgetMax()Get the upper bound.intGet the upper limit for the number of iterations.protected TgetMin()Get the lower bound.intGet the min limit for the number of iterations.doubleGet the relative accuracy.integrate(int maxEval, CalculusFieldUnivariateFunction<T> f, T lower, T upper) Integrate the function in the given interval.protected voidsetup(int maxEval, CalculusFieldUnivariateFunction<T> f, T lower, T upper) Prepare for computation.
-
Field Details
-
DEFAULT_ABSOLUTE_ACCURACY
public static final double DEFAULT_ABSOLUTE_ACCURACYDefault absolute accuracy.- See Also:
-
DEFAULT_RELATIVE_ACCURACY
public static final double DEFAULT_RELATIVE_ACCURACYDefault relative accuracy.- See Also:
-
DEFAULT_MIN_ITERATIONS_COUNT
public static final int DEFAULT_MIN_ITERATIONS_COUNTDefault minimal iteration count.- See Also:
-
DEFAULT_MAX_ITERATIONS_COUNT
public static final int DEFAULT_MAX_ITERATIONS_COUNTDefault maximal iteration count.- See Also:
-
iterations
The iteration count.
-
-
Constructor Details
-
BaseAbstractFieldUnivariateIntegrator
protected BaseAbstractFieldUnivariateIntegrator(Field<T> field, double relativeAccuracy, double absoluteAccuracy, int minimalIterationCount, int maximalIterationCount) throws MathIllegalArgumentException Construct an integrator with given accuracies and iteration counts.The meanings of the various parameters are:
- relative accuracy:
this is used to stop iterations if the absolute accuracy can't be
achieved due to large values or short mantissa length. If this
should be the primary criterion for convergence rather then a
safety measure, set the absolute accuracy to a ridiculously small value,
like
Precision.SAFE_MIN. - absolute accuracy: The default is usually chosen so that results in the interval -10..-0.1 and +0.1..+10 can be found with a reasonable accuracy. If the expected absolute value of your results is of much smaller magnitude, set this to a smaller value.
- minimum number of iterations: minimal iteration is needed to avoid false early convergence, e.g. the sample points happen to be zeroes of the function. Users can use the default value or choose one that they see as appropriate.
- maximum number of iterations: usually a high iteration count indicates convergence problems. However, the "reasonable value" varies widely for different algorithms. Users are advised to use the default value supplied by the algorithm.
- Parameters:
field- field to which function argument and value belongrelativeAccuracy- relative accuracy of the resultabsoluteAccuracy- absolute accuracy of the resultminimalIterationCount- minimum number of iterationsmaximalIterationCount- maximum number of iterations- Throws:
MathIllegalArgumentException- if minimal number of iterations is not strictly positiveMathIllegalArgumentException- if maximal number of iterations is lesser than or equal to the minimal number of iterations
- relative accuracy:
this is used to stop iterations if the absolute accuracy can't be
achieved due to large values or short mantissa length. If this
should be the primary criterion for convergence rather then a
safety measure, set the absolute accuracy to a ridiculously small value,
like
-
BaseAbstractFieldUnivariateIntegrator
protected BaseAbstractFieldUnivariateIntegrator(Field<T> field, double relativeAccuracy, double absoluteAccuracy) Construct an integrator with given accuracies.- Parameters:
field- field to which function argument and value belongrelativeAccuracy- relative accuracy of the resultabsoluteAccuracy- absolute accuracy of the result
-
BaseAbstractFieldUnivariateIntegrator
protected BaseAbstractFieldUnivariateIntegrator(Field<T> field, int minimalIterationCount, int maximalIterationCount) throws MathIllegalArgumentException Construct an integrator with given iteration counts.- Parameters:
field- field to which function argument and value belongminimalIterationCount- minimum number of iterationsmaximalIterationCount- maximum number of iterations- Throws:
MathIllegalArgumentException- if minimal number of iterations is not strictly positiveMathIllegalArgumentException- if maximal number of iterations is lesser than or equal to the minimal number of iterations
-
-
Method Details
-
getField
Get the field to which function argument and value belong.- Returns:
- field to which function argument and value belong
-
getRelativeAccuracy
public double getRelativeAccuracy()Get the relative accuracy.- Specified by:
getRelativeAccuracyin interfaceFieldUnivariateIntegrator<T extends CalculusFieldElement<T>>- Returns:
- the accuracy
-
getAbsoluteAccuracy
public double getAbsoluteAccuracy()Get the absolute accuracy.- Specified by:
getAbsoluteAccuracyin interfaceFieldUnivariateIntegrator<T extends CalculusFieldElement<T>>- Returns:
- the accuracy
-
getMinimalIterationCount
public int getMinimalIterationCount()Get the min limit for the number of iterations.- Specified by:
getMinimalIterationCountin interfaceFieldUnivariateIntegrator<T extends CalculusFieldElement<T>>- Returns:
- the actual min limit
-
getMaximalIterationCount
public int getMaximalIterationCount()Get the upper limit for the number of iterations.- Specified by:
getMaximalIterationCountin interfaceFieldUnivariateIntegrator<T extends CalculusFieldElement<T>>- Returns:
- the actual upper limit
-
getEvaluations
public int getEvaluations()Get the number of function evaluations of the last run of the integrator.- Specified by:
getEvaluationsin interfaceFieldUnivariateIntegrator<T extends CalculusFieldElement<T>>- Returns:
- number of function evaluations
-
getIterations
public int getIterations()Get the number of iterations of the last run of the integrator.- Specified by:
getIterationsin interfaceFieldUnivariateIntegrator<T extends CalculusFieldElement<T>>- Returns:
- number of iterations
-
getMin
Get the lower bound.- Returns:
- the lower bound.
-
getMax
Get the upper bound.- Returns:
- the upper bound.
-
computeObjectiveValue
Compute the objective function value.- Parameters:
point- Point at which the objective function must be evaluated.- Returns:
- the objective function value at specified point.
- Throws:
MathIllegalStateException- if the maximal number of function evaluations is exceeded.
-
setup
protected void setup(int maxEval, CalculusFieldUnivariateFunction<T> f, T lower, T upper) throws MathIllegalArgumentException, NullArgumentException Prepare for computation. Subclasses must call this method if they override any of thesolvemethods.- Parameters:
maxEval- Maximum number of evaluations.f- the integrand functionlower- the min bound for the intervalupper- the upper bound for the interval- Throws:
NullArgumentException- iffisnull.MathIllegalArgumentException- ifmin >= max.
-
integrate
public T integrate(int maxEval, CalculusFieldUnivariateFunction<T> f, T lower, T upper) throws MathIllegalArgumentException, MathIllegalStateException, NullArgumentException Integrate the function in the given interval.- Specified by:
integratein interfaceFieldUnivariateIntegrator<T extends CalculusFieldElement<T>>- Parameters:
maxEval- Maximum number of evaluations.f- the integrand functionlower- the lower bound for the intervalupper- the upper bound for the interval- Returns:
- the value of integral
- Throws:
MathIllegalArgumentException- ifmin > maxor the endpoints do not satisfy the requirements specified by the integratorMathIllegalStateException- if the maximum number of function evaluations is exceededMathIllegalStateException- if the maximum iteration count is exceeded or the integrator detects convergence problems otherwiseNullArgumentException- iffisnull.
-
doIntegrate
Method for implementing actual integration algorithms in derived classes.- Returns:
- the root.
- Throws:
MathIllegalStateException- if the maximal number of evaluations is exceeded.MathIllegalStateException- if the maximum iteration count is exceeded or the integrator detects convergence problems otherwise
-