APRONXX  0.9.12
Protected Member Functions | Protected Attributes | List of all members
apron::environment Class Reference

Level 1 environment (ap_environment_t wrapper). More...

#include <apxx_environment.hh>

Inherits apron::use_malloc.

Public Member Functions

Constructors
 environment ()
 Creates a new empty environment. More...
 
 environment (const std::vector< var > &intdim, const std::vector< var > &realdim)
 Creates a new environment with given integer and real variable names (copied). More...
 
 environment (const var *intdim, size_t intdim_size, const var *realdim, size_t realdim_size)
 Creates a new environment with given integer and real variable names (copied). More...
 
 environment (const environment &x)
 Creates a copy (i.e., increments the reference counter). More...
 
Destructor
 ~environment ()
 Decrements the reference counter and, if null, actually frees the environment. More...
 
Assignment
const environmentoperator= (const environment &x)
 Assignment (reference counter manipulation). More...
 
Accesses
size_t intdim () const
 Returns the number of integer dimensions in the environment. More...
 
size_t realdim () const
 Returns the number of real dimensions in the environment. More...
 
bool contains (const var &x) const
 Whether the environment contains the variable name x. More...
 
ap_dim_t operator[] (const var &x) const
 Returns the dimension associated with the variable name. More...
 
const varoperator[] (ap_dim_t d) const
 Returns the variable name at a given dimension (no bound-check). More...
 
ap_dim_t get_dim (const var &x) const
 Returns the dimension associated with a variable name. More...
 
const varget_var (ap_dim_t d) const
 Returns the variable name at a given dimension (bound-checked). More...
 
std::vector< varget_vars () const
 Returns (a copy of) the full map from dimensions to variable names. More...
 
C API compatibility
const ap_environment_t * get_ap_environment_t () const
 Returns a pointer to the internal APRON object pointed by *this. More...
 
ap_environment_t * get_ap_environment_t ()
 Returns a pointer to the internal APRON object pointed by *this. More...
 
- Public Member Functions inherited from apron::use_malloc
void * operator new (size_t sz)
 
void * operator new[] (size_t sz)
 
void operator delete (void *p)
 
void operator delete[] (void *p)
 

Protected Member Functions

 environment (ap_environment_t *x)
 Used internally only. Wraps the APRON object in an environment object (no copy, no change in reference counter). More...
 

Protected Attributes

ap_environment_t * e
 

Friends

Tests
bool operator== (const environment &x, const environment &y)
 Equality testing. More...
 
bool operator!= (const environment &x, const environment &y)
 Disequality testing. More...
 
bool operator<= (const environment &x, const environment &y)
 Inclusion testing. More...
 
bool operator>= (const environment &x, const environment &y)
 Inclusion testing. More...
 
int cmp (const environment &x, const environment &y)
 Environment comparison. More...
 

Operations

environment lce (const environment &x, const environment &y)
 Returns the least common environment of two environments. More...
 
environment lce (const environment &x, const environment &y, dimchange &chgx, dimchange &chgy)
 Returns the least common environment of two environments. More...
 
environment lce (const std::vector< environment > &x)
 Returns the least common environment of a vector of environments. More...
 
environment lce (const environment *env, size_t env_size)
 Returns the least common environment of an array env of env_size environments. More...
 
environment lce (const std::vector< environment > &x, std::vector< dimchange > &chg)
 Returns the least common environment of a vector of environments. More...
 
environment lce (const environment *env, dimchange *chg, size_t env_size)
 Returns the least common environment of an array env of env_size environments. More...
 
dimchange get_dimchange (const environment &x, const environment &y)
 Returns the dimension change to transform an environment x into a super-environment y. More...
 
environment add (const std::vector< var > &intdim, const std::vector< var > &realdim) const
 Returns a copy of the environment with some integer and/or real variable names added. More...
 
environment add (const var *intdim, size_t intdim_size, const var *realdim, size_t realdim_size) const
 Returns a copy of the environment with intdim_size integer and realdim_size real variable names added. More...
 
environment add (const std::vector< var > &intdim, const std::vector< var > &realdim, dimperm &perm) const
 Returns a copy of the environment with some integer and/or real variable names added. More...
 
environment add (const var *intdim, size_t intdim_size, const var *realdim, size_t realdim_size, dimperm &perm) const
 Returns a copy of the environment with intdim_size integer and realdim_size real variable names added. More...
 
environment remove (const std::vector< var > &dims) const
 Returns a copy of the environment with some variable names removed. More...
 
environment remove (const var *dims, size_t dims_size) const
 Returns a copy of the environment with dims_size variable names removed. More...
 
environment rename (const std::vector< std::pair< var, var > > &dims) const
 Returns a copy of the environment with some variable names substituted. More...
 
environment rename (const var *before, const var *after, size_t dims_size) const
 Returns a copy of the environment with dims_size variable names substituted. More...
 
environment rename (const std::vector< std::pair< var, var > > &dims, dimperm &perm) const
 Returns a copy of the environment with some variable names substituted. More...
 
environment rename (const var *before, const var *after, size_t dims_size, dimperm &perm) const
 Returns a copy of the environment with dims_size variable names substituted. More...
 

