Next: Linear expressions of level 1, Previous: Variables and related operations, Up: Level 1 of the interface
Environments bind variables (of level 1) to dimensions (of level 0).
Internal datatype for environments.
For information, the definition is:
typedef struct ap_environment_t { ap_var_t* var_of_dim; /* Array of size intdim+realdim, indexed by dimensions. - It should not contain identical strings.. - Slice [0..intdim-1] is lexicographically sorted, and denotes integer variables. - Slice [intdim..intdim+realdim-1] is lexicographically sorted, and denotes real variables. - The memory allocated for the variables are attached to the structure (they are freed when the structure is no longer in use) */ size_t intdim; /* Number of integer variables */ size_t realdim;/* Number of real variables */ size_t count; /* For reference counting */ } ap_environment_t;
Respectively free and duplicate an environment.
(copy
is cheap, as environments are managed with reference
counters).
Print an environment under the form:
environment: dim = (..,..), count = .. 0: name0 1: name1 ...
Build an empty environment.
Build an environment from an array of integer and an array of real variables.
var_of_intdim is an array of variables of size intdim,
var_of_realdim is an array of variables of size
realdim. Pointers to arrays may be NULL
if their size is
0.
Variables are duplicated in the result, so it is the responsability of the user to free the variables he provides.
If some variables are duplicated, return NULL
.
Resp. add or remove new variables to an existing environment, with
a functional semantics. Same conventions as for
ap_environment_alloc
function apply. If the result is
non-sense (or in case of attempt to remove an unknwon variable),
return NULL
.
Convert a variable in its corresponding dimension in the environment env. If var is unknown in env, return AP_DIM_MAX
.
Return the variable associated to the dimension dim in the environment env. There is no bound check here.
The remaining functions are much less useful for normal user.
Resp. test the equality and the inclusion of two environments.
Return:
-2
if the environments are not compatible (a variable has a different type in the 2 environments);
-1
if env1 is a subset of (included in) env2;
0
if they are equal;
+1
if env1 is a superset of env2;
+2
otherwise: the least common environment exists and is a strict superset of both environments.
Return an hash code for an environment.
Compute the transformation for converting from an environment env1 to a superenvironment env. Return NULL if env is not a superenvironment.
Compute the transformation for switching from an environment env1 to an env2, by first adding (some) variables of env2, and then removing (some) variables of env1. Return NULL if env1 and env2 ar enot compatible environments.
Least common environment to two enviroenments.
ap_environment_is_eq(env1,env2)==false
*dimchange1==NULL
. Otherwise, the function allocates the
*dimchange1
with ap_dimchange_alloc
.
Least common environment to an array of environments.
*ptdimchange==NULL
.
Otherwise, compute in *ptdimchange
the conversion permutations
tenv[i]
, this implies that the
result is actually tenv[i]
. In this case,
(*ptdimchange)[i]==NULL
. Otherwise, the function allocates the
(*ptdimchange)[i]
with ap_dimchange_alloc
.
Rename the variables in the environment. size is the common
size of arrays tvar1 and tvar2, and perm is a
result-parameter pointing to an existing but not initialized
object of type ap_dimperm_t
.
The function applies the variable substitution tvar1[i]->tvar2[i]
to the environment, and returns the resulting environment and the
allocated transformation permutation in *perm
.
If the parameters are not valid, return NULL
with
perm->dim==NULL
.
Next: Linear expressions of level 1, Previous: Variables and related operations, Up: Level 1 of the interface