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

Level 0 arbitrary expression tree (ap_texpr0_t wrapper). More...

#include <apxx_texpr0.hh>

Inherits apron::use_malloc.

Classes

class  builder
 Temporary expression nodes used when constructing a texpr0. More...
 
class  const_iterator
 Iterators to traverse a constant expression tree. More...
 
class  iterator
 Iterators to traverse and mutate an expression tree. More...
 

Public Member Functions

Constructors
 texpr0 (const builder &x)
 Makes an expression tree from a temporary (performing a deep copy). More...
 
 texpr0 (const texpr0 &x)
 Makes a (deep) copy of the expression tree. More...
 
 texpr0 (const const_iterator &x)
 Makes a (deep) copy of the expression tree. More...
 
 texpr0 (const linexpr0 &l)
 Makes an expression tree from a linear expression (copying coefficients). More...
 
 texpr0 (const texpr0 &x, const dimchange &d, bool add=true)
 Makes a (deep) copy of the expression, and then add or remove some dimensions. More...
 
 texpr0 (const texpr0 &x, const dimperm &d)
 Makes a (deep) copy of the expression, and then permutes dimensions. More...
 
 texpr0 (const texpr0 &x, ap_dim_t dim, const texpr0 &dst)
 Makes a (deep) copy of x and substitutes each occurrence of dim with (a fresh copy of) dst. More...
 
Destructor
 ~texpr0 ()
 Frees the memory occupied by the expression (and, recursively, all sub-expressions). More...
 
Assignments
texpr0operator= (const texpr0 &x)
 Makes a (deep) copy of the expression. More...
 
texpr0operator= (const const_iterator &x)
 Makes a (deep) copy of the expression. More...
 
texpr0operator= (const builder &x)
 Assigns from a temporary expression, performing a deep copy and deleting the previous value of *this. More...
 
texpr0operator= (const linexpr0 &x)
 Makes *this equal to the linear expression x (coefficients are copied), deleting the previous value of *this. More...
 
Iterators
const_iterator root () const
 Returns a new iterator at the root of a constant expression tree. More...
 
iterator root ()
 Returns a new iterator at the root of a mutable expression tree. More...
 
Tests, size, dimensions
bool equal (const texpr0 &x) const
 Whether two expressions are syntactically, structurally equal. More...
 
bool is_zero () const
 Whether the expression is a single coefficient node with 0 value. More...
 
size_t depth () const
 Returns the depth of the expression tree (counting only operator nodes). More...
 
size_t size () const
 Returns the number of operator nodes in the expression tree. More...
 
ap_dim_t max_dim () const
 Returns the maximal dimension occurring in the expression (or 0 if there is no variable). More...
 
bool has_dim (ap_dim_t d) const
 Whether the given dimension occurs in the expression. More...
 
std::vector< ap_dim_t > dimlist () const
 Returns a list of all dimensions occurring in the expression (in strict increasing order) More...
 
bool is_interval_cst () const
 Whether the expression is constant (i.e., has no dimension leaves). More...
 
bool is_interval_linear () const
 Whether the expression is linear and there is no rounding. More...
 
bool is_interval_polynomial () const
 Whether the expression is polynomial and there is no rounding. More...
 
bool is_interval_polyfrac () const
 Whether the expression is a polynomial fraction and there is no rounding. More...
 
bool is_scalar () const
 Whether all occurring constants are scalar. More...
 
Operations
void substitute (ap_dim_t dim, const texpr0 &dst)
 Substitutes each occurrence of dim with (a fresh copy of) dst. More...
 
long hash () const
 Returns a hash code. More...
 
Changes of dimension
void add_dimensions (const dimchange &d)
 Adds some dimensions, shifting dimension if needed. More...
 
void remove_dimensions (const dimchange &d)
 Removes some dimensions, shifting dimension if needed. More...
 
void permute_dimensions (const dimperm &d)
 Permutes dimensions. More...
 
