org.sbml.jsbml.math.compiler
public class UnitsCompiler extends java.lang.Object implements ASTNode2Compiler
Modifier and Type | Field and Description |
---|---|
private int |
level
SBML level field
|
private Model |
model
The model associated to this compiler.
|
private java.util.HashMap<java.lang.String,ASTNode2Value<?>> |
namesToUnits
Necessary for function definitions to remember the units of the argument
list.
|
private int |
version
SBML version field
|
Constructor and Description |
---|
UnitsCompiler() |
UnitsCompiler(int level,
int version) |
UnitsCompiler(Model model) |
Modifier and Type | Method and Description |
---|---|
<T> ASTNode2Value<java.lang.Double> |
abs(ASTNode2 value)
The absolute value represented by the given
ASTNode2 . |
<T> ASTNode2Value<java.lang.Boolean> |
and(java.util.List<ASTNode2> values) |
<T> ASTNode2Value<java.lang.Double> |
arccos(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
arccosh(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
arccot(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
arccoth(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
arccsc(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
arccsch(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
arcsec(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
arcsech(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
arcsin(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
arcsinh(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
arctan(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
arctanh(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
ceiling(ASTNode2 value) |
private void |
checkForDimensionlessOrInvalidUnits(UnitDefinition units)
Throws an
IllegalArgumentException if the given units do not
represent a dimensionless or invalid unit. |
<T> ASTNode2Value<java.lang.Boolean> |
compile(boolean b)
Compile boolean values
|
<T> ASTNode2Value<CallableSBase> |
compile(CallableSBase variable) |
<T> ASTNode2Value<CallableSBase> |
compile(Compartment c) |
<T> ASTNode2Value<java.lang.String> |
compile(double mantissa,
int exponent,
java.lang.String units)
Creates an
ASTNode2Value that represents a real number in
scientific notation, i.e., mantissa * 10^exponent, and the given units. |
<T> ASTNode2Value<java.lang.String> |
compile(double real,
java.lang.String units) |
<T> ASTNode2Value |
compile(int integer,
java.lang.String units) |
<T> ASTNode2Value<?> |
compile(java.lang.String name)
A compiler will also have to deal with a name.
|
<T> ASTNode2Value<java.lang.Double> |
cos(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
cosh(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
cot(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
coth(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
csc(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
csch(ASTNode2 value) |
<T> ASTNode2Value<?> |
delay(java.lang.String delayName,
ASTNode2 x,
ASTNode2 delay)
Evaluates delay functions.
|
private <T> ASTNode2Value<T> |
dimensionless(java.lang.Class<T> type)
Creates a dimensionless unit definition object encapsulated in an
ASTNode2Value . |
<T> ASTNode2Value<java.lang.Boolean> |
eq(ASTNode2 left,
ASTNode2 right)
Equal.
|
<T> ASTNode2Value<?> |
exp(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Long> |
factorial(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
floor(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
frac(ASTNode2 numerator,
ASTNode2 denominator)
Fraction of two
ASTNode2 s |
<T> ASTNode2Value<java.lang.Double> |
frac(int numerator,
int denominator)
A fraction of two int values.
|
<T> ASTNode2Value<java.lang.String> |
function(FunctionDefinition function,
java.util.List<ASTNode2> args) |
<T> ASTNode2Value<java.lang.String> |
function(java.lang.String functionDefinitionName,
java.util.List<ASTNode2> args) |
<T> ASTNode2Value<?> |
function(T functionDefinitionName,
java.util.List<ASTNode2> args) |
<T> ASTNode2Value<java.lang.Boolean> |
geq(ASTNode2 left,
ASTNode2 right)
Greater equal.
|
<T> ASTNode2Value<java.lang.Double> |
getConstantAvogadro(java.lang.String name)
Creates an
ASTNode2Value that represent's Avogadro's number. |
<T> ASTNode2Value<java.lang.Double> |
getConstantE() |
<T> ASTNode2Value<java.lang.Boolean> |
getConstantFalse() |
<T> ASTNode2Value<java.lang.Double> |
getConstantPi() |
<T> ASTNode2Value<java.lang.Boolean> |
getConstantTrue() |
<T> ASTNode2Value<java.lang.String> |
getNegativeInfinity() |
<T> ASTNode2Value<java.lang.String> |
getPositiveInfinity() |
<T> ASTNode2Value<java.lang.Boolean> |
gt(ASTNode2 left,
ASTNode2 right)
Greater than.
|
private <T> ASTNode2Value<?> |
invalid()
Creates an invalid unit definition encapsulated in an ASTNode2Value.
|
<T> ASTNode2Value<?> |
lambda(java.util.List<ASTNode2> values)
The body of a
FunctionDefinition . |
ASTNode2Value<java.lang.Boolean> |
leq(ASTNode2 left,
ASTNode2 right)
Less equal.
|
<T> ASTNode2Value<java.lang.Double> |
ln(ASTNode2 value)
Natural logarithm.
|
<T> ASTNode2Value<java.lang.Double> |
log(ASTNode2 value)
Logarithm of the given value to base 10.
|
<T> ASTNode2Value<java.lang.Double> |
log(ASTNode2 number,
ASTNode2 base)
Logarithm of the given value to the given base.
|
<T> ASTNode2Value<java.lang.Boolean> |
lt(ASTNode2 left,
ASTNode2 right)
Less than.
|
<T> ASTNode2Value<?> |
minus(java.util.List<ASTNode2> values)
Subtraction.
|
ASTNode2Value<java.lang.Boolean> |
neq(ASTNode2 left,
ASTNode2 right)
Not equal.
|
<T> ASTNode2Value<java.lang.Boolean> |
not(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Boolean> |
or(java.util.List<ASTNode2> values) |
<T> ASTNode2Value<?> |
piecewise(java.util.List<ASTNode2> values) |
<T> ASTNode2Value<?> |
plus(java.util.List<ASTNode2> values) |
<T> ASTNode2Value<?> |
pow(ASTNode2 base,
ASTNode2 exponent) |
private <T> ASTNode2Value<?> |
pow(ASTNode2Value base,
ASTNode2Value exponent) |
<T> ASTNode2Value<java.lang.Double> |
root(ASTNode2 rootExponent,
ASTNode2 radiant) |
<T> ASTNode2Value<java.lang.Double> |
root(double rootExponent,
ASTNode2 radiant) |
private <T> ASTNode2Value<java.lang.Double> |
root(double rootExponent,
ASTNode2Value radiant) |
<T> ASTNode2Value<java.lang.Double> |
sec(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
sech(ASTNode2 value) |
<T> ASTNode2Value<java.lang.String> |
selector(java.util.List<ASTNode2> nodes) |
private void |
setLevelAndVersion(UnitDefinition unit)
Ensures that level and version combination of a unit are the same then
these that are defined here.
|
ASTNode2Value<?> |
sin(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
sinh(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
sqrt(ASTNode2 value)
Square root.
|
<T> ASTNode2Value<java.lang.Double> |
symbolTime(java.lang.String time)
The simulation time.
|
<T> ASTNode2Value<java.lang.Double> |
tan(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
tanh(ASTNode2 value) |
<T> ASTNode2Value<java.lang.Double> |
times(java.util.List<ASTNode2> values)
Product of all given
ASTNode2 s. |
ASTNode2Value<?> |
uMinus(ASTNode2 value)
Unary minus, i.e., negation of the given
ASTNode2 . |
private void |
unifyUnits(ASTNode2Value left,
ASTNode2Value right)
This method tries to unify the units of two ASTNode2Values so that they
have the same units and their value thus is also adjusted.
|
<T> ASTNode2Value<?> |
unknownValue()
Dealing with a malformed
ASTNode2 . |
<T> ASTNode2Value<java.lang.String> |
vector(java.util.List<ASTNode2> nodes)
Dealing with a vector.
|
<T> ASTNode2Value<java.lang.Boolean> |
xor(java.util.List<ASTNode2> values)
Exclusive or.
|
private final int level
private final int version
private Model model
private java.util.HashMap<java.lang.String,ASTNode2Value<?>> namesToUnits
public UnitsCompiler()
public UnitsCompiler(int level, int version)
level
- version
- public UnitsCompiler(Model model)
model
- public <T> ASTNode2Value<java.lang.Double> abs(ASTNode2 value) throws SBMLException
ASTNode2Compiler
ASTNode2
.abs
in interface ASTNode2Compiler
value
- Must be interpretable as a Number
.SBMLException
public <T> ASTNode2Value<java.lang.Boolean> and(java.util.List<ASTNode2> values) throws SBMLException
and
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> arccos(ASTNode2 value) throws SBMLException
arccos
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> arccosh(ASTNode2 value) throws SBMLException
arccosh
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> arccot(ASTNode2 value) throws SBMLException
arccot
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> arccoth(ASTNode2 value) throws SBMLException
arccoth
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> arccsc(ASTNode2 value) throws SBMLException
arccsc
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> arccsch(ASTNode2 value) throws SBMLException
arccsch
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> arcsec(ASTNode2 value) throws SBMLException
arcsec
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> arcsech(ASTNode2 value) throws SBMLException
arcsech
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> arcsin(ASTNode2 value) throws SBMLException
arcsin
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> arcsinh(ASTNode2 value) throws SBMLException
arcsinh
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> arctan(ASTNode2 value) throws SBMLException
arctan
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> arctanh(ASTNode2 value) throws SBMLException
arctanh
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> ceiling(ASTNode2 value) throws SBMLException
ceiling
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Boolean> compile(boolean b)
b
- public <T> ASTNode2Value<CallableSBase> compile(Compartment c)
compile
in interface ASTNode2Compiler
public <T> ASTNode2Value<java.lang.String> compile(double mantissa, int exponent, java.lang.String units)
ASTNode2Compiler
ASTNode2Value
that represents a real number in
scientific notation, i.e., mantissa * 10^exponent, and the given units.compile
in interface ASTNode2Compiler
mantissa
- The number to be multiplied with ten to the power of the given
exponent.exponent
- The exponent for the multiplier ten.units
- The identifier of the units object associated with the number
represented by this element. Can be null if no units have been
defined.public <T> ASTNode2Value<java.lang.String> compile(double real, java.lang.String units)
compile
in interface ASTNode2Compiler
units
- A String representing the Unit
of the given number.
This can be the identifier of a UnitDefinition
in the
model or a literal in Unit.Kind
. Can be null if no units
have been defined.public <T> ASTNode2Value compile(int integer, java.lang.String units)
compile
in interface ASTNode2Compiler
units
- A String representing the Unit
of the given number.
This can be the identifier of a UnitDefinition
in the
model or a literal in Unit.Kind
. Can be null if no units
have been defined.public <T> ASTNode2Value<CallableSBase> compile(CallableSBase variable)
compile
in interface ASTNode2Compiler
public <T> ASTNode2Value<?> compile(java.lang.String name)
ASTNode2Compiler
Species
in the
system. In case of numerical computation, the ASTNodeCompiler
must create an ASTNode2Value
representing the current value of
this Species
.compile
in interface ASTNode2Compiler
public <T> ASTNode2Value<java.lang.Double> cos(ASTNode2 value) throws SBMLException
cos
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> cosh(ASTNode2 value) throws SBMLException
cosh
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> cot(ASTNode2 value) throws SBMLException
cot
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> coth(ASTNode2 value) throws SBMLException
coth
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> csc(ASTNode2 value) throws SBMLException
csc
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> csch(ASTNode2 value) throws SBMLException
csch
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<?> delay(java.lang.String delayName, ASTNode2 x, ASTNode2 delay) throws SBMLException
ASTNode2Compiler
delay
in interface ASTNode2Compiler
delayName
- the name of this delay function.delay
- an expression of a positive duration time (the amoutn of
delay)SBMLException
private <T> ASTNode2Value<T> dimensionless(java.lang.Class<T> type)
ASTNode2Value
.type
- The type of the dimensionless value, e.g., Boolean.class etc.public <T> ASTNode2Value<java.lang.Boolean> eq(ASTNode2 left, ASTNode2 right) throws SBMLException
ASTNode2Compiler
eq
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<?> exp(ASTNode2 value) throws SBMLException
exp
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Long> factorial(ASTNode2 value) throws SBMLException
factorial
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> floor(ASTNode2 value) throws SBMLException
floor
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> frac(ASTNode2 numerator, ASTNode2 denominator) throws SBMLException
ASTNode2Compiler
ASTNode2
sfrac
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> frac(int numerator, int denominator)
ASTNode2Compiler
frac
in interface ASTNode2Compiler
public <T> ASTNode2Value<java.lang.String> function(FunctionDefinition function, java.util.List<ASTNode2> args) throws SBMLException
function
in interface ASTNode2Compiler
args
- Values to be inserted into the parameter list of the
function.SBMLException
public <T> ASTNode2Value<java.lang.String> function(java.lang.String functionDefinitionName, java.util.List<ASTNode2> args) throws SBMLException
function
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Boolean> geq(ASTNode2 left, ASTNode2 right) throws SBMLException
ASTNode2Compiler
geq
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> getConstantAvogadro(java.lang.String name)
ASTNode2Compiler
ASTNode2Value
that represent's Avogadro's number.
Optionally, the compiler may associate the given name with this number.getConstantAvogadro
in interface ASTNode2Compiler
name
- An optional name for Avogadro's number.public <T> ASTNode2Value<java.lang.Double> getConstantE()
getConstantE
in interface ASTNode2Compiler
public <T> ASTNode2Value<java.lang.Boolean> getConstantFalse()
getConstantFalse
in interface ASTNode2Compiler
public <T> ASTNode2Value<java.lang.Double> getConstantPi()
getConstantPi
in interface ASTNode2Compiler
public <T> ASTNode2Value<java.lang.Boolean> getConstantTrue()
getConstantTrue
in interface ASTNode2Compiler
public <T> ASTNode2Value<java.lang.String> getNegativeInfinity()
getNegativeInfinity
in interface ASTNode2Compiler
public <T> ASTNode2Value<java.lang.String> getPositiveInfinity()
getPositiveInfinity
in interface ASTNode2Compiler
public <T> ASTNode2Value<java.lang.Boolean> gt(ASTNode2 left, ASTNode2 right) throws SBMLException
ASTNode2Compiler
gt
in interface ASTNode2Compiler
SBMLException
private <T> ASTNode2Value<?> invalid()
public <T> ASTNode2Value<?> lambda(java.util.List<ASTNode2> values) throws SBMLException
ASTNode2Compiler
FunctionDefinition
.lambda
in interface ASTNode2Compiler
values
- Place holders for arguments.SBMLException
public ASTNode2Value<java.lang.Boolean> leq(ASTNode2 left, ASTNode2 right) throws SBMLException
ASTNode2Compiler
leq
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> ln(ASTNode2 value) throws SBMLException
ASTNode2Compiler
ln
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> log(ASTNode2 value) throws SBMLException
ASTNode2Compiler
log
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> log(ASTNode2 number, ASTNode2 base) throws SBMLException
ASTNode2Compiler
log
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Boolean> lt(ASTNode2 left, ASTNode2 right) throws SBMLException
ASTNode2Compiler
lt
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<?> minus(java.util.List<ASTNode2> values) throws SBMLException
ASTNode2Compiler
minus
in interface ASTNode2Compiler
SBMLException
public ASTNode2Value<java.lang.Boolean> neq(ASTNode2 left, ASTNode2 right) throws SBMLException
ASTNode2Compiler
neq
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Boolean> not(ASTNode2 value) throws SBMLException
not
in interface ASTNode2Compiler
value
- This value must be interpretable as a Boolean
.SBMLException
public <T> ASTNode2Value<java.lang.Boolean> or(java.util.List<ASTNode2> values) throws SBMLException
or
in interface ASTNode2Compiler
values
- These values must be interpretable as a Boolean
.SBMLException
public <T> ASTNode2Value<?> piecewise(java.util.List<ASTNode2> values) throws SBMLException
piecewise
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<?> plus(java.util.List<ASTNode2> values) throws SBMLException
plus
in interface ASTNode2Compiler
SBMLException
private void unifyUnits(ASTNode2Value left, ASTNode2Value right) throws SBMLException
left
- right
- SBMLException
public <T> ASTNode2Value<?> pow(ASTNode2 base, ASTNode2 exponent) throws SBMLException
pow
in interface ASTNode2Compiler
SBMLException
private <T> ASTNode2Value<?> pow(ASTNode2Value base, ASTNode2Value exponent) throws SBMLException
base
- exponent
- SBMLException
private void checkForDimensionlessOrInvalidUnits(UnitDefinition units)
IllegalArgumentException
if the given units do not
represent a dimensionless or invalid unit.units
- public <T> ASTNode2Value<java.lang.Double> root(ASTNode2 rootExponent, ASTNode2 radiant) throws SBMLException
root
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> root(double rootExponent, ASTNode2 radiant) throws SBMLException
root
in interface ASTNode2Compiler
SBMLException
private <T> ASTNode2Value<java.lang.Double> root(double rootExponent, ASTNode2Value radiant) throws SBMLException
rootExponent
- radiant
- SBMLException
public <T> ASTNode2Value<java.lang.Double> sec(ASTNode2 value) throws SBMLException
sec
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> sech(ASTNode2 value) throws SBMLException
sech
in interface ASTNode2Compiler
SBMLException
private void setLevelAndVersion(UnitDefinition unit)
unit
- public ASTNode2Value<?> sin(ASTNode2 value) throws SBMLException
sin
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> sinh(ASTNode2 value) throws SBMLException
sinh
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> sqrt(ASTNode2 value) throws SBMLException
ASTNode2Compiler
sqrt
in interface ASTNode2Compiler
value
- This value must be interpretable as a Number
.SBMLException
public <T> ASTNode2Value<java.lang.Double> symbolTime(java.lang.String time)
ASTNode2Compiler
symbolTime
in interface ASTNode2Compiler
time
- The name of the time symbol.ASTNode2Value
that represents the current time.public <T> ASTNode2Value<java.lang.Double> tan(ASTNode2 value) throws SBMLException
tan
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> tanh(ASTNode2 value) throws SBMLException
tanh
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.Double> times(java.util.List<ASTNode2> values) throws SBMLException
ASTNode2Compiler
ASTNode2
s.times
in interface ASTNode2Compiler
values
- These values must be interpretable to Number
.SBMLException
public ASTNode2Value<?> uMinus(ASTNode2 value) throws SBMLException
ASTNode2Compiler
ASTNode2
.uMinus
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<?> unknownValue()
ASTNode2Compiler
ASTNode2
.unknownValue
in interface ASTNode2Compiler
public <T> ASTNode2Value<java.lang.Boolean> xor(java.util.List<ASTNode2> values) throws SBMLException
ASTNode2Compiler
xor
in interface ASTNode2Compiler
values
- It must be possible to evaluate the given values to
Boolean
.SBMLException
public <T> ASTNode2Value<java.lang.String> selector(java.util.List<ASTNode2> nodes) throws SBMLException
selector
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<java.lang.String> vector(java.util.List<ASTNode2> nodes) throws SBMLException
ASTNode2Compiler
vector
in interface ASTNode2Compiler
SBMLException
public <T> ASTNode2Value<?> function(T functionDefinitionName, java.util.List<ASTNode2> args) throws SBMLException
function
in interface ASTNode2Compiler
args
- Values to be inserted into the parameter list of the
function.SBMLException