|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.doodleproject.numerics4j.IterativeMethod
net.sf.doodleproject.numerics4j.continuedfraction.ContinuedFraction
public abstract class ContinuedFraction
This class provides the means to evaluate continued fractions (1). To create a continued fraction, authors subclass this class and provided concrete a and b coefficient methods.
For example, this is the continued fraction for the exponential function defined by (2):
ContinuedFraction exponential = new ContinuedFraction() {
public double getA(int n, double x) {
if (n == 0) {
return 1.0;
} else if (n % 2 == 0) { // even
return 2.0;
} else { // odd
return n;
}
}
public double getB(int n, double x) {
if (n % 2 == 0) { // even
return x;
} else { // odd
return -x;
}
}
References:
| Nested Class Summary | |
|---|---|
(package private) class |
ContinuedFraction.IterativeState
The internal state used during continued fraction evaluation. |
| Constructor Summary | |
|---|---|
protected |
ContinuedFraction()
Default constructor. |
protected |
ContinuedFraction(int iterations,
double error)
Create a continued fraction with the given number of maximum iterations and maximum relative error. |
| Method Summary | |
|---|---|
double |
evaluate(double x)
Evaluate this continued fraction at the given value. |
protected abstract double |
getA(int n,
double x)
Access the n-th a coefficient. |
protected abstract double |
getB(int n,
double x)
Access the n-th b coefficient. |
| Methods inherited from class net.sf.doodleproject.numerics4j.IterativeMethod |
|---|
getMaximumIterations, getMaximumRelativeError, iterate, setMaximumIterations, setMaximumRelativeError |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected ContinuedFraction()
protected ContinuedFraction(int iterations,
double error)
iterations - maximum number of iterations.error - maximum relative error.| Method Detail |
|---|
public double evaluate(double x)
throws NumericException
x - the point of evalutation.
NumericException - if the continued fraction could not be
evaluated.
protected abstract double getA(int n,
double x)
n - the coefficient index.x - the continued fraction evaluation point.
protected abstract double getB(int n,
double x)
n - the coefficient index.x - the continued fraction evaluation point.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||