Next: Tree constraints of level 1, Previous: Generators of level 1, Up: Level 1 of the interface
We manipulate here general expressions described by the grammar
expr ::= cst | var | unop e | e1 binop e2
Such tree expressions generalize linear expressions(see Linear expressions of level 1) in two ways:
• Datatypes for tree expressions of level 1 | ||
• Constructors/Destructors for tree expressions of level 1 | ||
• Tests on tree expressions of level 1 | ||
• Operations on tree expressions of level 1 |
Next: Constructors/Destructors for tree expressions of level 1, Previous: Tree expressions of level 1, Up: Tree expressions of level 1
Type of tree expressions.
Tree expressions of level 1 are created as objects of type
ap_texpr1_t*
. They are manipulated in a functional way (except
a few operations), unlike linear expressions on which most operations
acts by side-effects.
Operators (actually defined in ap_texpr0.h)
typedef enum ap_texpr_op_t { /* Binary operators */ AP_TEXPR_ADD, AP_TEXPR_SUB, AP_TEXPR_MUL, AP_TEXPR_DIV, AP_TEXPR_MOD, /* either integer or real, no rounding */ /* Unary operators */ AP_TEXPR_NEG /* no rounding */, AP_TEXPR_CAST, AP_TEXPR_SQRT, } ap_texpr_op_t;
Destination type of the operation for rounding (actually defined in ap_texpr0.h)
typedef enum ap_texpr_rtype_t { AP_RTYPE_REAL, /* real (no rounding) */ AP_RTYPE_INT, /* integer */ AP_RTYPE_SINGLE, /* IEEE 754 32-bit single precision, e.g.: C's float */ AP_RTYPE_DOUBLE, /* IEEE 754 64-bit double precision, e.g.: C's double */ AP_RTYPE_EXTENDED, /* non-standard 80-bit double extended, e.g.: Intel's long double */ AP_RTYPE_QUAD, /* non-standard 128-bit quadruple precision, e.g.: Motorola's long double */ } ap_texpr_rtype_t;
Rounding mode (actually defined in ap_texpr0.h)
typedef enum ap_texpr_rdir_t { AP_RDIR_NEAREST /* Nearest */ AP_RDIR_ZERO /* Zero (truncation for integers) */ AP_RDIR_UP /* + Infinity */ AP_RDIR_DOWN /* - Infinity */ AP_RDIR_RND, /* All possible mode, non deterministically */ AP_RDIR_SIZE /* Not to be used ! */ } ap_texpr_rdir_t;
Next: Tests on tree expressions of level 1, Previous: Datatypes for tree expressions of level 1, Up: Tree expressions of level 1
Parameters of constructors are not memory-managed by the constructed
expression, with the important exception of expressions parameters
(type ap_texpr1.h
) are, which means that they should not be
freed afterwards.
Create a constant expression, on the environment env.
Create a variable expression. Return NULL
in the case var
is unknown in env.
Create an expression from an operator and expression operand(s). Be aware that opA and opB are memroy-managed by the result upon return.
(Deep) copy of a tree expression.
Creation from a linear expression.
Free (recursively) a tree expression.
Print the expression
Next: Operations on tree expressions of level 1, Previous: Constructors/Destructors for tree expressions of level 1, Up: Tree expressions of level 1
Structural (recursive) equality
Return true if variable var appears in the expression.
The next functions classifies tree expressions.
No variable, only constant leaves
Linear with possibly interval coefficients, no rounding
Polynomial with possibly interval coefficients, no rounding
Polynomial fraction with possibly interval coefficients, no rounding
All coefficients are scalar (non-interval)
Previous: Tests on tree expressions of level 1, Up: Tree expressions of level 1
Substitute every occurence of variable var with a copy of dst. Return NULL in case of incorrect argument (w.r.t. var and/or environment compatibility).
Change current environment with a super-environment. Return NULL if
nenv is not a superenvironment of e->env
.
Side-effect versions of the previous functions. Return true
instead of NULL
in case of problem.
Previous: Tests on tree expressions of level 1, Up: Tree expressions of level 1