C API compatibility
ap_texpr0_t * get_ap_texpr0_t ()
 Returns a pointer to the internal APRON object stored in *this. More...
 
const ap_texpr0_t * get_ap_texpr0_t () const
 Returns a pointer to the internal APRON object stored in *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

 texpr0 (ap_texpr0_t *x)
 Internal use only. Shallow copy. More...
 
void init_from (ap_texpr0_t *x)
 Internal use only. Shallow copy. More...
 

Protected Attributes

ap_texpr0_t l
 Structure managed by APRON. More...
 

Printing

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

Detailed Description

Level 0 arbitrary expression tree (ap_texpr0_t wrapper).

A texpr0 represents an expression tree. Leaves include dimensions (i.e., variables by index) as well as constants (coefficients). Binary operators include addition, subtraction, multiplication, division, and modulo. Unary operators include opposite, square root, and typecast. Additionally, all operators are tagged with a destination type: perfect integers, reals, or floating-point numbers (of various bit-size). For integer and floating-point operators, a rounding direction can be specified (as well as 'any direction'). The concrete semantics of all operators is to first perform the operation on perfect reals (typecast being the identity operator here), and then round the result to the destination type in the specified direction.

A texpr0 manages a whole expression tree: assignment, copy, and destruction are deep (recursive).

Complex expression trees can be constructed using the standard +, -, *, /, % operators, as well as functions such as add, mul, div, etc. (allowing to set the destination type and rounding direction).

texpr0 x = dim(1) + dim(2) * 5;
texpr0 y = add(sqrt(x), x, AP_RTYPE_FLOAT);

Temporaries created by the operators have the texpr0::builder type. See the texpr0::builder class documentation for the details on operator arguments.

Expression trees can be visited and/or modified using the texpr0::iterator type.

Constructor & Destructor Documentation

◆ texpr0() [1/8]

texpr0::texpr0 ( ap_texpr0_t *  x)
inlineprotected

Internal use only. Shallow copy.

◆ texpr0() [2/8]

texpr0::texpr0 ( const builder x)
inline

Makes an expression tree from a temporary (performing a deep copy).

A deep copy is performed so that, after the assignment, temporaries can be safely destroyed and we have a private copy of all formerly aliased sub-trees.

◆ texpr0() [3/8]

texpr0::texpr0 ( const texpr0 x)
inline

Makes a (deep) copy of the expression tree.

◆ texpr0() [4/8]

texpr0::texpr0 ( const const_iterator x)
inline

Makes a (deep) copy of the expression tree.

◆ texpr0() [5/8]

texpr0::texpr0 ( const linexpr0 l)
inline

Makes an expression tree from a linear expression (copying coefficients).

Real-valued addition and multiplication operators are used (i.e., no rounding).

◆ texpr0() [6/8]

apron::texpr0::texpr0 ( const texpr0 x,
const dimchange d,
bool  add = true 
)
inline

Makes a (deep) copy of the expression, and then add or remove some dimensions.

  • add whether to add or remove dimensions.

◆ texpr0() [7/8]

texpr0::texpr0 ( const texpr0 x,
const dimperm d 
)
inline

Makes a (deep) copy of the expression, and then permutes dimensions.

◆ texpr0() [8/8]

texpr0::texpr0 ( const texpr0 x,
ap_dim_t  dim,
const texpr0 dst 
)
inline

Makes a (deep) copy of x and substitutes each occurrence of dim with (a fresh copy of) dst.

◆ ~texpr0()

texpr0::~texpr0 ( )
inline

Frees the memory occupied by the expression (and, recursively, all sub-expressions).

Member Function Documentation

◆ add_dimensions()

void texpr0::add_dimensions ( const dimchange d)
inline

Adds some dimensions, shifting dimension if needed.

◆ depth()

size_t texpr0::depth ( ) const
inline

Returns the depth of the expression tree (counting only operator nodes).

◆ dimlist()

std::vector< ap_dim_t > texpr0::dimlist ( ) const
inline

