[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Linear expressions of level 0 (‘ap_linexpr0.h’)

datatype: ap_linexpr_discr_t
 
typedef enum ap_linexpr_discr_t {
  LINEXPR_DENSE,
  LINEXPR_SPARSE
} ap_linexpr_discr_t;

Type of representation of linear expressions: either dense or sparse.

datatype: ap_linexpr0_t

Type of interval linear expressions. Coefficients in such expressions are of type coeff_t.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Allocating linear expressions of level 0

Function: ap_linexpr0_t* ap_linexpr0_alloc (ap_linexpr_discr_t lin_discr, size_t size);

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.

Function: void ap_linexpr0_realloc (ap_linexpr0_t* e, size_t size)

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.

Function: void ap_linexpr0_minimize (ap_linexpr0_t* e)

Reduce the coefficients (transform intervals into scalars when possible). In case of sparse representation, also remove zero coefficients.

Function: void ap_linexpr0_free (ap_linexpr0_t* e);

Deallocate the linear expression.

Function: ap_linexpr0_t* ap_linexpr0_copy (ap_linexpr0_t* e)

Duplication.

Function: void ap_linexpr0_fprint (FILE* stream, ap_linexpr0_t* e, char** name_of_dim);

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,....


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Tests on linear expressions of level 0

Function: bool ap_linexpr0_is_integer (ap_linexpr0_t* e, size_t intdim)

Does the expression depends only on integer variables ? assuming that the first intdim dimensions are integer.

Function: bool ap_linexpr0_is_real (ap_linexpr0_t* e, size_t intdim)

Does the expression depends only on real variables ? assuming that the first intdim dimensions are integer .

Function: bool ap_linexpr0_is_linear (ap_linexpr0_t* e)

Return true iff all involved coefficients are scalars.

Function: bool ap_linexpr0_is_quasilinear (ap_linexpr0_t* e)

Return true iff all involved coefficients but the constant are scalars.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Access to linear expressions of level 0

Function: size_t ap_linexpr0_size (ap_linexpr0_t* e)

Get the size of the linear expression


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Getting references

Function: ap_coefft* ap_linexpr0_cstref (ap_linexpr0_t* e)

Get a reference to the constant. Do not free it.

Function: ap_coefft* ap_linexpr0_coeffref (ap_linexpr0_t* e, ap_dim_t dim)

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:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Getting values

Function: void ap_linexpr0_get_cst (ap_coefft* coeff, ap_linexpr0_t* e)

Assign to coeff the constant coefficient of e.

Function: bool ap_linexpr0_get_coeff (ap_coefft* coeff, ap_linexpr0_t* e, ap_dim_t dim)

Assign to coeff the coefficient of dimension dim in the expression e.

Return true in case ap_linexpr0_coeffref(e,dim) returns NULL.

Macro: ap_linexpr0_ForeachLinterm (ap_linexpr0_t* e, size_t i, ap_dim_t dim, ap_coeff_t* coeff)

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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Assigning values with a list of arguments

datatype: ap_coefftag_t
 
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.

Function: bool ap_linexpr0_set_list (ap_linexpr0_t* e, ...)

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);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Assigning values

Function: void ap_linexpr0_set_cst (ap_linexpr0_t* e, ap_coefft* coeff)
Function: void ap_linexpr0_set_cst_scalar (ap_linexpr0_t* e, ap_scalar_t* scalar)
Function: void ap_linexpr0_set_cst_scalar_int (ap_linexpr0_t* e, int num)
Function: void ap_linexpr0_set_cst_scalar_frac (ap_linexpr0_t* e, int num, unsigned int den)
Function: void ap_linexpr0_set_cst_scalar_double (ap_linexpr0_t* e, double num)
Function: void ap_linexpr0_set_cst_interval (ap_linexpr0_t* e, ap_interval_t* itv)
Function: void ap_linexpr0_set_cst_interval_scalar (ap_linexpr0_t* e, ap_scalar_t* inf, ap_scalar_t* sup)
Function: void ap_linexpr0_set_cst_interval_int (ap_linexpr0_t* e, int inf, int sup)
Function: void ap_linexpr0_set_cst_interval_frac (ap_linexpr0_t* e, int numinf, unsigned int deninf, int numsup, unsigned int densup)
Function: void ap_linexpr0_set_cst_interval_double (ap_linexpr0_t* e, double inf, double sup)

Set the constant coefficient of expression e.

Function: bool ap_linexpr0_set_coeff (ap_linexpr0_t* e, ap_dim_t dim, ap_coefft* coeff)
Function: bool ap_linexpr0_set_coeff_scalar (ap_linexpr0_t* e, ap_dim_t dim, ap_scalar_t* scalar)
Function: bool ap_linexpr0_set_coeff_scalar_int (ap_linexpr0_t* e, ap_dim_t dim, int num)
Function: bool ap_linexpr0_set_coeff_scalar_frac (ap_linexpr0_t* e, ap_dim_t dim, int num, unsigned int den)
Function: bool ap_linexpr0_set_coeff_scalar_double (ap_linexpr0_t* e, ap_dim_t dim, double num)
Function: bool ap_linexpr0_set_coeff_interval (ap_linexpr0_t* e, ap_dim_t dim, ap_interval_t* itv)
Function: bool ap_linexpr0_set_coeff_interval_scalar (ap_linexpr0_t* e, ap_dim_t dim, ap_scalar_t* inf, ap_scalar_t* sup)
Function: bool ap_linexpr0_set_coeff_interval_int (ap_linexpr0_t* e, ap_dim_t dim, int inf, int sup)
Function: bool ap_linexpr0_set_coeff_interval_frac (ap_linexpr0_t* e, ap_dim_t dim, int numinf, unsigned int deninf, int numsup, unsigned int densup)
Function: void ap_linexpr0_set_coeff_interval_double (ap_linexpr0_t* e, ap_dim_t dim, double inf, double sup)

Set the coefficient of the dimension dim of expression e.

Return true in case ap_linexpr0_coeffref(e,dim) returns NULL.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Change of dimensions and permutations of linear expressions of level 0

Function: void ap_linexpr0_add_dimensions_with (ap_linexpr0_t* e, ap_dimchange_t* dimchange)
Function: ap_linexpr0_t* ap_linexpr0_add_dimensions (ap_linexpr0_t* e, ap_dimchange_t* dimchange)

These two functions add dimensions to the expressions, following the semantics of dimchange (see the type definition of ap_dimchange_t).

Function: void ap_linexpr0_permute_dimensions_with (ap_linexpr0_t* e, ap_dimperm_t* perm)
Function: ap_linexpr0_t* ap_linexpr0_permute_dimensions (ap_linexpr0_t* e, ap_dimperm_t* perm)

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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Other functions on linear expressions of level 0

All these functions induces a reduction of the coefficients of the linear expression.

Function: int ap_linexpr0_hash (ap_linexpr0_t* e)

Return a hash code.

Function: bool ap_linexpr0_equal (ap_linexpr0_t* e1, ap_linexpr0_t* e2)

Equality test.

Function: int ap_linexpr0_compare (ap_linexpr0_t* e1, ap_linexpr0_t* e2)

Lexicographic ordering, terminating by constant coefficients.

Use the (partial order) comparison function on coefficients coeff_cmp.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by root on September 20, 2019 using texi2html 1.82.