org.apache.commons.math.analysis
Class UnivariateRealIntegratorImpl

java.lang.Object
  extended by org.apache.commons.math.analysis.UnivariateRealIntegratorImpl
All Implemented Interfaces:
java.io.Serializable, UnivariateRealIntegrator
Direct Known Subclasses:
RombergIntegrator, SimpsonIntegrator, TrapezoidIntegrator

public abstract class UnivariateRealIntegratorImpl
extends java.lang.Object
implements UnivariateRealIntegrator, java.io.Serializable

Provide a default implementation for several generic functions.

Since:
1.2
Version:
$Revision: 620312 $ $Date: 2008-02-10 12:28:59 -0700 (Sun, 10 Feb 2008) $
See Also:
Serialized Form

Field Summary
protected  int defaultMaximalIterationCount
          default maximum number of iterations
protected  int defaultMinimalIterationCount
          default minimum number of iterations
protected  double defaultRelativeAccuracy
          default maximum relative error
protected  UnivariateRealFunction f
          the integrand function
protected  int iterationCount
          the last iteration count
protected  int maximalIterationCount
          maximum number of iterations
protected  int minimalIterationCount
          minimum number of iterations
protected  double relativeAccuracy
          maximum relative error
protected  double result
          the last computed integral
protected  boolean resultComputed
          indicates whether an integral has been computed
(package private) static long serialVersionUID
          serializable version identifier
 
Constructor Summary
protected UnivariateRealIntegratorImpl(UnivariateRealFunction f, int defaultMaximalIterationCount)
          Construct an integrator with given iteration count and accuracy.
 
Method Summary
protected  void clearResult()
          Convenience function for implementations.
 int getIterationCount()
          Access the last iteration count.
 int getMaximalIterationCount()
          Get the upper limit for the number of iterations.
 int getMinimalIterationCount()
          Get the lower limit for the number of iterations.
 double getRelativeAccuracy()
          Get the actual relative accuracy.
 double getResult()
          Access the last computed integral.
protected  boolean isSequence(double start, double mid, double end)
          Returns true if the arguments form a (strictly) increasing sequence
 void resetMaximalIterationCount()
          Reset the upper limit for the number of iterations to the default.
 void resetMinimalIterationCount()
          Reset the lower limit for the number of iterations to the default.
 void resetRelativeAccuracy()
          Reset the relative accuracy to the default.
 void setMaximalIterationCount(int count)
          Set the upper limit for the number of iterations.
 void setMinimalIterationCount(int count)
          Set the lower limit for the number of iterations.
 void setRelativeAccuracy(double accuracy)
          Set the relative accuracy.
protected  void setResult(double result, int iterationCount)
          Convenience function for implementations.
protected  void verifyInterval(double lower, double upper)
          Verifies that the endpoints specify an interval.
protected  void verifyIterationCount()
          Verifies that the upper and lower limits of iterations are valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.math.analysis.UnivariateRealIntegrator
integrate
 

Field Detail

serialVersionUID

static final long serialVersionUID
serializable version identifier

See Also:
Constant Field Values

relativeAccuracy

protected double relativeAccuracy
maximum relative error


maximalIterationCount

protected int maximalIterationCount
maximum number of iterations


minimalIterationCount

protected int minimalIterationCount
minimum number of iterations


defaultRelativeAccuracy

protected double defaultRelativeAccuracy
default maximum relative error


defaultMaximalIterationCount

protected int defaultMaximalIterationCount
default maximum number of iterations


defaultMinimalIterationCount

protected int defaultMinimalIterationCount
default minimum number of iterations


resultComputed

protected boolean resultComputed
indicates whether an integral has been computed


result

protected double result
the last computed integral


iterationCount

protected int iterationCount
the last iteration count


f

protected UnivariateRealFunction f
the integrand function

Constructor Detail

UnivariateRealIntegratorImpl

protected UnivariateRealIntegratorImpl(UnivariateRealFunction f,
                                       int defaultMaximalIterationCount)
                                throws java.lang.IllegalArgumentException
