Package uk.ac.starlink.ttools.jel
Class JELFunction
- java.lang.Object
-
- uk.ac.starlink.ttools.jel.JELFunction
-
public class JELFunction extends java.lang.Object
Provides a double precision function of one double precision variable which can be evaluated using JEL. The variable name and an expression giving the result in terms of that variable name are supplied.Instances of this class are not threadsafe, but could be made so by putting a lock on the
evaluate(double)
method.- Since:
- 14 Jun 2012
- Author:
- Mark Taylor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JELFunction.XResolver
This public class is an implementation detail, not intended for external use.
-
Constructor Summary
Constructors Constructor Description JELFunction(java.lang.String xvarname, java.lang.String fexpr)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
evaluate(double x)
Evaluates this function at a given value of the independent variable.java.lang.String
getExpression()
Returns the text of the function expression.java.lang.String
getXVarName()
Returns the name of the independent variable.static void
main(java.lang.String[] args)
Main method tests this class.
-
-
-
Constructor Detail
-
JELFunction
public JELFunction(java.lang.String xvarname, java.lang.String fexpr) throws gnu.jel.CompilationException
Constructor.- Parameters:
xvarname
- name of the independent variable (for instance "x")fexpr
- text of expression giving the function value, in terms ofxvarname
(for instance "x+1")- Throws:
gnu.jel.CompilationException
-
-
Method Detail
-
evaluate
public double evaluate(double x)
Evaluates this function at a given value of the independent variable. In case of an evaluation error of some kind, NaN is returned.- Parameters:
x
- variable value- Returns:
- function value
-
getXVarName
public java.lang.String getXVarName()
Returns the name of the independent variable.- Returns:
- x variable name
-
getExpression
public java.lang.String getExpression()
Returns the text of the function expression.- Returns:
- function expression
-
main
public static void main(java.lang.String[] args)
Main method tests this class. Args are varname, expr, varvalue, for instance "x", "3x+1", "29"
-
-