public class ComputableFunctionSampler extends java.lang.Object implements SampledFunction, java.io.Serializable
ComputableFunction.
The sample produced is a regular sample. It can be specified by several means :
The sample points are computed on demand, they are not stored. This allow to use this method for very large sample with little memory overhead. The drawback is that if the same sample points are going to be requested several times, they will be recomputed each time. In this case, the user should consider storing the points by some other means.
ComputableFunction,
Serialized Form| Constructor and Description |
|---|
ComputableFunctionSampler(ComputableFunction function,
double[] range,
double step,
boolean adjustStep)
Constructor.
|
ComputableFunctionSampler(ComputableFunction function,
double[] range,
int n)
Constructor.
|
ComputableFunctionSampler(ComputableFunction function,
double begin,
double step,
int n)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
ScalarValuedPair |
samplePointAt(int index)
Get the abscissa and value of the sample at the specified index.
|
int |
size()
Get the number of points in the sample.
|
public ComputableFunctionSampler(ComputableFunction function, double begin, double step, int n)
ComputableFunction. Beware of the
classical off-by-one problem ! If you want to have a sample like
this : 0.0, 0.1, 0.2 ..., 1.0, then you should specify step = 0.1
and n = 11 (not n = 10).begin - beginning of the range (will be the abscissa of the
first point)step - step between pointsn - number of pointspublic ComputableFunctionSampler(ComputableFunction function, double[] range, int n)
ComputableFunction.range - abscissa range (from range [0] to
range [1])n - number of pointspublic ComputableFunctionSampler(ComputableFunction function, double[] range, double step, boolean adjustStep)
ComputableFunction.range - abscissa range (from range [0] to
range [1])step - step between pointsadjustStep - if true, the step is reduced in order to have
the last point of the sample exactly at range [1],
if false the last point will be between range [1] -
step and range [1]public int size()
SampledFunctionsize in interface SampledFunctionpublic ScalarValuedPair samplePointAt(int index) throws java.lang.ArrayIndexOutOfBoundsException, FunctionException
SampledFunctionsamplePointAt in interface SampledFunctionindex - index in the sample, should be between 0 and
SampledFunction.size() - 1java.lang.ArrayIndexOutOfBoundsException - if the index is wrongFunctionException - if an eventual underlying function
throws oneCopyright © 2001-2007 Luc Maisonobe. All Rights Reserved.