- All Known Subinterfaces:
IdealFactory
public interface NumericExpressionFactory
A NumericExpressionFactory provides all of the functionality needed to create
and manipulate expressions of numeric type. For example, it must provide
methods to instantiate new numeric expression instances, to add, subtract,
multiply, and divide numeric expressions, etc. A general ExpressionFactory
will use one or more NumericExpressionFactorys by delegating out all
numerical operations to it.
Different implementations of NumericExpressionFactory can deal with
arithmetic issues in different ways, e.g., by treating real types as the
mathematical reals or as finite-precision floating point numbers, and so on.
-
Method Summary
Modifier and TypeMethodDescriptionadd(NumericExpression arg0, NumericExpression arg1) Returns a symbolic expression which is the result of adding arg1 from arg0.Returns the boolean expression factory used by this numeric expression factory.cast(NumericExpression numericExpression, SymbolicType newType) Returns a NumericExpression with the symbolic type passed in the second argumentceil(NumericExpression expr) Returns a comparator on all numeric expressions that are controlled by this factorydivide(NumericExpression arg0, NumericExpression arg1) Returns a symbolic expression which is the result of dividing arg0 by arg1.equals(NumericExpression arg0, NumericExpression arg1) Returns a BooleanExpression with the result of the equals operation on 2 NumericExpressionsexpand(NumericExpression expr) expression(SymbolicExpression.SymbolicOperator operator, SymbolicType numericType, SymbolicObject... arguments) Returns an expression, given the operator, type, and array of argumentsextractNumber(NumericExpression expression) Attempts to interpret the given symbolic expression as a concrete number.floor(NumericExpression expr) voidinit()Initialize this numeric expression factory.lessThan(NumericExpression arg0, NumericExpression arg1) Returns a BooleanExpression with the result of the lessThan operation on 2 NumericExpressionslessThanEquals(NumericExpression arg0, NumericExpression arg1) Returns a BooleanExpression with the result of the lessThanEquals operation on 2 NumericExpressionsmax(List<NumericExpression> exprs) Returns a NumericExpression which is equivalent to the maximum of all NumericExpressions in exprs.min(List<NumericExpression> exprs) Returns a NumericExpression which is equivalent to the minimum of all NumericExpressions in exprs.minus(NumericExpression arg) Returns a symbolic expression which is the negative of the given numerical expression.modulo(NumericExpression arg0, NumericExpression arg1) Returns a symbolic expression which represents arg0 modulo arg1.multiply(NumericExpression arg0, NumericExpression arg1) Returns a symbolic expression which is the result of multiplying the two given symbolic exprssions.neq(NumericExpression arg0, NumericExpression arg1) Returns a BooleanExpression with the result of the notEquals operation on 2 NumericExpressionsnotLessThan(NumericExpression arg0, NumericExpression arg1) Returns a BooleanExpression with the result of the notLessThan operation on 2 NumericExpressionsnotLessThanEquals(NumericExpression arg0, NumericExpression arg1) Returns a BooleanExpression with the result of the notLessThanEquals operation on 2 NumericExpressionsnumber(int value) number(NumberObject numberObject) Returns the number factory used by this numeric factory.Returns the object factory used by this numeric factory.oneInt()Returns a symbolic expression of integer type with the value of 1oneReal()Returns a symbolic expression of real type with the value of 1power(NumericExpression base, NumericExpression exponent) General power operator: e^b.power(NumericExpression base, NumberObject exponent) Concrete power operator: e^b, where b is aNumberObjectwith a concrete non-negative integer value.roundToZero(NumericExpression expr) subtract(NumericExpression arg0, NumericExpression arg1) Returns a symbolic expression which is the result of subtracting arg1 and arg0.symbolicConstant(StringObject name, SymbolicType type) Returns the type factory used by this numeric expression factory.zeroInt()Returns a symbolic expression of integer type with the value of 0zeroReal()Returns a symbolic expression of real type with the value of 0
-
Method Details
-
init
void init()Initialize this numeric expression factory. This factory should not be used until it has been initialized. Pre-conditions: the boolean factory, object factory, and type factory have alrady been initialized. -
booleanFactory
BooleanExpressionFactory booleanFactory()Returns the boolean expression factory used by this numeric expression factory. The boolean factory is needed to produce relational expressions such as "xinvalid input: '<'y".- Returns:
- the boolean expression factory used by this factory
-
numberFactory
NumberFactory numberFactory()Returns the number factory used by this numeric factory.- Returns:
- the number factory
-
objectFactory
ObjectFactory objectFactory()Returns the object factory used by this numeric factory.- Returns:
- the object factory
-
typeFactory
SymbolicTypeFactory typeFactory()Returns the type factory used by this numeric expression factory.- Returns:
- the type factory
-
comparator
Comparator<NumericExpression> comparator()Returns a comparator on all numeric expressions that are controlled by this factory- Returns:
- a comparator on numeric expressions
-
number
-
number
-
symbolicConstant
-
expression
NumericExpression expression(SymbolicExpression.SymbolicOperator operator, SymbolicType numericType, SymbolicObject... arguments) Returns an expression, given the operator, type, and array of arguments- Parameters:
operator- A SymbolicOperatornumericType- A SymbolicTypearguments- array of arguments- Returns:
- Returns a NumericExpression
-
zeroInt
NumericExpression zeroInt()Returns a symbolic expression of integer type with the value of 0- Returns:
-
zeroReal
NumericExpression zeroReal()Returns a symbolic expression of real type with the value of 0- Returns:
-
oneInt
NumericExpression oneInt()Returns a symbolic expression of integer type with the value of 1- Returns:
-
oneReal
NumericExpression oneReal()Returns a symbolic expression of real type with the value of 1- Returns:
-
add
Returns a symbolic expression which is the result of adding arg1 from arg0. The two given expressions must have the same (numeric) type: either both integers, or both real.- Parameters:
arg0- a symbolic expression of a numeric typearg1- a symbolic expression of the same numeric type- Returns:
- arg0+arg1
-
subtract
Returns a symbolic expression which is the result of subtracting arg1 and arg0. The two given expressions must have the same (numeric) type: either both integers, or both real.- Parameters:
arg0- a symbolic expression of a numeric typearg1- a symbolic expression of the same numeric type- Returns:
- arg0-arg1
-
multiply
Returns a symbolic expression which is the result of multiplying the two given symbolic exprssions. The two given expressions must have the same (numeric) type: either both integers, or both real.- Parameters:
arg0- a symbolic expression of a numeric typearg1- a symbolic expression of the same numeric type- Returns:
- arg0 * arg1, the product of arg0 and arg1.
-
divide
Returns a symbolic expression which is the result of dividing arg0 by arg1. The two given expressions must have the same (numeric) type: either both integers, or both real. In the integer case, division is interpreted as "integer division", which rounds towards 0.- Parameters:
arg0- a symbolic expression of a numeric typearg1- a symbolic expression of the same numeric type- Returns:
- arg0 / arg1
-
modulo
Returns a symbolic expression which represents arg0 modulo arg1. The two given expressions must have the integer type. What happens for negative integers is unspecified.- Parameters:
arg0- a symbolic expression of integer typearg1- a symbolic expression of integer type- Returns:
- arg0 % arg1
-
minus
Returns a symbolic expression which is the negative of the given numerical expression. The given expression must be non-null and have either integer or real type.- Parameters:
arg- a symbolic expression of integer or real type- Returns:
- -arg
-
power
Concrete power operator: e^b, where b is aNumberObjectwith a concrete non-negative integer value. This method might actually multiply out the expression, i.e., it does not necessarily return an expression with operator POWER.- Parameters:
base- the base expression in the power expressionexponent- a non-negative concreteNumberObjectexponent
-
power
General power operator: e^b. Both e and b are numeric expressions.- Parameters:
base- the base expression in the power expressionexponent- the exponent in the power expression
-
min
Returns a NumericExpression which is equivalent to the minimum of all NumericExpressions in exprs.- Parameters:
exprs- the NumericExpressions we want the minimum of.
-
max
Returns a NumericExpression which is equivalent to the maximum of all NumericExpressions in exprs.- Parameters:
exprs- the NumericExpressions we want the maximum of.
-
cast
Returns a NumericExpression with the symbolic type passed in the second argument- Parameters:
numericExpression- The NumericExpression that will receive the new typenewType- The new SymbolicType for the numericExpression- Returns:
- NumericExpression
-
extractNumber
Attempts to interpret the given symbolic expression as a concrete number. If this is not possible, returns null. -
lessThan
Returns a BooleanExpression with the result of the lessThan operation on 2 NumericExpressions -
lessThanEquals
Returns a BooleanExpression with the result of the lessThanEquals operation on 2 NumericExpressions -
notLessThan
Returns a BooleanExpression with the result of the notLessThan operation on 2 NumericExpressions -
notLessThanEquals
Returns a BooleanExpression with the result of the notLessThanEquals operation on 2 NumericExpressions -
equals
Returns a BooleanExpression with the result of the equals operation on 2 NumericExpressions -
neq
Returns a BooleanExpression with the result of the notEquals operation on 2 NumericExpressions -
expand
-
floor
-
ceil
-
roundToZero
-