org.apache.commons.math3.analysis.interpolation
Class UniLinearIntervalsFunction
java.lang.Object
org.apache.commons.math3.analysis.interpolation.AbstractLinearIntervalsFunction
org.apache.commons.math3.analysis.interpolation.UniLinearIntervalsFunction
- All Implemented Interfaces:
- UnivariateFunction
public class UniLinearIntervalsFunction
- extends AbstractLinearIntervalsFunction
- implements UnivariateFunction
Implements the representation of a linear function in dimension 1.
If double[] are given to the constructor, they should be sorted by increasing order.
No test to ensure that will be made, therefore, if these tab are not correctly sorted,
results can be totally wrong. No exception will be thrown.
- Since:
- 2.3
- Version:
- $Id: UniLinearIntervalsFunction.java 17603 2017-05-18 08:28:32Z bignon $
- Author:
- Sophie LAURENS
- Concurrency :
- not thread-safe
- Concurrency comment :
- input ISearchIndex not thread-safe
Method Summary |
double[] |
getValues()
Getter for ftab in dimension 1 |
double |
value(double x)
Computation of the interpolated/extrapolated value f(x). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
UniLinearIntervalsFunction
public UniLinearIntervalsFunction(double[] xval,
double[] fval)
- Constructor, in one dimension. The search index algorithm is set by default to an instance of
class BinarySearchIndexClosedOpen, see its javadoc for convention details.
Checks the lengths of xval and fval : they should be equal, and at least 2.
- Parameters:
xval
- : abscissas array increasingly sorted of length >= 2 (duplicates are allowed).fval
- : function values array increasingly sorted of length >= 2.- Preconditions :
- : xval and fval are increasingly sorted. No test to ensure that will
be made, therefore, if these tab are not correctly sorted, results can be totally wrong. No exception will
be thrown.
UniLinearIntervalsFunction
public UniLinearIntervalsFunction(ISearchIndex algoX,
double[] fval)
- Constructor, in one dimension with a search index algorithm as a parameter.
The attribute xtab is retrieved from the search index algorithm.
Checks the lengths of xval and fval : they should be equal, and at least 2.
- Parameters:
algoX
- : an instance of a class implemented ISearchIndex, containing xtab.
When it has been created, it should have been with a sorted tab.fval
- : function values array increasingly sorted of length >= 2.- Preconditions :
- : fval is increasingly sorted, and the search index algorithm had to be
created with a sorted tab also. No test to ensure that will be made, therefore, if these
tab are not correctly sorted, results can be totally wrong. No exception will be thrown.
value
public double value(double x)
- Computation of the interpolated/extrapolated value f(x).
If the index returned by method getIndex(key) is -1, with the convention OPEN_CLOSED, it can be either
tab[0] = key, and in that case it's an interpolation that has to be done, or key < tab[0], and in that case,
it is an extrapolation, where the slope used is the one computed in the first interval, and extended to key.
Important remark : in the last case, the result obtained is highly optimistic, because it can work even if key is
far away from tab[0], and therefore, the information the extrapolation is made upon is highly approximated.
If the index return is numberOfPoints, with the convention CLOSED_OPEN,
it can be either tab[numberOfPoints-1] = key or key > tab[numberOfPoints-1].
- Specified by:
value
in interface UnivariateFunction
- Parameters:
x
- : abscissa where to interpolate.
- Returns:
- fx : the value of the function at x.
getValues
public double[] getValues()
- Getter for ftab in dimension 1
- Returns:
- the function values
Copyright © 2017 CNES. All Rights Reserved.