Printing

std::ostream & operator<< (std::ostream &os, const environment &s)
 Printing. More...
 
void print (FILE *stream=stdout) const
 Prints to a C stream. More...
 

Detailed Description

Level 1 environment (ap_environment_t wrapper).

An environment associates dimensions to integer and real variable names (var). It stores a number intdim of integer dimensions, a number realdim of real dimensions, and an array of size intdim+realdim variable names indexed by dimensions. Dimensions 0 to intdim-1 are associated to integer variables while dimensions intdim to intdim+realdim-1 are associated to real variables. Variables in both slices [0;intdim-1] and [intdim;intdim+realdim-1] are always sorted in strictly increasing order. (Recall that variables have the following user-specified functions: copy, deallocation, comparison, conversion to string.) This invariant is automatically enforced by the library by performing dimension permutations after variable name addition, deletion, or renaming. Thus, such an operation can change the dimension associated to existing variable names.

Environments are reference-counted and the API is fully functional (i.e., functions do not change *this but return a new object instead).

Constructor & Destructor Documentation

◆ environment() [1/5]

apron::environment::environment ( ap_environment_t *  x)
inlineprotected

Used internally only. Wraps the APRON object in an environment object (no copy, no change in reference counter).

◆ environment() [2/5]

environment::environment ( )
inline

Creates a new empty environment.

◆ environment() [3/5]

environment::environment ( const std::vector< var > &  intdim,
const std::vector< var > &  realdim 
)
inline

Creates a new environment with given integer and real variable names (copied).

Exceptions
std::invalid_argumentif variable names are not distinct.

◆ environment() [4/5]

environment::environment ( const var intdim,
size_t  intdim_size,
const var realdim,
size_t  realdim_size 
)
inline

Creates a new environment with given integer and real variable names (copied).

Exceptions
std::invalid_argumentif variable names are not distinct.

◆ environment() [5/5]

environment::environment ( const environment x)
inline

Creates a copy (i.e., increments the reference counter).

◆ ~environment()

environment::~environment ( )
inline

Decrements the reference counter and, if null, actually frees the environment.

Member Function Documentation

◆ add() [1/4]

environment environment::add ( const std::vector< var > &  intdim,
const std::vector< var > &  realdim 
) const
inline

Returns a copy of the environment with some integer and/or real variable names added.

Exceptions
std::invalid_argumentif the resulting environment has duplicate variable names.

◆ add() [2/4]

environment environment::add ( const var intdim,
size_t  intdim_size,
const var realdim,
size_t  realdim_size 
) const
inline

Returns a copy of the environment with intdim_size integer and realdim_size real variable names added.

Exceptions
std::invalid_argumentif the resulting environment has duplicate variable names.

◆ add() [3/4]

environment environment::add ( const std::vector< var > &  intdim,
const std::vector< var > &  realdim,
dimperm perm 
) const
inline

Returns a copy of the environment with some integer and/or real variable names added.

Sets perm to the dimension permutation that has been performed after appending variable names at the end of integer (resp. real) dimensions to get them sorted again.

Exceptions
std::invalid_argumentif the resulting environment has duplicate variable names.

◆ add() [4/4]

environment environment::add ( const var intdim,
size_t  intdim_size,
const var realdim,
size_t  realdim_size,
dimperm perm 
) const
inline

Returns a copy of the environment with intdim_size integer and realdim_size real variable names added.

Sets perm to the dimension permutation that has been performed after appending variable names at the end of integer (resp. real) dimensions to get them sorted again.

Exceptions
std::invalid_argumentif the resulting environment has duplicate variable names.

◆ contains()

bool environment::contains ( const var x) const
inline

Whether the environment contains the variable name x.

◆ get_ap_environment_t() [1/2]

const ap_environment_t * environment::get_ap_environment_t ( ) const
inline

Returns a pointer to the internal APRON object pointed by *this.

◆ get_ap_environment_t() [2/2]

ap_environment_t * environment::get_ap_environment_t ( )
inline

Returns a pointer to the internal APRON object pointed by *this.

◆ get_dim()

ap_dim_t environment::get_dim ( const var x) const
inline

Returns the dimension associated with a variable name.

Exceptions
std::invalid_argumentif there is no such variable name in the environment.

◆ get_var()

const var & environment::get_var ( ap_dim_t  d) const
inline

Returns the variable name at a given dimension (bound-checked).

Exceptions
std::out_of_rangeif the dimension is larger than the environment size.

◆ get_vars()

std::vector< var > environment::get_vars ( ) const
inline

Returns (a copy of) the full map from dimensions to variable names.

◆ intdim()

size_t environment::intdim ( ) const
inline

Returns the number of integer dimensions in the environment.

◆ operator=()

const environment & environment::operator= ( const environment x)
inline

Assignment (reference counter manipulation).

◆ operator[]() [1/2]

ap_dim_t environment::operator[] ( const var x) const
inline

Returns the dimension associated with the variable name.

Exceptions
std::invalid_argumentif there is no such variable name in the environment.

◆ operator[]() [2/2]

