Next: Linear constraints of level 0, Previous: Dimensions and related operations, Up: Level 0 of the interface
typedef enum ap_linexpr_discr_t { LINEXPR_DENSE, LINEXPR_SPARSE } ap_linexpr_discr_t;
Type of representation of linear expressions: either dense or sparse.
Type of interval linear expressions. Coefficients in such expressions
are of type coeff_t
.
Next: Tests on linear expressions of level 0, Previous: Linear expressions of level 0, Up: Linear expressions of level 0
Allocate a linear expressions with coefficients by default of type
SCALAR and DOUBLE. If sparse representation, corresponding new
dimensions are initialized with AP_DIM_MAX
.
Change the dimensions of the array in e. If new coefficients
are added, their type is of type SCALAR and DOUBLE. If sparse
representation, corresponding new dimensions are initialized with
AP_DIM_MAX
.
Reduce the coefficients (transform intervals into scalars when possible). In case of sparse representation, also remove zero coefficients.
Deallocate the linear expression.
Duplication.
Print the linear expression on stream stream, using the array
name_of_dim to convert dimensions to variable names. If
name_of_dim is NULL
, the dimensions are named
x0,x1,...
.
Next: Access to linear expressions of level 0, Previous: Allocating linear expressions of level 0, Up: Linear expressions of level 0
Does the expression depends only on integer variables ? assuming that the first intdim dimensions are integer.
Does the expression depends only on real variables ? assuming that the first intdim dimensions are integer .
Return true iff all involved coefficients are scalars.
Return true iff all involved coefficients but the constant are scalars.
Next: Change of dimensions and permutations of linear expressions of level 0, Previous: Tests on linear expressions of level 0, Up: Linear expressions of level 0
Get the size of the linear expression
Get a reference to the constant. Do not free it.
Get a reference to the coefficient associated to the dimension dim in expression e.
Do not free it. In case of sparse representation, possibly induce the addition of a new linear term.
Return NULL if:
dim>=e->size
.
dim==AP_DIM_MAX
.
Assign to coeff the constant coefficient of e.
Assign to coeff the coefficient of dimension dim in the expression e.
Return true in case ap_linexpr0_coeffref(e,dim)
returns NULL.
Iterator on the coefficients associated to dimensions.
ap_linexpr0_ForeachLinterm(E,I,DIM,COEFF){ body }
executes the body for each pair (coeff,dim) in the
expression e. coeff is a reference to the coefficient
associated to dimension dim in e. i is an
auxiliary variable used internally by the macro.
typedef enum ap_coefftag_t { AP_COEFF, /* waiting for a coeff_t* object and a dimension */ AP_COEFF_S, /* waiting for a scalar_t* object and a dimension */ AP_COEFF_S_MPQ, /* waiting for a mpq_t object and a dimension */ AP_COEFF_S_INT, /* waiting for a int object and a dimension */ AP_COEFF_S_FRAC, /* waiting for 2 int objects and a dimension */ AP_COEFF_S_DOUBLE, /* waiting for a double object and a dimension */ AP_COEFF_I, /* waiting for a interval_t* object and a dimension */ AP_COEFF_I_SCALAR, /* waiting for 2 scalar_t* objects and a dimension */ AP_COEFF_I_MPQ, /* waiting for 2 mpq_t objects and a dimension */ AP_COEFF_I_INT, /* waiting for 2 int objects and a dimension */ AP_COEFF_I_FRAC, /* waiting for 4 int objects and a dimension */ AP_COEFF_I_DOUBLE, /* waiting for 2 double objects and a dimension */ AP_CST, /* waiting for a coeff_t* object */ AP_CST_S, /* waiting for a scalar_t* object */ AP_CST_S_MPQ, /* waiting for a mpq_t object */ AP_CST_S_INT, /* waiting for a int object */ AP_CST_S_FRAC, /* waiting for 2 int objects */ AP_CST_S_DOUBLE, /* waiting for a double object */ AP_CST_I, /* waiting for a interval_t* object */ AP_CST_I_SCALAR, /* waiting for 2 scalar_t* objects */ AP_CST_I_MPQ, /* waiting for 2 mpq_t objects */ AP_CST_I_INT, /* waiting for 2 int objects */ AP_CST_I_FRAC, /* waiting for 4 int objects */ AP_CST_I_DOUBLE, /* waiting for 2 double objects */ AP_END /* indicating end of the list */ } ap_coefftag_t;
Tags for ap_linexpr0_set_list
function.
This function assign the linear expression E from a list of
tags of type ap_coefftag_t
, each followed by a number of
arguments as specified in the definition of the tye
ap_coefftag_t
. The list should end with the tag
AP_COEFF_END
.
Return true
in case ap_linexpr0_coeffref(e,dim)
returns NULL for one of the dimensions involved.
Here is a typical example:
ap_linexpr0_set_list(e, AP_COEFF_S_INT, 3, 0, AP_COEFF_S_FRAC, 3,2, 1, AP_COEFF_S_DOUBLE, 4.1, 2, AP_CST_I_DOUBLE, -2.4, 3.6, AP_END); /* Do not forget the last tatg ! */
which transforms an null expression into 3 x0 + 3/2 x1 + 4.1 x2 + [-2.4,3.6]
and is equivalent to:
ap_linexpr0_set_coeff_scalar_int(e,0, 3); ap_linexpr0_set_coeff_scalar_frac(e,1, 3,2); ap_linexpr0_set_coeff_scalar_double(e,2, 4.1); ap_linexpr0_set_cst_interval_double(e, -2.4, 3.6);
Set the constant coefficient of expression e.
Set the coefficient of the dimension dim of expression e.
Return true
in case ap_linexpr0_coeffref(e,dim)
returns NULL.
Next: Other functions on linear expressions of level 0, Previous: Access to linear expressions of level 0, Up: Linear expressions of level 0
These two functions add dimensions to the expressions, following
the semantics of dimchange (see the type definition of ap_dimchange_t
).
These two functions apply the given permutation to the dimensions
of e. If dense representation, the size of the permutation
should be e->size
. If sparse representation, the
dimensions present in the expression should just be less
than the size of the permutation.
Previous: Change of dimensions and permutations of linear expressions of level 0, Up: Linear expressions of level 0
All these functions induces a reduction of the coefficients of the linear expression.
Return a hash code.
Equality test.
Lexicographic ordering, terminating by constant coefficients.
Use the (partial order) comparison function on coefficients
coeff_cmp
.