public final class DoubleUtils extends Object
java.lang.Double
.Modifier and Type | Field and Description |
---|---|
static DoubleUtils |
DOUBLE_UTILS
Singleton instance.
|
Modifier and Type | Method and Description |
---|---|
protected Double |
add(Double i1,
Double i2) |
ConstantNode |
add(Node n1,
Node n2)
Returns the result of adding the numeric values represented by the given
Node s. |
ConstantNode |
add(Node n1,
Node n2,
Assignments assignments)
Returns the result of adding the result of evaluating the given
Node s with the given Assignments . |
ConstantNode |
decrement(Node n)
Returns the result of subtracting one from the numeric value represented by the given node.
|
protected Double |
divide(Double i1,
Double i2) |
ConstantNode |
divide(Node n1,
Node n2,
Assignments assignments)
Returns the result of dividing the result of evaluating the given
Node s with the given Assignments . |
org.oakgp.function.math.Add |
getAdd()
Returns an addition operator for the numeric type this instance is concerned with.
|
org.oakgp.function.math.Divide |
getDivide()
Returns a division operator for the numeric type this instance is concerned with.
|
org.oakgp.function.math.Multiply |
getMultiply()
Returns a multiplication operator for the numeric type this instance is concerned with.
|
org.oakgp.function.math.ArithmeticExpressionSimplifier |
getSimplifier()
Returns a
ArithmeticExpressionSimplifier for the numeric type this instance is concerned with. |
org.oakgp.function.math.Subtract |
getSubtract()
Returns a subtraction operator for the numeric type this instance is concerned with.
|
Type |
getType()
Returns the
Type associated with the numeric values this instance is concerned with. |
ConstantNode |
increment(Node n)
Returns the result of adding one to the numeric value represented by the given node.
|
boolean |
isAdd(Function f)
|
boolean |
isAddOrSubtract(Function f)
Returns
true if the given Function is the same as the values returned from getAdd() or getSubtract() . |
boolean |
isArithmeticExpression(Node n)
Returns
true if the given Node is a FunctionNode with the same Function as returned from getAdd() ,
getSubtract() , getMultiply() or getDivide() . |
boolean |
isMultiply(Function f)
|
boolean |
isMultiply(FunctionNode n)
|
boolean |
isNegative(Node n)
Returns
true if the numeric value represented by the given node is less than zero. |
boolean |
isOne(Node n)
Returns true if the given
Node is a ConstantNode with the value 1 of type #T . |
boolean |
isSubtract(Function f)
|
boolean |
isSubtract(FunctionNode n)
|
boolean |
isSubtract(Node n)
Returns
true if the given Node is a FunctionNode with the same Function as returned from getSubtract() . |
boolean |
isZero(Node n)
Returns true if the given
Node is a ConstantNode with the value 0 of type #T . |
protected Double |
multiply(Double i1,
Double i2) |
ConstantNode |
multiply(Node n1,
Node n2)
Returns the result of multiplying the numeric values represented by the given
Node s. |
ConstantNode |
multiply(Node n1,
Node n2,
Assignments assignments)
Returns the result of multiplying the result of evaluating the given
Node s with the given Assignments . |
FunctionNode |
multiplyByTwo(Node arg)
Returns a new expression which multiplies the given
Node by two. |
Node |
negate(Node arg)
Returns the result of negating the numeric value represented by the given node.
|
ConstantNode |
negateConstant(Node n)
Returns the result of negating the numeric value represented by the given node.
|
ConstantNode |
one()
Returns a
ConstantNode with the value 1 of type #T . |
protected Double |
subtract(Double i1,
Double i2) |
ConstantNode |
subtract(Node n1,
Node n2)
Returns the result of subtracting the numeric values represented by the given
Node s. |
ConstantNode |
subtract(Node n1,
Node n2,
Assignments assignments)
Returns the result of subtracting the result of evaluating the given
Node s with the given Assignments . |
ConstantNode |
zero()
Returns a
ConstantNode with the value 0 of type #T . |
public static final DoubleUtils DOUBLE_UTILS
public final Type getType()
Type
associated with the numeric values this instance is concerned with.public final org.oakgp.function.math.ArithmeticExpressionSimplifier getSimplifier()
ArithmeticExpressionSimplifier
for the numeric type this instance is concerned with.public final org.oakgp.function.math.Add getAdd()
public final org.oakgp.function.math.Subtract getSubtract()
public final org.oakgp.function.math.Multiply getMultiply()
public final org.oakgp.function.math.Divide getDivide()
public final boolean isZero(Node n)
Node
is a ConstantNode
with the value 0
of type #T
.public final boolean isOne(Node n)
Node
is a ConstantNode
with the value 1
of type #T
.public final ConstantNode zero()
ConstantNode
with the value 0
of type #T
.public final ConstantNode one()
ConstantNode
with the value 1
of type #T
.public final ConstantNode add(Node n1, Node n2, Assignments assignments)
Node
s with the given Assignments
.public final ConstantNode add(Node n1, Node n2)
Node
s.n1
- a ConstantNode
with a value of type #T
n2
- a ConstantNode
with a value of type #T
public final ConstantNode increment(Node n)
n
- a ConstantNode
with a value of type #T
public final ConstantNode decrement(Node n)
n
- a ConstantNode
with a value of type #T
public final ConstantNode subtract(Node n1, Node n2, Assignments assignments)
Node
s with the given Assignments
.n1
- n2
public final ConstantNode subtract(Node n1, Node n2)
Node
s.n1
- a ConstantNode
with a value of type #T
n2
- a ConstantNode
with a value of type #T
n1
- n2
public final Node negate(Node arg)
n
- the expression to negate (may be a ConstantNode
, VariableNode
or a FunctionNode
)public final ConstantNode negateConstant(Node n)
n
- a ConstantNode
with a value of type #T
public final ConstantNode multiply(Node n1, Node n2, Assignments assignments)
Node
s with the given Assignments
.public final ConstantNode multiply(Node n1, Node n2)
Node
s.n1
- a ConstantNode
with a value of type #T
n2
- a ConstantNode
with a value of type #T
public final FunctionNode multiplyByTwo(Node arg)
Node
by two.public final ConstantNode divide(Node n1, Node n2, Assignments assignments)
Node
s with the given Assignments
.n1
/ n2
public final boolean isNegative(Node n)
true
if the numeric value represented by the given node is less than zero.n
- a ConstantNode
with a value of type #T
public final boolean isAddOrSubtract(Function f)
true
if the given Function
is the same as the values returned from getAdd()
or getSubtract()
.public final boolean isAdd(Function f)
public final boolean isSubtract(Node n)
true
if the given Node
is a FunctionNode
with the same Function
as returned from getSubtract()
.public final boolean isSubtract(FunctionNode n)
public final boolean isSubtract(Function f)
public final boolean isMultiply(FunctionNode n)
public final boolean isMultiply(Function f)
public final boolean isArithmeticExpression(Node n)
true
if the given Node
is a FunctionNode
with the same Function
as returned from getAdd()
,
getSubtract()
, getMultiply()
or getDivide()
.OakGP Genetic Programming Framework