public abstract class UnaryOperation extends Expression
UnaryOperation
is an Expression
which
represents a mathematical unary operation (positive sign, negative sign or
a FunctionCall
) of another Expression
(the operand).Modifier and Type | Field and Description |
---|---|
protected Expression |
operand
This
UnaryOperation's operand. |
protected int |
type
The operation type of this
UnaryOperation . |
Constructor and Description |
---|
UnaryOperation(int type,
int pri)
Creates a new
UnaryOperation with the operation type
type and the evaluation priority pri . |
UnaryOperation(int type,
int pri,
Expression op)
Creates a new
UnaryOperation with the operation type
type , the evaluation priority pri and the
operand op . |
Modifier and Type | Method and Description |
---|---|
Expression |
dissolveFunctionCalls()
Inserts the arguments of any FunctionCall in the expression-tree-hierarchy
into the appropriate function definitions and replaces the FunctionCalls
by that new Expressions.
|
boolean |
equals(Object o)
Returns
true if the specified Object is a
UnaryOperation of the same operation type and with an equal
operand, false otherwise. |
void |
getEssentialVariables(Collection c)
Adds the names of the
Variables which are essential for
evaluation into the specified Collection . |
Evaluator |
getEvaluator(Type defaultType,
Context context)
Returns the
Evaluator for this UnaryOperation . |
Expression |
getOperand()
Returns the operand of this
UnaryOperation or
null if there is no operand defined yet. |
int |
getPriority()
Returns the evaluation priority of this
UnaryOperation . |
int |
getType()
Returns the operation type of this
UnaryOperation . |
boolean |
isComplete()
Returns
true if the operand of this
UnaryOperation is not null and also complete,
false otherwise. |
boolean |
isConstant()
Returns
true if the operand of this
UnaryOperation is not null and also constant,
false if not. |
Expression |
replaceSymbol(Symbol s,
Expression expr)
Replaces all Symbols equal to s in this UnaryOperation
with the specified Expression.
|
void |
setOperand(Expression op)
Sets the operand of this
UnaryOperation to the specified
Expression . |
String |
toString()
Returns a
String representing this
UnaryOperation . |
differentiate, differentiate, getEssentialVariables, simplify
protected Expression operand
UnaryOperation's
operand.protected int type
UnaryOperation
.getType()
public UnaryOperation(int type, int pri)
UnaryOperation
with the operation type
type
and the evaluation priority pri
.
The operand of this UnaryOperation
will be
null
until you call the method setOperand(Expression)
. Use the other constructor, if
the operand is already known.type
- the operation type this UnaryOperation
will
represent.pri
- the evaluation priority this UnaryOperation
will
have.public UnaryOperation(int type, int pri, Expression op)
UnaryOperation
with the operation type
type
, the evaluation priority pri
and the
operand op
. Use the other constructor if the operand is
not known.type
- the operation type this UnaryOperation
will
represent.pri
- the evaluation priority this UnaryOperation
will
have.op
- the operand for this UnaryOperation
.public Expression dissolveFunctionCalls()
Expression
dissolveFunctionCalls
in class Expression
Function.insertArguments(Expression)
public boolean equals(Object o)
true
if the specified Object
is a
UnaryOperation
of the same operation type and with an equal
operand, false
otherwise.public void getEssentialVariables(Collection c)
Variables
which are essential for
evaluation into the specified Collection
. Therefor it gets the
essential Variables
of the operand of this
UnaryOperation
.getEssentialVariables
in class Expression
c
- the Collection
the Variable
names
will be added to.public Evaluator getEvaluator(Type defaultType, Context context)
Evaluator
for this UnaryOperation
.
Type defaultType
specifies, how to deal with
Symbols
in the expression-tree-hirarchy (evaluate any
Symbol
as a Complex
or a Real
or
whatever?). It has nothing to do with getType()
.getEvaluator
in class Expression
defaultType
- the Type
any Symbol
will be
evaluated to.context
- the Context
, the Evaluators for
the Symbols
are getting from.
Evaluator
for this UnaryOperation
.Evaluator.getReturnType()
,
Context.getEvaluator(Symbol)
public Expression getOperand()
UnaryOperation
or
null
if there is no operand defined yet. Define the
operand with the appropriate constructor or with the method
setOperand(Expression)
.UnaryOperation
.public int getPriority()
UnaryOperation
.getPriority
in class Expression
UnaryOperation
.Parser.parse()
,
Expression.getEvaluator(Type,Context)
public int getType()
UnaryOperation
.
It's the ASCII-code of the following characters representing the
appropriate operation:UnaryOperation
.public boolean isComplete()
true
if the operand of this
UnaryOperation
is not null and also complete,
false
otherwise.isComplete
in class Expression
true
if the operand of this
UnaryOperation
is not null and also complete,
false
otherwise.public boolean isConstant()
true
if the operand of this
UnaryOperation
is not null and also constant,
false
if not.isConstant
in class Expression
true
if the operand of this
UnaryOperation
is not null and also constant,
false
if not.public Expression replaceSymbol(Symbol s, Expression expr)
replaceSymbol
in class Expression
s
- the Symbol to be replace.expr
- the Expression for replacement.Symbol.replaceSymbol(Symbol,Expression)
public void setOperand(Expression op)
UnaryOperation
to the specified
Expression
.op
- the new operand for this UnaryOperation
.