Interface FloatingPointFormulaManager
- All Known Implementing Classes:
AbstractFloatingPointFormulaManager,DebuggingFloatingPointFormulaManager
Most operations are overloaded: there is an option of either using the default rounding mode
(set via the option solver.floatingPointRoundingMode), or providing the rounding mode
explicitly.
If the result of an operation can not be exactly represented by the available floating-point type, i.e., the given precision is insufficient, the result is rounded to the nearest possible floating-point representation, depending on the given rounding mode.
Example: If the input number is too large to be represented as a floating point with the given type, it will be converted to positive infinity (+inf) or negative infinity (-inf). If the input number is too small to be represented with the given type (closer to zero than the smallest possible floating-point number), it will be converted to zero, with the sign preserved.
-
Method Summary
Modifier and TypeMethodDescriptionabs(FloatingPointFormula number) add(FloatingPointFormula number1, FloatingPointFormula number2) add(FloatingPointFormula number1, FloatingPointFormula number2, FloatingPointRoundingMode pFloatingPointRoundingMode) assignment(FloatingPointFormula number1, FloatingPointFormula number2) Create a term for assigning one floating-point term to another.castFrom(Formula source, boolean signed, FormulaType.FloatingPointType targetType) Build aFloatingPointFormulafrom another compatible formula.castFrom(Formula source, boolean signed, FormulaType.FloatingPointType targetType, FloatingPointRoundingMode pFloatingPointRoundingMode) Build aFloatingPointFormulafrom another compatible formula.<T extends Formula>
TcastTo(FloatingPointFormula source, boolean signed, FormulaType<T> targetType) Build a formula of compatible type from aFloatingPointFormula.<T extends Formula>
TcastTo(FloatingPointFormula source, boolean signed, FormulaType<T> targetType, FloatingPointRoundingMode pFloatingPointRoundingMode) Build a formula of compatible type from aFloatingPointFormula.divide(FloatingPointFormula number1, FloatingPointFormula number2) divide(FloatingPointFormula number1, FloatingPointFormula number2, FloatingPointRoundingMode pFloatingPointRoundingMode) equalWithFPSemantics(FloatingPointFormula number1, FloatingPointFormula number2) Create a term for comparing the equality of two floating-point terms, according to standard floating-point semantics (i.e., NaN != NaN).fromIeeeBitvector(BitvectorFormula number, FormulaType.FloatingPointType pTargetType) Create a formula that interprets the given bitvector as a floating-point value in the IEEE format, according to the given type.greaterOrEquals(FloatingPointFormula number1, FloatingPointFormula number2) greaterThan(FloatingPointFormula number1, FloatingPointFormula number2) isInfinity(FloatingPointFormula number) isNaN(FloatingPointFormula number) isNegative(FloatingPointFormula number) checks whether a formula is negative, including -0.0.isNormal(FloatingPointFormula number) isSubnormal(FloatingPointFormula number) isZero(FloatingPointFormula number) lessOrEquals(FloatingPointFormula number1, FloatingPointFormula number2) lessThan(FloatingPointFormula number1, FloatingPointFormula number2) makeNumber(double n, FormulaType.FloatingPointType type) Creates a floating point formula representing the given double value with the specified type.makeNumber(double n, FormulaType.FloatingPointType type, FloatingPointRoundingMode pFloatingPointRoundingMode) Creates a floating point formula representing the given double value with the specified type and rounding mode.Creates a floating point formula representing the given string value with the specified type.makeNumber(String n, FormulaType.FloatingPointType type, FloatingPointRoundingMode pFloatingPointRoundingMode) Creates a floating point formula representing the given string value with the specified type and rounding mode.Creates a floating point formula representing the given BigDecimal value with the specified type.makeNumber(BigDecimal n, FormulaType.FloatingPointType type, FloatingPointRoundingMode pFloatingPointRoundingMode) Creates a floating point formula representing the given BigDecimal value with the specified type and rounding mode.makeNumber(BigInteger exponent, BigInteger mantissa, boolean signBit, FormulaType.FloatingPointType type) Creates a floating point formula from the given exponent, mantissa, and sign bit with the specified type.Creates a floating point formula representing the given Rational value with the specified type.makeNumber(Rational n, FormulaType.FloatingPointType type, FloatingPointRoundingMode pFloatingPointRoundingMode) Creates a floating point formula representing the given Rational value with the specified type and rounding mode.makeVariable(String pVar, FormulaType.FloatingPointType type) Creates a variable with exactly the given name.max(FloatingPointFormula number1, FloatingPointFormula number2) min(FloatingPointFormula number1, FloatingPointFormula number2) multiply(FloatingPointFormula number1, FloatingPointFormula number2) multiply(FloatingPointFormula number1, FloatingPointFormula number2, FloatingPointRoundingMode pFloatingPointRoundingMode) negate(FloatingPointFormula number) remainder(FloatingPointFormula dividend, FloatingPointFormula divisor) remainder: x - y * n, where n in Z is nearest to x/y.round(FloatingPointFormula formula, FloatingPointRoundingMode roundingMode) sqrt(FloatingPointFormula number) sqrt(FloatingPointFormula number, FloatingPointRoundingMode roundingMode) subtract(FloatingPointFormula number1, FloatingPointFormula number2) subtract(FloatingPointFormula number1, FloatingPointFormula number2, FloatingPointRoundingMode pFloatingPointRoundingMode) toIeeeBitvector(FloatingPointFormula number) Create a formula that produces a representation of the given floating-point value as a bitvector conforming to the IEEE format.
-
Method Details
-
makeNumber
Creates a floating point formula representing the given double value with the specified type. -
makeNumber
FloatingPointFormula makeNumber(double n, FormulaType.FloatingPointType type, FloatingPointRoundingMode pFloatingPointRoundingMode) Creates a floating point formula representing the given double value with the specified type and rounding mode. -
makeNumber
Creates a floating point formula representing the given BigDecimal value with the specified type. -
makeNumber
FloatingPointFormula makeNumber(BigDecimal n, FormulaType.FloatingPointType type, FloatingPointRoundingMode pFloatingPointRoundingMode) Creates a floating point formula representing the given BigDecimal value with the specified type and rounding mode. -
makeNumber
Creates a floating point formula representing the given string value with the specified type. -
makeNumber
FloatingPointFormula makeNumber(String n, FormulaType.FloatingPointType type, FloatingPointRoundingMode pFloatingPointRoundingMode) Creates a floating point formula representing the given string value with the specified type and rounding mode. -
makeNumber
Creates a floating point formula representing the given Rational value with the specified type. -
makeNumber
FloatingPointFormula makeNumber(Rational n, FormulaType.FloatingPointType type, FloatingPointRoundingMode pFloatingPointRoundingMode) Creates a floating point formula representing the given Rational value with the specified type and rounding mode. -
makeNumber
FloatingPointFormula makeNumber(BigInteger exponent, BigInteger mantissa, boolean signBit, FormulaType.FloatingPointType type) Creates a floating point formula from the given exponent, mantissa, and sign bit with the specified type.- Parameters:
exponent- the exponent part of the floating point numbermantissa- the mantissa part of the floating point numbersignBit- the sign bit of the floating point number, e.g., true for negative numbers
-
makeVariable
Creates a variable with exactly the given name.Please make sure that the given name is valid in SMT-LIB2. Take a look at
FormulaManager.isValidName(java.lang.String)for further information.This method does not quote or unquote the given name, but uses the plain name "AS IS".
Formula.toString()can return a different String than the given one. -
makePlusInfinity
-
makeMinusInfinity
-
makeNaN
-
castTo
<T extends Formula> T castTo(FloatingPointFormula source, boolean signed, FormulaType<T> targetType) Build a formula of compatible type from aFloatingPointFormula. This method uses the default rounding mode.Compatible formula types are all numeral types and (signed/unsigned) bitvector types. It is also possible to cast a floating-point number into another floating-point type. We do not support casting from boolean or array types. We try to keep an exact representation, however fall back to rounding if needed.
- Parameters:
source- the source formula of floating-point typesigned- if aBitvectorFormulais given as target, we additionally use this flag. Otherwise, we ignore it.targetType- the type of the resulting formula- Throws:
IllegalArgumentException- if an incompatible type is used, e.g. aFloatingPointFormulacannot be cast toBooleanFormula.
-
castTo
<T extends Formula> T castTo(FloatingPointFormula source, boolean signed, FormulaType<T> targetType, FloatingPointRoundingMode pFloatingPointRoundingMode) Build a formula of compatible type from aFloatingPointFormula.Compatible formula types are all numeral types and (signed/unsigned) bitvector types. It is also possible to cast a floating-point number into another floating-point type. We do not support casting from boolean or array types. We try to keep an exact representation, however fall back to rounding if needed.
- Parameters:
source- the source formula of floating-point typesigned- if aBitvectorFormulais given as target, we additionally use this flag. Otherwise, we ignore it.targetType- the type of the resulting formulapFloatingPointRoundingMode- if rounding is needed, we apply the rounding mode.- Throws:
IllegalArgumentException- if an incompatible type is used, e.g. aFloatingPointFormulacannot be cast toBooleanFormula.
-
castFrom
FloatingPointFormula castFrom(Formula source, boolean signed, FormulaType.FloatingPointType targetType) Build aFloatingPointFormulafrom another compatible formula. This method uses the default rounding mode.Compatible formula types are all numeral types and (signed/unsigned) bitvector types. It is also possible to cast a floating-point number into another floating-point type. We do not support casting from boolean or array types. We try to keep an exact representation, however fall back to rounding if needed.
- Parameters:
source- the source formula of compatible typesigned- if aBitvectorFormulais given as source, we additionally use this flag. Otherwise, we ignore it.targetType- the type of the resulting formula- Throws:
IllegalArgumentException- if an incompatible type is used, e.g. aBooleanFormulacannot be cast toFloatingPointFormula.
-
castFrom
FloatingPointFormula castFrom(Formula source, boolean signed, FormulaType.FloatingPointType targetType, FloatingPointRoundingMode pFloatingPointRoundingMode) Build aFloatingPointFormulafrom another compatible formula.Compatible formula types are all numeral types and (signed/unsigned) bitvector types. It is also possible to cast a floating-point number into another floating-point type. We do not support casting from boolean or array types. We try to keep an exact representation, however fall back to rounding if needed.
- Parameters:
source- the source formula of compatible typesigned- if aBitvectorFormulais given as source, we additionally use this flag. Otherwise, we ignore it.targetType- the type of the resulting formulapFloatingPointRoundingMode- if rounding is needed, we apply the rounding mode.- Throws:
IllegalArgumentException- if an incompatible type is used, e.g. aBooleanFormulacannot be cast toFloatingPointFormula.
-
fromIeeeBitvector
FloatingPointFormula fromIeeeBitvector(BitvectorFormula number, FormulaType.FloatingPointType pTargetType) Create a formula that interprets the given bitvector as a floating-point value in the IEEE format, according to the given type. The sum of the sizes of exponent and mantissa of the target type plus 1 (for the sign bit) needs to be equal to the size of the bitvector.Note: This method will return a value that is (numerically) far away from the original value. This method is completely different from
castFrom(org.sosy_lab.java_smt.api.Formula, boolean, org.sosy_lab.java_smt.api.FormulaType.FloatingPointType), which will produce a floating-point value close to the numeral value. -
toIeeeBitvector
Create a formula that produces a representation of the given floating-point value as a bitvector conforming to the IEEE format. The size of the resulting bitvector is the sum of the sizes of the exponent and mantissa of the input formula plus 1 (for the sign bit). -
round
-
negate
-
abs
-
max
-
min
-
sqrt
-
sqrt
-
add
-
add
FloatingPointFormula add(FloatingPointFormula number1, FloatingPointFormula number2, FloatingPointRoundingMode pFloatingPointRoundingMode) -
subtract
-
subtract
FloatingPointFormula subtract(FloatingPointFormula number1, FloatingPointFormula number2, FloatingPointRoundingMode pFloatingPointRoundingMode) -
divide
-
divide
FloatingPointFormula divide(FloatingPointFormula number1, FloatingPointFormula number2, FloatingPointRoundingMode pFloatingPointRoundingMode) -
multiply
-
multiply
FloatingPointFormula multiply(FloatingPointFormula number1, FloatingPointFormula number2, FloatingPointRoundingMode pFloatingPointRoundingMode) -
remainder
remainder: x - y * n, where n in Z is nearest to x/y. The result can be negative even for two positive arguments, e.g. "rem(5, 4) == 1" and "rem(5, 6) == -1", as opposed to integer modulo operators. -
assignment
Create a term for assigning one floating-point term to another. This means both terms are considered equal afterwards. This method is the same as the methodequalfor other theories. -
equalWithFPSemantics
Create a term for comparing the equality of two floating-point terms, according to standard floating-point semantics (i.e., NaN != NaN). Be careful to not use this method when you really needassignment(FloatingPointFormula, FloatingPointFormula). -
greaterThan
-
greaterOrEquals
-
lessThan
-
lessOrEquals
-
isNaN
-
isInfinity
-
isZero
-
isNormal
-
isSubnormal
-
isNegative
checks whether a formula is negative, including -0.0.
-