APRONXX 0.9.15
apron::linexpr0 Class Reference

Level 0 linear expression (ap_linexpr0_t wrapper). More...

#include <apxx_linexpr0.hh>

Inherits apron::use_malloc.

Classes

class  const_iterator
 Iterator to traverse a constant linexpr0. More...
 
class  iterator
 Iterator to traverse and mutate a linear expression. More...
 

Public Member Functions

Constructors
 linexpr0 (ap_linexpr_discr_t discr=AP_LINEXPR_SPARSE, size_t size=0)
 Creates a new expression.
 
 linexpr0 (const linexpr0 &x)
 Makes a (deep) copy.
 
 linexpr0 (const linexpr0 &x, const dimchange &d)
 Makes a (deep) copy, and adds some dimensions (shifting coefficients if needed).
 
 linexpr0 (const linexpr0 &x, const dimperm &d)
 Makes a (deep) copy, and applies a permutation on coefficients.
 
 linexpr0 (size_t size, const coeff coeffs[], const coeff &cst, ap_linexpr_discr_t discr=AP_LINEXPR_SPARSE)
 Makes a new linear expression with the given size and coefficients (copied).
 
 linexpr0 (const std::vector< coeff > &coeffs, const coeff &cst, ap_linexpr_discr_t discr=AP_LINEXPR_SPARSE)
 Makes a new linear expression with the given coefficients (copied).
 
 linexpr0 (size_t size, const coeff coeffs[], const ap_dim_t dims[], const coeff &cst)
 Makes a new linear expression with the given size and coefficients (copied).
 
Destructor
 ~linexpr0 ()
 Frees all space for the expression and coefficients.
 
Assignment
linexpr0operator= (const linexpr0 &x)
 Makes a (deep) copy.
 
Dimension operations
void resize (size_t size)
 Changes the number of coefficients in the expression. (Useful only for dense expressions.)
 
void add_dimensions (const dimchange &d)
 Adds some dimensions, shifting coefficients if needed.
 
void permute_dimensions (const dimperm &d)
 Applies a permutation on coefficients.
 
Accesses, size
size_t size () const
 Returns the number of coefficients in the expression.
 
ap_linexpr_discr_t get_discr () const
 Returns the expression type.
 
coeffget_cst ()
 Returns a (modifiable) reference to the constant coefficient.
 
const coeffget_cst () const
 Returns a reference to the constant coefficient.
 
coeffoperator[] (ap_dim_t dim)
 Returns a (modifiable) reference to the coefficient corresponding to the given dimension.
 
const coeffoperator[] (ap_dim_t dim) const
 Returns a reference to the coefficient corresponding to the given dimension.
 
Iterator
iterator begin ()
 Returns a new iterator to traverse and mutate the linear expression.
 
const_iterator begin () const
 Returns a new constant iterator to traverse the linear expression.
 
Operators
void minimize ()
 Minimizes all coefficients.
 
long hash () const
 Returns a hash-code.
 
C API compatibility
const ap_linexpr0_t * get_ap_linexpr0_t () const
 Returns a pointer to the internal APRON object stored in *this.
 
ap_linexpr0_t * get_ap_linexpr0_t ()
 Returns a pointer to the internal APRON object stored in *this.
 
- 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

 linexpr0 (ap_linexpr0_t *p)
 Internal use only. Shallow copy of structure followed by a free to take ownership of expression.
 

Protected Attributes

ap_linexpr0_t l
 Structure managed by APRON.
 

Printing

void print (char **name_of_dim=NULL, FILE *stream=stdout) const
 Prints to a C stream.
 

Tests

bool is_integer (size_t intdim) const
 Whether only dimensions greater than intdim have a non-zero coefficient.
 
bool is_real (size_t intdim) const
 Whether only dimensions strictly smaller than intdim have a non-zero coefficient.
 
ap_linexpr_type_t get_type () const
 Gets the type of the linear expression.
 
bool is_linear () const
 Whether all coefficients are scalar.
 
bool is_quasilinear () const
 Whether all coefficients are scalar, except maybe the constant one.
 

Detailed Description

Level 0 linear expression (ap_linexpr0_t wrapper).

A linexpr0 object represents a linear expression with scalar or interval coefficients (coeff). They have a constant coefficient, plus a coefficient for each represented dimension. An expression can be either sparse (AP_LINEXPR_SPARSE) or dense (AP_LINEXPR_DENSE). Dense expressions use an array of coefficients to represent dimensions from 0 up to the expression size. Sparse expressions can have 'holes' between coefficients and grow automatically when a coefficient for a non-existing dimension is accessed.

Constructor & Destructor Documentation

◆ linexpr0() [1/8]

linexpr0::linexpr0 ( ap_linexpr0_t * p)
inlineprotected

Internal use only. Shallow copy of structure followed by a free to take ownership of expression.

◆ linexpr0() [2/8]

linexpr0::linexpr0 ( ap_linexpr_discr_t discr = AP_LINEXPR_SPARSE,
size_t size = 0 )
inline

Creates a new expression.

  • discr whether the expression is sparse (AP_LINEXPR_SPARSE) or dense (AP_LINEXPR_DENSE).
  • size is the initial number of dimensions.

◆ linexpr0() [3/8]

linexpr0::linexpr0 ( const linexpr0 & x)
inline

Makes a (deep) copy.

◆ linexpr0() [4/8]

linexpr0::linexpr0 ( const linexpr0 & x,
const dimchange & d )
inline

Makes a (deep) copy, and adds some dimensions (shifting coefficients if needed).

◆ linexpr0() [5/8]

linexpr0::linexpr0 ( const linexpr0 & x,
const dimperm & d )
inline