Construct an integrator with given iteration count and accuracy.

Parameters:
f - the integrand function
defaultMaximalIterationCount - maximum number of iterations
Throws:
java.lang.IllegalArgumentException - if f is null or the iteration limits are not valid
Method Detail

getResult

public double getResult()
                 throws java.lang.IllegalStateException
Access the last computed integral.

Specified by:
getResult in interface UnivariateRealIntegrator
Returns:
the last computed integral
Throws:
java.lang.IllegalStateException - if no integral has been computed

getIterationCount

public int getIterationCount()
                      throws java.lang.IllegalStateException
Access the last iteration count.

Specified by:
getIterationCount in interface UnivariateRealIntegrator
Returns:
the last iteration count
Throws:
java.lang.IllegalStateException - if no integral has been computed

setResult

protected final void setResult(double result,
                               int iterationCount)
Convenience function for implementations.

Parameters:
result - the result to set
iterationCount - the iteration count to set

clearResult

protected final void clearResult()
Convenience function for implementations.


setMaximalIterationCount

public void setMaximalIterationCount(int count)
Set the upper limit for the number of iterations.

Specified by:
setMaximalIterationCount in interface UnivariateRealIntegrator
Parameters:
count - maximum number of iterations

getMaximalIterationCount

public int getMaximalIterationCount()
Get the upper limit for the number of iterations.

Specified by:
getMaximalIterationCount in interface UnivariateRealIntegrator
Returns:
the actual upper limit

resetMaximalIterationCount

public void resetMaximalIterationCount()
Reset the upper limit for the number of iterations to the default.

Specified by:
resetMaximalIterationCount in interface UnivariateRealIntegrator
See Also:
UnivariateRealIntegrator.setMaximalIterationCount(int)

setMinimalIterationCount

public void setMinimalIterationCount(int count)
Set the lower limit for the number of iterations.

Specified by:
setMinimalIterationCount in interface UnivariateRealIntegrator
Parameters:
count - minimum number of iterations

getMinimalIterationCount

public int getMinimalIterationCount()
Get the lower limit for the number of iterations.

Specified by:
getMinimalIterationCount in interface UnivariateRealIntegrator
Returns:
the actual lower limit

resetMinimalIterationCount

public void resetMinimalIterationCount()
Reset the lower limit for the number of iterations to the default.

Specified by:
resetMinimalIterationCount in interface UnivariateRealIntegrator
See Also:
UnivariateRealIntegrator.setMinimalIterationCount(int)

setRelativeAccuracy

public void setRelativeAccuracy(double accuracy)
Set the relative accuracy.

Specified by:
setRelativeAccuracy in interface UnivariateRealIntegrator
Parameters:
accuracy - the relative accuracy
Throws:
java.lang.IllegalArgumentException - if the accuracy can't be achieved by the integrator or is otherwise deemed unreasonable

getRelativeAccuracy

public double getRelativeAccuracy()
Get the actual relative accuracy.

Specified by:
getRelativeAccuracy in interface UnivariateRealIntegrator
Returns:
the accuracy

resetRelativeAccuracy

public void resetRelativeAccuracy()
Reset the relative accuracy to the default.

Specified by:
resetRelativeAccuracy in interface UnivariateRealIntegrator
See Also:
UnivariateRealIntegrator.setRelativeAccuracy(double)

isSequence

protected boolean isSequence(double start,
                             double mid,
                             double end)
Returns true if the arguments form a (strictly) increasing sequence

Parameters:
start - first number
mid - second number
end - third number
Returns:
true if the arguments form an increasing sequence

verifyInterval

protected void verifyInterval(double lower,
                              double upper)
                       throws java.lang.IllegalArgumentException
Verifies that the endpoints specify an interval.

Parameters:
lower - lower endpoint
upper - upper endpoint
Throws:
java.lang.IllegalArgumentException - if not interval

verifyIterationCount

protected void verifyIterationCount()
                             throws java.lang.IllegalArgumentException
Verifies that the upper and lower limits of iterations are valid.

Throws:
java.lang.IllegalArgumentException - if not valid