const var & environment::operator[] ( ap_dim_t  d) const
inline

Returns the variable name at a given dimension (no bound-check).

◆ print()

void environment::print ( FILE *  stream = stdout) const
inline

Prints to a C stream.

◆ realdim()

size_t environment::realdim ( ) const
inline

Returns the number of real dimensions in the environment.

◆ remove() [1/2]

environment environment::remove ( const std::vector< var > &  dims) const
inline

Returns a copy of the environment with some variable names removed.

Exceptions
std::invalid_argumentif some variable name does not exist.

◆ remove() [2/2]

environment environment::remove ( const var dims,
size_t  dims_size 
) const
inline

Returns a copy of the environment with dims_size variable names removed.

Exceptions
std::invalid_argumentif some variable name does not exist.

◆ rename() [1/4]

environment environment::rename ( const std::vector< std::pair< var, var > > &  dims) const
inline

Returns a copy of the environment with some variable names substituted.

dims[i].first is replaced with dims[i].second.

Exceptions
std::invalid_argumentif some variable name does not exist.

◆ rename() [2/4]

environment environment::rename ( const var before,
const var after,
size_t  dims_size 
) const
inline

Returns a copy of the environment with dims_size variable names substituted.

before[i] is replaced with after[i]. Both array should contain dims_size elements.

Exceptions
std::invalid_argumentif some variable name does not exist.

◆ rename() [3/4]

environment environment::rename ( const std::vector< std::pair< var, var > > &  dims,
dimperm perm 
) const
inline

Returns a copy of the environment with some variable names substituted.

dims[i].first is replaced with dims[i].second. Sets perm to the dimension permutation that has been performed after renaming the variable names in-place to get them sorted again.

Exceptions
std::invalid_argumentif some variable name does not exist.

◆ rename() [4/4]

environment environment::rename ( const var before,
const var after,
size_t  dims_size,
dimperm perm 
) const
inline

Returns a copy of the environment with dims_size variable names substituted.

before[i] is replaced with after[i]. Both array should contain dims_size elements. Sets perm to the dimension permutation that has been performed after renaming the variable names in-place to get them sorted again.

Exceptions
std::invalid_argumentif some variable name does not exist.

Friends And Related Function Documentation

◆ cmp

int cmp ( const environment x,
const environment y 
)
friend

Environment comparison.

Returns
  • -2 if some variable name has different type in both environments
  • -1 if x is a sub-environment of y
  • 0 if x equals y
  • +1 if x is a super-environment of y
  • +2 if x and y a not comparable but there exists a lowest upper bound

◆ get_dimchange

dimchange get_dimchange ( const environment x,
const environment y 
)
friend

Returns the dimension change to transform an environment x into a super-environment y.

Exceptions
std::invalid_argumentif x is not a subset of y, or if x and chg have different size.

◆ lce [1/6]

environment lce ( const environment x,
const environment y 
)
friend

Returns the least common environment of two environments.

Exceptions
std::invalid_argumentif some variable name has different type in both environments

◆ lce [2/6]

environment lce ( const environment x,
const environment y,
dimchange chgx,
dimchange chgy 
)
friend

Returns the least common environment of two environments.

Sets chgx (resp. chgy) to the dimension transformation that has been performed after appending the required variable names to x (resp. y) to keep them sorted.

Exceptions
std::invalid_argumentif some variable name has different type in both environments

◆ lce [3/6]

environment lce ( const std::vector< environment > &  x)
friend

Returns the least common environment of a vector of environments.

Exceptions
std::invalid_argumentif some variable name has different type in different environments

◆ lce [4/6]

environment lce ( const environment env,
size_t  env_size 
)
friend

Returns the least common environment of an array env of env_size environments.

Exceptions
std::invalid_argumentif some variable name has different type in different environments

◆ lce [5/6]

environment lce ( const std::vector< environment > &  x,
std::vector< dimchange > &  chg 
)
friend

Returns the least common environment of a vector of environments.

Sets chg[i] to the dimension transformation that has been performed after appending the required variable names to x[i] to keep them sorted. chg must have space for at least env_size elements.

Exceptions
std::invalid_argumentif some variable name has different type in different environments

◆ lce [6/6]

environment lce ( const environment env,
dimchange chg,
size_t  env_size 
)
friend

Returns the least common environment of an array env of env_size environments.

Sets chg[i] to the dimension transformation that has been performed after appending the required variable names to x[i] to keep them sorted. chg must have space for at least env_size elements.

Exceptions
std::invalid_argumentif some variable name has different type in different environments

◆ operator!=

bool operator!= ( const environment x,
const environment y 
)
friend

Disequality testing.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const environment s 
)
friend

Printing.

◆ operator<=

bool operator<= ( const environment x,
const environment y 
)
friend

Inclusion testing.

◆ operator==

bool operator== ( const environment x,
const environment y 
)
friend

Equality testing.

◆ operator>=

bool operator>= ( const environment x,
const environment y 
)
friend

Inclusion testing.

Member Data Documentation

◆ e

ap_environment_t* apron::environment::e
protected

The documentation for this class was generated from the following files: