|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectvec_math.SimpleIntegrator
public class SimpleIntegrator
The simpliest Integrator possible. Implements a
trapezoid-integrator. Only the accumulated sum is stored. Highly
inefficient if used with setting of huge data sets.
Note that it is within the user's responsibility to correctly initialize
the numerical integrator with a call to initData(double, double) prior to calling
the one of the add(double, double) methods.
| Nested Class Summary | |
|---|---|
static class |
SimpleIntegrator.E
Tests the integrator. |
static class |
SimpleIntegrator.Gauss
Tests the integrator. |
static class |
SimpleIntegrator.Xsquare
Tests the integrator. |
| Field Summary | |
|---|---|
private double |
xprior
The x-value prior-to-last. |
private double |
yprior
The y-value prior-to-last. |
private double |
ysum
The accumulated sum, i.e. |
| Constructor Summary | |
|---|---|
SimpleIntegrator()
|
|
| Method Summary | |
|---|---|
void |
add(double y)
Adds a new y-data point with a step-size of one. |
void |
add(double x,
double y)
Adds a new x/y data point. |
private void |
addTrapezoid(double base,
double ynew)
This private method calculates the area of an trapezoid and adds it to the accumulated sum in ysum. |
double |
getIntegral()
Calculates the difference at the last points added. |
double |
getIntegral(double x)
Cannot compute. |
void |
initData(double xstart,
double ystart)
Initializes the integrator. |
void |
setData(double[] y)
Takes the last two y-values as the last and prior-to-last y value. |
void |
setData(double[] x,
double[] y)
Lengthy implementation erasing all old data and step-by-step adding the new one. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private double xprior
private double yprior
private double ysum
| Constructor Detail |
|---|
public SimpleIntegrator()
| Method Detail |
|---|
public void initData(double xstart,
double ystart)
xprior and yprior. Additionally, the accumulated
sum is set to zero.
initData in interface Integrator
public void add(double x,
double y)
xprior value to calculate
a step-size and then calls addTrapezoid(double, double).
add in interface Integratorx - A newly added x-value.y - A newly added y-value.public void add(double y)
add in interface Integratory - A newly added y-value.
private void addTrapezoid(double base,
double ynew)
ysum. Additionally, the y-prior
value is updated to the new y value.
public void setData(double[] x,
double[] y)
initData(double, double) with the first x/y pair and then
continuously adds new data with the add(double, double) method.
setData in interface Integratorx - A double-array representing the x-axis values.y - A double-array representing the y-axis values.public void setData(double[] y)
setData in interface Integratory - A double-array representing the y-axis values.public double getIntegral()
getIntegral in interface Integratorpublic double getIntegral(double x)
getIntegral in interface Integrator
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||