Returns a list of all dimensions occurring in the expression (in strict increasing order)

◆ equal()

bool texpr0::equal ( const texpr0 x) const
inline

Whether two expressions are syntactically, structurally equal.

◆ get_ap_texpr0_t() [1/2]

ap_texpr0_t * texpr0::get_ap_texpr0_t ( )
inline

Returns a pointer to the internal APRON object stored in *this.

◆ get_ap_texpr0_t() [2/2]

const ap_texpr0_t * texpr0::get_ap_texpr0_t ( ) const
inline

Returns a pointer to the internal APRON object stored in *this.

◆ has_dim()

bool texpr0::has_dim ( ap_dim_t  d) const
inline

Whether the given dimension occurs in the expression.

◆ hash()

long texpr0::hash ( ) const
inline

Returns a hash code.

◆ init_from()

void texpr0::init_from ( ap_texpr0_t *  x)
inlineprotected

Internal use only. Shallow copy.

◆ is_interval_cst()

bool texpr0::is_interval_cst ( ) const
inline

Whether the expression is constant (i.e., has no dimension leaves).

◆ is_interval_linear()

bool texpr0::is_interval_linear ( ) const
inline

Whether the expression is linear and there is no rounding.

◆ is_interval_polyfrac()

bool texpr0::is_interval_polyfrac ( ) const
inline

Whether the expression is a polynomial fraction and there is no rounding.

◆ is_interval_polynomial()

bool texpr0::is_interval_polynomial ( ) const
inline

Whether the expression is polynomial and there is no rounding.

◆ is_scalar()

bool texpr0::is_scalar ( ) const
inline

Whether all occurring constants are scalar.

◆ is_zero()

bool texpr0::is_zero ( ) const
inline

Whether the expression is a single coefficient node with 0 value.

◆ max_dim()

ap_dim_t texpr0::max_dim ( ) const
inline

Returns the maximal dimension occurring in the expression (or 0 if there is no variable).

◆ operator=() [1/4]

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

Makes a (deep) copy of the expression.

◆ operator=() [2/4]

texpr0 & texpr0::operator= ( const const_iterator x)
inline

Makes a (deep) copy of the expression.

◆ operator=() [3/4]

texpr0 & texpr0::operator= ( const builder x)
inline

Assigns from a temporary expression, performing a deep copy and deleting the previous value of *this.

◆ operator=() [4/4]

texpr0 & texpr0::operator= ( const linexpr0 x)
inline

Makes *this equal to the linear expression x (coefficients are copied), deleting the previous value of *this.

Real-valued addition and multiplication operators are used (i.e., no rounding).

◆ permute_dimensions()

void texpr0::permute_dimensions ( const dimperm d)
inline

Permutes dimensions.

◆ print()

void texpr0::print ( char **  name_of_dim = NULL,
FILE *  stream = stdout 
) const
inline

Prints to a C stream.

◆ remove_dimensions()

void texpr0::remove_dimensions ( const dimchange d)
inline

Removes some dimensions, shifting dimension if needed.

Nodes corresponding to deleted dimensions are replaced with ]-oo;+oo[.

◆ root() [1/2]

texpr0::const_iterator texpr0::root ( ) const
inline

Returns a new iterator at the root of a constant expression tree.

◆ root() [2/2]

texpr0::iterator texpr0::root ( )
inline

Returns a new iterator at the root of a mutable expression tree.

◆ size()

size_t texpr0::size ( ) const
inline

Returns the number of operator nodes in the expression tree.

◆ substitute()

void texpr0::substitute ( ap_dim_t  dim,
const texpr0 dst 
)
inline

Substitutes each occurrence of dim with (a fresh copy of) dst.

Friends And Related Function Documentation

◆ operator<<

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

Printing.

Variable naming can be configured through the varname stream modifier.

Member Data Documentation

◆ l

ap_texpr0_t apron::texpr0::l
protected

Structure managed by APRON.


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