Makes a (deep) copy, and applies a permutation on coefficients.

◆ linexpr0() [6/8]

linexpr0::linexpr0 ( size_t size,
const coeff coeffs[],
const coeff & cst,
ap_linexpr_discr_t discr = AP_LINEXPR_SPARSE )
inline

Makes a new linear expression with the given size and coefficients (copied).

  • discr whether the expression is sparse (AP_LINEXPR_SPARSE) or dense (AP_LINEXPR_DENSE).
  • coeffs has size size, coeffs[i] corresponds to the coefficient for dimension i.
  • cst corresponds to the constant coefficient.

◆ linexpr0() [7/8]

linexpr0::linexpr0 ( const std::vector< coeff > & coeffs,
const coeff & cst,
ap_linexpr_discr_t discr = AP_LINEXPR_SPARSE )
inline

Makes a new linear expression with the given coefficients (copied).

  • discr whether the expression is sparse (AP_LINEXPR_SPARSE) or dense (AP_LINEXPR_DENSE).
  • coeffs vector of coefficients, coeffs[i] corresponds to the coefficient for dimension i.
  • cst corresponds to the constant coefficient.

◆ linexpr0() [8/8]

linexpr0::linexpr0 ( size_t size,
const coeff coeffs[],
const ap_dim_t dims[],
const coeff & cst )
inline

Makes a new linear expression with the given size and coefficients (copied).

The expression is always sparse.

  • coeffs has size size, coeffs[i] corresponds to the coefficient for dimension dims[i];
  • dims is a list of size dimensions (sorted in increasing order)
  • cst corresponds to the constant coefficient.

◆ ~linexpr0()

linexpr0::~linexpr0 ( )
inline

Frees all space for the expression and coefficients.

Member Function Documentation

◆ add_dimensions()

void linexpr0::add_dimensions ( const dimchange & d)
inline

Adds some dimensions, shifting coefficients if needed.

◆ begin() [1/2]

linexpr0::iterator linexpr0::begin ( )
inline

Returns a new iterator to traverse and mutate the linear expression.

◆ begin() [2/2]

linexpr0::const_iterator linexpr0::begin ( ) const
inline

Returns a new constant iterator to traverse the linear expression.

◆ get_ap_linexpr0_t() [1/2]

ap_linexpr0_t * linexpr0::get_ap_linexpr0_t ( )
inline

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

◆ get_ap_linexpr0_t() [2/2]

const ap_linexpr0_t * linexpr0::get_ap_linexpr0_t ( ) const
inline

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

◆ get_cst() [1/2]

coeff & linexpr0::get_cst ( )
inline

Returns a (modifiable) reference to the constant coefficient.

◆ get_cst() [2/2]

const coeff & linexpr0::get_cst ( ) const
inline

Returns a reference to the constant coefficient.

◆ get_discr()

ap_linexpr_discr_t linexpr0::get_discr ( ) const
inline

Returns the expression type.

Returns
Either AP_LINEXPR_SPARSE or AP_LINEXPR_DENSE.

◆ get_type()

ap_linexpr_type_t linexpr0::get_type ( ) const
inline

Gets the type of the linear expression.

Returns
Either AP_LINEXPR_INTLINEAR (coefficients are interval), AP_LINEXPR_QUASILINEAR (coefficients are scalar except the constant one), or AP_LINEXPR_LINEAR (all coefficients are scalar).

◆ hash()

long linexpr0::hash ( ) const
inline

Returns a hash-code.

◆ is_integer()

bool linexpr0::is_integer ( size_t intdim) const
inline

Whether only dimensions greater than intdim have a non-zero coefficient.

◆ is_linear()

bool linexpr0::is_linear ( ) const
inline

Whether all coefficients are scalar.

◆ is_quasilinear()

bool linexpr0::is_quasilinear ( ) const
inline

Whether all coefficients are scalar, except maybe the constant one.

◆ is_real()

bool linexpr0::is_real ( size_t intdim) const
inline

Whether only dimensions strictly smaller than intdim have a non-zero coefficient.

◆ minimize()

void linexpr0::minimize ( )
inline

Minimizes all coefficients.

In sparse expressions, also remove zero and unused (hole) coefficients to save space.

◆ operator=()

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

Makes a (deep) copy.

◆ operator[]() [1/2]

coeff & linexpr0::operator[] ( ap_dim_t dim)
inline

Returns a (modifiable) reference to the coefficient corresponding to the given dimension.

Always succeeds if the expression is sparse: if the dimension has no coefficient yet, it is created and returned (linear time in the worst case).

Exceptions
std::out_of_rangeif the expression is dense and the dimension exceeds the size of the expression.
Warning
as a side-effect, the method renders previous references to coefficients within the same expression invalid. For instance,
l.get_coeff(0) = l.get_coeff(1) = 0;
ap_linexpr0_t l
Structure managed by APRON.
Definition apxx_linexpr0.hh:48
is invalid.

◆ operator[]() [2/2]

const coeff & linexpr0::operator[] ( ap_dim_t dim) const
inline

Returns a reference to the coefficient corresponding to the given dimension.

◆ permute_dimensions()

void linexpr0::permute_dimensions ( const dimperm & d)
inline

Applies a permutation on coefficients.

◆ print()

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

Prints to a C stream.

◆ resize()

void linexpr0::resize ( size_t size)
inline

Changes the number of coefficients in the expression. (Useful only for dense expressions.)

◆ size()

size_t linexpr0::size ( ) const
inline

Returns the number of coefficients in the expression.

Member Data Documentation

◆ l

ap_linexpr0_t apron::linexpr0::l
protected

Structure managed by APRON.


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