PPL
1.2
|
A grid. More...
#include <ppl.hh>
Public Types | |
typedef Coefficient | coefficient_type |
The numeric type of coefficients. | |
Public Member Functions | |
Grid (dimension_type num_dimensions=0, Degenerate_Element kind=UNIVERSE) | |
Builds a grid having the specified properties. More... | |
Grid (const Congruence_System &cgs) | |
Builds a grid, copying a system of congruences. More... | |
Grid (Congruence_System &cgs, Recycle_Input dummy) | |
Builds a grid, recycling a system of congruences. More... | |
Grid (const Constraint_System &cs) | |
Builds a grid, copying a system of constraints. More... | |
Grid (Constraint_System &cs, Recycle_Input dummy) | |
Builds a grid, recycling a system of constraints. More... | |
Grid (const Grid_Generator_System &ggs) | |
Builds a grid, copying a system of grid generators. More... | |
Grid (Grid_Generator_System &ggs, Recycle_Input dummy) | |
Builds a grid, recycling a system of grid generators. More... | |
template<typename Interval > | |
Grid (const Box< Interval > &box, Complexity_Class complexity=ANY_COMPLEXITY) | |
Builds a grid out of a box. More... | |
template<typename U > | |
Grid (const BD_Shape< U > &bd, Complexity_Class complexity=ANY_COMPLEXITY) | |
Builds a grid out of a bounded-difference shape. More... | |
template<typename U > | |
Grid (const Octagonal_Shape< U > &os, Complexity_Class complexity=ANY_COMPLEXITY) | |
Builds a grid out of an octagonal shape. More... | |
Grid (const Polyhedron &ph, Complexity_Class complexity=ANY_COMPLEXITY) | |
Builds a grid from a polyhedron using algorithms whose complexity does not exceed the one specified by complexity . If complexity is ANY_COMPLEXITY , then the grid built is the smallest one containing ph . More... | |
Grid (const Grid &y, Complexity_Class complexity=ANY_COMPLEXITY) | |
Ordinary copy constructor. More... | |
Grid & | operator= (const Grid &y) |
The assignment operator. (*this and y can be dimension-incompatible.) | |
Member Functions that Do Not Modify the Grid | |
dimension_type | space_dimension () const |
Returns the dimension of the vector space enclosing *this . | |
dimension_type | affine_dimension () const |
Returns ![]() *this is empty; otherwise, returns the affine dimension of *this . | |
Constraint_System | constraints () const |
Returns a system of equality constraints satisfied by *this with the same affine dimension as *this . | |
Constraint_System | minimized_constraints () const |
Returns a minimal system of equality constraints satisfied by *this with the same affine dimension as *this . | |
const Congruence_System & | congruences () const |
Returns the system of congruences. | |
const Congruence_System & | minimized_congruences () const |
Returns the system of congruences in minimal form. | |
const Grid_Generator_System & | grid_generators () const |
Returns the system of generators. | |
const Grid_Generator_System & | minimized_grid_generators () const |
Returns the minimized system of generators. | |
Poly_Con_Relation | relation_with (const Congruence &cg) const |
Returns the relations holding between *this and cg . | |
Poly_Gen_Relation | relation_with (const Grid_Generator &g) const |
Returns the relations holding between *this and g . | |
Poly_Gen_Relation | relation_with (const Generator &g) const |
Returns the relations holding between *this and g . | |
Poly_Con_Relation | relation_with (const Constraint &c) const |
Returns the relations holding between *this and c . | |
bool | is_empty () const |
Returns true if and only if *this is an empty grid. | |
bool | is_universe () const |
Returns true if and only if *this is a universe grid. | |
bool | is_topologically_closed () const |
Returns true if and only if *this is a topologically closed subset of the vector space. More... | |
bool | is_disjoint_from (const Grid &y) const |
Returns true if and only if *this and y are disjoint. More... | |
bool | is_discrete () const |
Returns true if and only if *this is discrete. More... | |
bool | is_bounded () const |
Returns true if and only if *this is bounded. | |
bool | contains_integer_point () const |
Returns true if and only if *this contains at least one integer point. | |
bool | constrains (Variable var) const |
Returns true if and only if var is constrained in *this . More... | |
bool | bounds_from_above (const Linear_Expression &expr) const |
Returns true if and only if expr is bounded in *this . More... | |
bool | bounds_from_below (const Linear_Expression &expr) const |
Returns true if and only if expr is bounded in *this . More... | |
bool | maximize (const Linear_Expression &expr, Coefficient &sup_n, Coefficient &sup_d, bool &maximum) const |
Returns true if and only if *this is not empty and expr is bounded from above in *this , in which case the supremum value is computed. More... | |
bool | maximize (const Linear_Expression &expr, Coefficient &sup_n, Coefficient &sup_d, bool &maximum, Generator &point) const |
Returns true if and only if *this is not empty and expr is bounded from above in *this , in which case the supremum value and a point where expr reaches it are computed. More... | |
bool | minimize (const Linear_Expression &expr, Coefficient &inf_n, Coefficient &inf_d, bool &minimum) const |
Returns true if and only if *this is not empty and expr is bounded from below in *this , in which case the infimum value is computed. More... | |
bool | minimize (const Linear_Expression &expr, Coefficient &inf_n, Coefficient &inf_d, bool &minimum, Generator &point) const |
Returns true if and only if *this is not empty and expr is bounded from below in *this , in which case the infimum value and a point where expr reaches it are computed. More... | |
bool | frequency (const Linear_Expression &expr, Coefficient &freq_n, Coefficient &freq_d, Coefficient &val_n, Coefficient &val_d) const |
Returns true if and only if *this is not empty and frequency for *this with respect to expr is defined, in which case the frequency and the value for expr that is closest to zero are computed. More... | |
bool | contains (const Grid &y) const |
Returns true if and only if *this contains y . More... | |
bool | strictly_contains (const Grid &y) const |
Returns true if and only if *this strictly contains y . More... | |
bool | OK (bool check_not_empty=false) const |
Checks if all the invariants are satisfied. More... | |
Space Dimension Preserving Member Functions that May Modify the Grid | |
void | add_congruence (const Congruence &cg) |
Adds a copy of congruence cg to *this . More... | |
void | add_grid_generator (const Grid_Generator &g) |
Adds a copy of grid generator g to the system of generators of *this . More... | |
void | add_congruences (const Congruence_System &cgs) |
Adds a copy of each congruence in cgs to *this . More... | |
void | add_recycled_congruences (Congruence_System &cgs) |
Adds the congruences in cgs to *this. More... | |
void | add_constraint (const Constraint &c) |
Adds to *this a congruence equivalent to constraint c . More... | |
void | add_constraints (const Constraint_System &cs) |
Adds to *this congruences equivalent to the constraints in cs . More... | |
void | add_recycled_constraints (Constraint_System &cs) |
Adds to *this congruences equivalent to the constraints in cs . More... | |
void | refine_with_congruence (const Congruence &cg) |
Uses a copy of the congruence cg to refine *this . More... | |
void | refine_with_congruences (const Congruence_System &cgs) |
Uses a copy of the congruences in cgs to refine *this . More... | |
void | refine_with_constraint (const Constraint &c) |
Uses a copy of the constraint c to refine *this . More... | |
void | refine_with_constraints (const Constraint_System &cs) |
Uses a copy of the constraints in cs to refine *this . More... | |
void | add_grid_generators (const Grid_Generator_System &gs) |
Adds a copy of the generators in gs to the system of generators of *this . More... | |
void | add_recycled_grid_generators (Grid_Generator_System &gs) |
Adds the generators in gs to the system of generators of this . More... | |
void | unconstrain (Variable var) |
Computes the cylindrification of *this with respect to space dimension var , assigning the result to *this . More... | |
void | unconstrain (const Variables_Set &vars) |
Computes the cylindrification of *this with respect to the set of space dimensions vars , assigning the result to *this . More... | |
void | intersection_assign (const Grid &y) |
Assigns to *this the intersection of *this and y . More... | |
void | upper_bound_assign (const Grid &y) |
Assigns to *this the least upper bound of *this and y . More... | |
bool | upper_bound_assign_if_exact (const Grid &y) |
If the upper bound of *this and y is exact it is assigned to this and true is returned, otherwise false is returned. More... | |
void | difference_assign (const Grid &y) |
Assigns to *this the grid-difference of *this and y . More... | |
bool | simplify_using_context_assign (const Grid &y) |
Assigns to *this a meet-preserving simplification of *this with respect to y . If false is returned, then the intersection is empty. More... | |
void | affine_image (Variable var, const Linear_Expression &expr, Coefficient_traits::const_reference denominator=Coefficient_one()) |
Assigns to *this the affine image of this under the function mapping variable var to the affine expression specified by expr and denominator . More... | |
void | affine_preimage (Variable var, const Linear_Expression &expr, Coefficient_traits::const_reference denominator=Coefficient_one()) |
Assigns to *this the affine preimage of *this under the function mapping variable var to the affine expression specified by expr and denominator . More... | |
void | generalized_affine_image (Variable var, Relation_Symbol relsym, const Linear_Expression &expr, Coefficient_traits::const_reference denominator=Coefficient_one(), Coefficient_traits::const_reference modulus=Coefficient_zero()) |
Assigns to *this the image of *this with respect to the generalized affine relation ![]() | |
void | generalized_affine_preimage (Variable var, Relation_Symbol relsym, const Linear_Expression &expr, Coefficient_traits::const_reference denominator=Coefficient_one(), Coefficient_traits::const_reference modulus=Coefficient_zero()) |
Assigns to *this the preimage of *this with respect to the generalized affine relation ![]() | |
void | generalized_affine_image (const Linear_Expression &lhs, Relation_Symbol relsym, const Linear_Expression &rhs, Coefficient_traits::const_reference modulus=Coefficient_zero()) |
Assigns to *this the image of *this with respect to the generalized affine relation ![]() | |
void | generalized_affine_preimage (const Linear_Expression &lhs, Relation_Symbol relsym, const Linear_Expression &rhs, Coefficient_traits::const_reference modulus=Coefficient_zero()) |
Assigns to *this the preimage of *this with respect to the generalized affine relation ![]() | |
void | bounded_affine_image (Variable var, const Linear_Expression &lb_expr, const Linear_Expression &ub_expr, Coefficient_traits::const_reference denominator=Coefficient_one()) |
Assigns to *this the image of *this with respect to the bounded affine relation ![]() | |
void | bounded_affine_preimage (Variable var, const Linear_Expression &lb_expr, const Linear_Expression &ub_expr, Coefficient_traits::const_reference denominator=Coefficient_one()) |
Assigns to *this the preimage of *this with respect to the bounded affine relation ![]() | |
void | time_elapse_assign (const Grid &y) |
Assigns to *this the result of computing the time-elapse between *this and y . More... | |
void | wrap_assign (const Variables_Set &vars, Bounded_Integer_Type_Width w, Bounded_Integer_Type_Representation r, Bounded_Integer_Type_Overflow o, const Constraint_System *cs_p=0, unsigned complexity_threshold=16, bool wrap_individually=true) |
Wraps the specified dimensions of the vector space. More... | |
void | drop_some_non_integer_points (Complexity_Class complexity=ANY_COMPLEXITY) |
Possibly tightens *this by dropping all points with non-integer coordinates. More... | |
void | drop_some_non_integer_points (const Variables_Set &vars, Complexity_Class complexity=ANY_COMPLEXITY) |
Possibly tightens *this by dropping all points with non-integer coordinates for the space dimensions corresponding to vars . More... | |
void | topological_closure_assign () |
Assigns to *this its topological closure. | |
void | congruence_widening_assign (const Grid &y, unsigned *tp=NULL) |
Assigns to *this the result of computing the Grid widening between *this and y using congruence systems. More... | |
void | generator_widening_assign (const Grid &y, unsigned *tp=NULL) |
Assigns to *this the result of computing the Grid widening between *this and y using generator systems. More... | |
void | widening_assign (const Grid &y, unsigned *tp=NULL) |
Assigns to *this the result of computing the Grid widening between *this and y . More... | |
void | limited_congruence_extrapolation_assign (const Grid &y, const Congruence_System &cgs, unsigned *tp=NULL) |
Improves the result of the congruence variant of Grid widening computation by also enforcing those congruences in cgs that are satisfied by all the points of *this . More... | |
void | limited_generator_extrapolation_assign (const Grid &y, const Congruence_System &cgs, unsigned *tp=NULL) |
Improves the result of the generator variant of the Grid widening computation by also enforcing those congruences in cgs that are satisfied by all the points of *this . More... | |
void | limited_extrapolation_assign (const Grid &y, const Congruence_System &cgs, unsigned *tp=NULL) |
Improves the result of the Grid widening computation by also enforcing those congruences in cgs that are satisfied by all the points of *this . More... | |
Member Functions that May Modify the Dimension of the Vector Space | |
void | add_space_dimensions_and_embed (dimension_type m) |
Adds m new space dimensions and embeds the old grid in the new vector space. More... | |
void | add_space_dimensions_and_project (dimension_type m) |
Adds m new space dimensions to the grid and does not embed it in the new vector space. More... | |
void | concatenate_assign (const Grid &y) |
Assigns to *this the concatenation of *this and y , taken in this order. More... | |
void | remove_space_dimensions (const Variables_Set &vars) |
Removes all the specified dimensions from the vector space. More... | |
void | remove_higher_space_dimensions (dimension_type new_dimension) |
Removes the higher dimensions of the vector space so that the resulting space will have dimension new_dimension .. More... | |
template<typename Partial_Function > | |
void | map_space_dimensions (const Partial_Function &pfunc) |
Remaps the dimensions of the vector space according to a partial function. More... | |
void | expand_space_dimension (Variable var, dimension_type m) |
Creates m copies of the space dimension corresponding to var . More... | |
void | fold_space_dimensions (const Variables_Set &vars, Variable dest) |
Folds the space dimensions in vars into dest . More... | |
Miscellaneous Member Functions | |
~Grid () | |
Destructor. | |
void | m_swap (Grid &y) |
Swaps *this with grid y . (*this and y can be dimension-incompatible.) | |
void | ascii_dump () const |
Writes to std::cerr an ASCII representation of *this . | |
void | ascii_dump (std::ostream &s) const |
Writes to s an ASCII representation of *this . | |
void | print () const |
Prints *this to std::cerr using operator<< . | |
bool | ascii_load (std::istream &s) |
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise. | |
memory_size_type | total_memory_in_bytes () const |
Returns the total size in bytes of the memory occupied by *this . | |
memory_size_type | external_memory_in_bytes () const |
Returns the size in bytes of the memory managed by *this . | |
int32_t | hash_code () const |
Returns a 32-bit hash code for *this . More... | |
Static Public Member Functions | |
static dimension_type | max_space_dimension () |
Returns the maximum space dimension all kinds of Grid can handle. | |
static bool | can_recycle_congruence_systems () |
Returns true indicating that this domain has methods that can recycle congruences. | |
static bool | can_recycle_constraint_systems () |
Returns true indicating that this domain has methods that can recycle constraints. | |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &s, const Grid &gr) |
Output operator. More... | |
void | swap (Grid &x, Grid &y) |
Swaps x with y . More... | |
bool | operator== (const Grid &x, const Grid &y) |
Returns true if and only if x and y are the same grid. More... | |
bool | operator!= (const Grid &x, const Grid &y) |
Returns true if and only if x and y are different grids. More... | |
bool | operator!= (const Grid &x, const Grid &y) |
void | swap (Grid &x, Grid &y) |
A grid.
An object of the class Grid represents a rational grid.
The domain of grids optimally supports:
Depending on the method, using a constraint that is not optimally supported by the domain will either raise an exception or result in a (possibly non-optimal) upward approximation.
The domain of grids support a concept of double description similar to the one developed for polyhedra: hence, a grid can be specified as either a finite system of congruences or a finite system of generators (see Section Rational Grids) and it is always possible to obtain either representation. That is, if we know the system of congruences, we can obtain from this a system of generators that define the same grid and vice versa. These systems can contain redundant members, or they can be in the minimal form.
A key attribute of any grid is its space dimension (the dimension of the enclosing vector space):
Note that two different grids can be defined on the zero-dimension space: the empty grid and the universe grid .
x
and y
are defined (where they are used) as follows: add_space_dimensions_and_embed
: We build the universe grid in the 1-dimension space
add_space_dimensions_and_project
: The first two lines of code are the same as in Example 4 for add_space_dimensions_and_embed
. After the last line of code, the resulting grid is the singleton set affine_image
: x
is instead affine_preimage
: var
and the affine expression and the denominator are the same as in Example 6, while the resulting grid is similar but translated 3 integers to the left (all the pairs x
is x
, for example, the affine expression remove_space_dimensions
: remove_space_dimensions
operator, unexpected results can be obtained. For instance, by using the following code we would obtain a different result: vars2
we are actually removing variable remove_space_dimensions
is not idempotent: removing twice the same non-empty set of dimensions is never the same as removing them just once.
|
inlineexplicit |
Builds a grid having the specified properties.
num_dimensions | The number of dimensions of the vector space enclosing the grid; |
kind | Specifies whether the universe or the empty grid has to be built. |
std::length_error | Thrown if num_dimensions exceeds the maximum allowed space dimension. |
|
inlineexplicit |
Builds a grid, copying a system of congruences.
The grid inherits the space dimension of the congruence system.
cgs | The system of congruences defining the grid. |
std::length_error | Thrown if num_dimensions exceeds the maximum allowed space dimension. |
|
inline |
Builds a grid, recycling a system of congruences.
The grid inherits the space dimension of the congruence system.
cgs | The system of congruences defining the grid. Its data-structures may be recycled to build the grid. |
dummy | A dummy tag to syntactically differentiate this one from the other constructors. |
std::length_error | Thrown if num_dimensions exceeds the maximum allowed space dimension. |
|
explicit |
Builds a grid, copying a system of constraints.
The grid inherits the space dimension of the constraint system.
cs | The system of constraints defining the grid. |
std::invalid_argument | Thrown if the constraint system cs contains inequality constraints. |
std::length_error | Thrown if num_dimensions exceeds the maximum allowed space dimension. |
Parma_Polyhedra_Library::Grid::Grid | ( | Constraint_System & | cs, |
Recycle_Input | dummy | ||
) |
Builds a grid, recycling a system of constraints.
The grid inherits the space dimension of the constraint system.
cs | The system of constraints defining the grid. Its data-structures may be recycled to build the grid. |
dummy | A dummy tag to syntactically differentiate this one from the other constructors. |
std::invalid_argument | Thrown if the constraint system cs contains inequality constraints. |
std::length_error | Thrown if num_dimensions exceeds the maximum allowed space dimension. |
|
inlineexplicit |
Builds a grid, copying a system of grid generators.
The grid inherits the space dimension of the generator system.
ggs | The system of generators defining the grid. |
std::invalid_argument | Thrown if the system of generators is not empty but has no points. |
std::length_error | Thrown if num_dimensions exceeds the maximum allowed space dimension. |
|
inline |
Builds a grid, recycling a system of grid generators.
The grid inherits the space dimension of the generator system.
ggs | The system of generators defining the grid. Its data-structures may be recycled to build the grid. |
dummy | A dummy tag to syntactically differentiate this one from the other constructors. |
std::invalid_argument | Thrown if the system of generators is not empty but has no points. |
std::length_error | Thrown if num_dimensions exceeds the maximum allowed space dimension. |
|
explicit |
Builds a grid out of a box.
The grid inherits the space dimension of the box. The built grid is the most precise grid that includes the box.
box | The box representing the grid to be built. |
complexity | This argument is ignored as the algorithm used has polynomial complexity. |
std::length_error | Thrown if the space dimension of box exceeds the maximum allowed space dimension. |
|
inlineexplicit |
Builds a grid out of a bounded-difference shape.
The grid inherits the space dimension of the BDS. The built grid is the most precise grid that includes the BDS.
bd | The BDS representing the grid to be built. |
complexity | This argument is ignored as the algorithm used has polynomial complexity. |
std::length_error | Thrown if the space dimension of bd exceeds the maximum allowed space dimension. |
|
inlineexplicit |
Builds a grid out of an octagonal shape.
The grid inherits the space dimension of the octagonal shape. The built grid is the most precise grid that includes the octagonal shape.
os | The octagonal shape representing the grid to be built. |
complexity | This argument is ignored as the algorithm used has polynomial complexity. |
std::length_error | Thrown if the space dimension of os exceeds the maximum allowed space dimension. |
|
explicit |
Builds a grid from a polyhedron using algorithms whose complexity does not exceed the one specified by complexity
. If complexity
is ANY_COMPLEXITY
, then the grid built is the smallest one containing ph
.
The grid inherits the space dimension of polyhedron.
ph | The polyhedron. |
complexity | The complexity class. |
std::length_error | Thrown if num_dimensions exceeds the maximum allowed space dimension. |
Parma_Polyhedra_Library::Grid::Grid | ( | const Grid & | y, |
Complexity_Class | complexity = ANY_COMPLEXITY |
||
) |
Ordinary copy constructor.
The complexity argument is ignored.
bool Parma_Polyhedra_Library::Grid::is_topologically_closed | ( | ) | const |
Returns true
if and only if *this
is a topologically closed subset of the vector space.
A grid is always topologically closed.
bool Parma_Polyhedra_Library::Grid::is_disjoint_from | ( | const Grid & | y | ) | const |
Returns true
if and only if *this
and y
are disjoint.
std::invalid_argument | Thrown if x and y are dimension-incompatible. |
bool Parma_Polyhedra_Library::Grid::is_discrete | ( | ) | const |
Returns true
if and only if *this
is discrete.
A grid is discrete if it can be defined by a generator system which contains only points and parameters. This includes the empty grid and any grid in dimension zero.
bool Parma_Polyhedra_Library::Grid::constrains | ( | Variable | var | ) | const |
Returns true
if and only if var
is constrained in *this
.
std::invalid_argument | Thrown if var is not a space dimension of *this . |
|
inline |
Returns true
if and only if expr
is bounded in *this
.
This method is the same as bounds_from_below.
std::invalid_argument | Thrown if expr and *this are dimension-incompatible. |
|
inline |
Returns true
if and only if expr
is bounded in *this
.
This method is the same as bounds_from_above.
std::invalid_argument | Thrown if expr and *this are dimension-incompatible. |
|
inline |
Returns true
if and only if *this
is not empty and expr
is bounded from above in *this
, in which case the supremum value is computed.
expr | The linear expression to be maximized subject to *this ; |
sup_n | The numerator of the supremum value; |
sup_d | The denominator of the supremum value; |
maximum | true if the supremum value can be reached in this . Always true when this bounds expr . Present for interface compatibility with class Polyhedron, where closure points can result in a value of false. |
std::invalid_argument | Thrown if expr and *this are dimension-incompatible. |
If *this
is empty or expr
is not bounded by *this
, false
is returned and sup_n
, sup_d
and maximum
are left untouched.
|
inline |
Returns true
if and only if *this
is not empty and expr
is bounded from above in *this
, in which case the supremum value and a point where expr
reaches it are computed.
expr | The linear expression to be maximized subject to *this ; |
sup_n | The numerator of the supremum value; |
sup_d | The denominator of the supremum value; |
maximum | true if the supremum value can be reached in this . Always true when this bounds expr . Present for interface compatibility with class Polyhedron, where closure points can result in a value of false; |
point | When maximization succeeds, will be assigned a point where expr reaches its supremum value. |
std::invalid_argument | Thrown if expr and *this are dimension-incompatible. |
If *this
is empty or expr
is not bounded by *this
, false
is returned and sup_n
, sup_d
, maximum
and point
are left untouched.
|
inline |
Returns true
if and only if *this
is not empty and expr
is bounded from below in *this
, in which case the infimum value is computed.
expr | The linear expression to be minimized subject to *this ; |
inf_n | The numerator of the infimum value; |
inf_d | The denominator of the infimum value; |
minimum | true if the is the infimum value can be reached in this . Always true when this bounds expr . Present for interface compatibility with class Polyhedron, where closure points can result in a value of false. |
std::invalid_argument | Thrown if expr and *this are dimension-incompatible. |
If *this
is empty or expr
is not bounded from below, false
is returned and inf_n
, inf_d
and minimum
are left untouched.
|
inline |
Returns true
if and only if *this
is not empty and expr
is bounded from below in *this
, in which case the infimum value and a point where expr
reaches it are computed.
expr | The linear expression to be minimized subject to *this ; |
inf_n | The numerator of the infimum value; |
inf_d | The denominator of the infimum value; |
minimum | true if the is the infimum value can be reached in this . Always true when this bounds expr . Present for interface compatibility with class Polyhedron, where closure points can result in a value of false; |
point | When minimization succeeds, will be assigned a point where expr reaches its infimum value. |
std::invalid_argument | Thrown if expr and *this are dimension-incompatible. |
If *this
is empty or expr
is not bounded from below, false
is returned and inf_n
, inf_d
, minimum
and point
are left untouched.
bool Parma_Polyhedra_Library::Grid::frequency | ( | const Linear_Expression & | expr, |
Coefficient & | freq_n, | ||
Coefficient & | freq_d, | ||
Coefficient & | val_n, | ||
Coefficient & | val_d | ||
) | const |
Returns true
if and only if *this
is not empty and frequency for *this
with respect to expr
is defined, in which case the frequency and the value for expr
that is closest to zero are computed.
expr | The linear expression for which the frequency is needed; |
freq_n | The numerator of the maximum frequency of expr ; |
freq_d | The denominator of the maximum frequency of expr ; |
val_n | The numerator of them value of expr at a point in the grid that is closest to zero; |
val_d | The denominator of a value of expr at a point in the grid that is closest to zero; |
std::invalid_argument | Thrown if expr and *this are dimension-incompatible. |
If *this
is empty or frequency is undefined with respect to expr
, then false
is returned and freq_n
, freq_d
, val_n
and val_d
are left untouched.
bool Parma_Polyhedra_Library::Grid::contains | ( | const Grid & | y | ) | const |
Returns true
if and only if *this
contains y
.
std::invalid_argument | Thrown if *this and y are dimension-incompatible. |
|
inline |
Returns true
if and only if *this
strictly contains y
.
std::invalid_argument | Thrown if *this and y are dimension-incompatible. |
bool Parma_Polyhedra_Library::Grid::OK | ( | bool | check_not_empty = false | ) | const |
Checks if all the invariants are satisfied.
true
if and only if *this
satisfies all the invariants and either check_not_empty
is false
or *this
is not empty.check_not_empty | true if and only if, in addition to checking the invariants, *this must be checked to be not empty. |
The check is performed so as to intrude as little as possible. If the library has been compiled with run-time assertions enabled, error messages are written on std::cerr
in case invariants are violated. This is useful for the purpose of debugging the library.
|
inline |
Adds a copy of congruence cg
to *this
.
std::invalid_argument | Thrown if *this and congruence cg are dimension-incompatible. |
void Parma_Polyhedra_Library::Grid::add_grid_generator | ( | const Grid_Generator & | g | ) |
Adds a copy of grid generator g
to the system of generators of *this
.
std::invalid_argument | Thrown if *this and generator g are dimension-incompatible, or if *this is an empty grid and g is not a point. |
|
inline |
Adds a copy of each congruence in cgs
to *this
.
cgs | Contains the congruences that will be added to the system of congruences of *this . |
std::invalid_argument | Thrown if *this and cgs are dimension-incompatible. |
void Parma_Polyhedra_Library::Grid::add_recycled_congruences | ( | Congruence_System & | cgs | ) |
Adds the congruences in cgs
to *this.
cgs | The congruence system to be added to *this . The congruences in cgs may be recycled. |
std::invalid_argument | Thrown if *this and cgs are dimension-incompatible. |
cgs
upon successful or exceptional return is that it can be safely destroyed.
|
inline |
Adds to *this
a congruence equivalent to constraint c
.
c | The constraint to be added. |
std::invalid_argument | Thrown if *this and c are dimension-incompatible or if constraint c is not optimally supported by the grid domain. |
void Parma_Polyhedra_Library::Grid::add_constraints | ( | const Constraint_System & | cs | ) |
Adds to *this
congruences equivalent to the constraints in cs
.
cs | The constraints to be added. |
std::invalid_argument | Thrown if *this and cs are dimension-incompatible or if cs contains a constraint which is not optimally supported by the grid domain. |
|
inline |
Adds to *this
congruences equivalent to the constraints in cs
.
cs | The constraints to be added. They may be recycled. |
std::invalid_argument | Thrown if *this and cs are dimension-incompatible or if cs contains a constraint which is not optimally supported by the grid domain. |
cs
upon successful or exceptional return is that it can be safely destroyed.
|
inline |
Uses a copy of the congruence cg
to refine *this
.
cg | The congruence used. |
std::invalid_argument | Thrown if *this and congruence cg are dimension-incompatible. |
|
inline |
Uses a copy of the congruences in cgs
to refine *this
.
cgs | The congruences used. |
std::invalid_argument | Thrown if *this and cgs are dimension-incompatible. |
void Parma_Polyhedra_Library::Grid::refine_with_constraint | ( | const Constraint & | c | ) |
Uses a copy of the constraint c
to refine *this
.
c | The constraint used. If it is not an equality, it will be ignored |
std::invalid_argument | Thrown if *this and c are dimension-incompatible. |
void Parma_Polyhedra_Library::Grid::refine_with_constraints | ( | const Constraint_System & | cs | ) |
Uses a copy of the constraints in cs
to refine *this
.
cs | The constraints used. Constraints that are not equalities are ignored. |
std::invalid_argument | Thrown if *this and cs are dimension-incompatible. |
void Parma_Polyhedra_Library::Grid::add_grid_generators | ( | const Grid_Generator_System & | gs | ) |
Adds a copy of the generators in gs
to the system of generators of *this
.
gs | Contains the generators that will be added to the system of generators of *this . |
std::invalid_argument | Thrown if *this and gs are dimension-incompatible, or if *this is empty and the system of generators gs is not empty, but has no points. |
void Parma_Polyhedra_Library::Grid::add_recycled_grid_generators | ( | Grid_Generator_System & | gs | ) |
Adds the generators in gs
to the system of generators of this
.
gs | The generator system to be added to *this . The generators in gs may be recycled. |
std::invalid_argument | Thrown if *this and gs are dimension-incompatible. |
gs
upon successful or exceptional return is that it can be safely destroyed. void Parma_Polyhedra_Library::Grid::unconstrain | ( | Variable | var | ) |
Computes the cylindrification of *this
with respect to space dimension var
, assigning the result to *this
.
var | The space dimension that will be unconstrained. |
std::invalid_argument | Thrown if var is not a space dimension of *this . |
void Parma_Polyhedra_Library::Grid::unconstrain | ( | const Variables_Set & | vars | ) |
Computes the cylindrification of *this
with respect to the set of space dimensions vars
, assigning the result to *this
.
vars | The set of space dimension that will be unconstrained. |
std::invalid_argument | Thrown if *this is dimension-incompatible with one of the Variable objects contained in vars . |
void Parma_Polyhedra_Library::Grid::intersection_assign | ( | const Grid & | y | ) |
Assigns to *this
the intersection of *this
and y
.
std::invalid_argument | Thrown if *this and y are dimension-incompatible. |
void Parma_Polyhedra_Library::Grid::upper_bound_assign | ( | const Grid & | y | ) |
Assigns to *this
the least upper bound of *this
and y
.
std::invalid_argument | Thrown if *this and y are dimension-incompatible. |
bool Parma_Polyhedra_Library::Grid::upper_bound_assign_if_exact | ( | const Grid & | y | ) |
If the upper bound of *this
and y
is exact it is assigned to this
and true
is returned, otherwise false
is returned.
std::invalid_argument | Thrown if *this and y are dimension-incompatible. |
void Parma_Polyhedra_Library::Grid::difference_assign | ( | const Grid & | y | ) |
Assigns to *this
the grid-difference of *this
and y
.
The grid difference between grids x and y is the smallest grid containing all the points from x and y that are only in x.
std::invalid_argument | Thrown if *this and y are dimension-incompatible. |
bool Parma_Polyhedra_Library::Grid::simplify_using_context_assign | ( | const Grid & | y | ) |
Assigns to *this
a meet-preserving simplification of *this
with respect to y
. If false
is returned, then the intersection is empty.
std::invalid_argument | Thrown if *this and y are topology-incompatible or dimension-incompatible. |
void Parma_Polyhedra_Library::Grid::affine_image | ( | Variable | var, |
const Linear_Expression & | expr, | ||
Coefficient_traits::const_reference | denominator = Coefficient_one() |
||
) |
Assigns to *this
the affine image of this
under the function mapping variable var
to the affine expression specified by expr
and denominator
.
var | The variable to which the affine expression is assigned; |
expr | The numerator of the affine expression; |
denominator | The denominator of the affine expression (optional argument with default value 1). |
std::invalid_argument | Thrown if denominator is zero or if expr and *this are dimension-incompatible or if var is not a space dimension of *this . |
void Parma_Polyhedra_Library::Grid::affine_preimage | ( | Variable | var, |
const Linear_Expression & | expr, | ||
Coefficient_traits::const_reference | denominator = Coefficient_one() |
||
) |
Assigns to *this
the affine preimage of *this
under the function mapping variable var
to the affine expression specified by expr
and denominator
.
var | The variable to which the affine expression is substituted; |
expr | The numerator of the affine expression; |
denominator | The denominator of the affine expression (optional argument with default value 1). |
std::invalid_argument | Thrown if denominator is zero or if expr and *this are dimension-incompatible or if var is not a space dimension of *this . |
void Parma_Polyhedra_Library::Grid::generalized_affine_image | ( | Variable | var, |
Relation_Symbol | relsym, | ||
const Linear_Expression & | expr, | ||
Coefficient_traits::const_reference | denominator = Coefficient_one() , |
||
Coefficient_traits::const_reference | modulus = Coefficient_zero() |
||
) |
Assigns to *this
the image of *this
with respect to the generalized affine relation .
var | The left hand side variable of the generalized affine relation; |
relsym | The relation symbol where EQUAL is the symbol for a congruence relation; |
expr | The numerator of the right hand side affine expression; |
denominator | The denominator of the right hand side affine expression. Optional argument with an automatic value of one; |
modulus | The modulus of the congruence lhs %= rhs. A modulus of zero indicates lhs == rhs. Optional argument with an automatic value of zero. |
std::invalid_argument | Thrown if denominator is zero or if expr and *this are dimension-incompatible or if var is not a space dimension of this . |
void Parma_Polyhedra_Library::Grid::generalized_affine_preimage | ( | Variable | var, |
Relation_Symbol | relsym, | ||
const Linear_Expression & | expr, | ||
Coefficient_traits::const_reference | denominator = Coefficient_one() , |
||
Coefficient_traits::const_reference | modulus = Coefficient_zero() |
||
) |
Assigns to *this
the preimage of *this
with respect to the generalized affine relation .
var | The left hand side variable of the generalized affine relation; |
relsym | The relation symbol where EQUAL is the symbol for a congruence relation; |
expr | The numerator of the right hand side affine expression; |
denominator | The denominator of the right hand side affine expression. Optional argument with an automatic value of one; |
modulus | The modulus of the congruence lhs %= rhs. A modulus of zero indicates lhs == rhs. Optional argument with an automatic value of zero. |
std::invalid_argument | Thrown if denominator is zero or if expr and *this are dimension-incompatible or if var is not a space dimension of this . |
void Parma_Polyhedra_Library::Grid::generalized_affine_image | ( | const Linear_Expression & | lhs, |
Relation_Symbol | relsym, | ||
const Linear_Expression & | rhs, | ||
Coefficient_traits::const_reference | modulus = Coefficient_zero() |
||
) |
Assigns to *this
the image of *this
with respect to the generalized affine relation .
lhs | The left hand side affine expression. |
relsym | The relation symbol where EQUAL is the symbol for a congruence relation; |
rhs | The right hand side affine expression. |
modulus | The modulus of the congruence lhs %= rhs. A modulus of zero indicates lhs == rhs. Optional argument with an automatic value of zero. |
std::invalid_argument | Thrown if *this is dimension-incompatible with lhs or rhs . |
void Parma_Polyhedra_Library::Grid::generalized_affine_preimage | ( | const Linear_Expression & | lhs, |
Relation_Symbol | relsym, | ||
const Linear_Expression & | rhs, | ||
Coefficient_traits::const_reference | modulus = Coefficient_zero() |
||
) |
Assigns to *this
the preimage of *this
with respect to the generalized affine relation .
lhs | The left hand side affine expression; |
relsym | The relation symbol where EQUAL is the symbol for a congruence relation; |
rhs | The right hand side affine expression; |
modulus | The modulus of the congruence lhs %= rhs. A modulus of zero indicates lhs == rhs. Optional argument with an automatic value of zero. |
std::invalid_argument | Thrown if *this is dimension-incompatible with lhs or rhs . |
void Parma_Polyhedra_Library::Grid::bounded_affine_image | ( | Variable | var, |
const Linear_Expression & | lb_expr, | ||
const Linear_Expression & | ub_expr, | ||
Coefficient_traits::const_reference | denominator = Coefficient_one() |
||
) |
Assigns to *this
the image of *this
with respect to the bounded affine relation .
var | The variable updated by the affine relation; |
lb_expr | The numerator of the lower bounding affine expression; |
ub_expr | The numerator of the upper bounding affine expression; |
denominator | The (common) denominator for the lower and upper bounding affine expressions (optional argument with default value 1). |
std::invalid_argument | Thrown if denominator is zero or if lb_expr (resp., ub_expr ) and *this are dimension-incompatible or if var is not a space dimension of *this . |
void Parma_Polyhedra_Library::Grid::bounded_affine_preimage | ( | Variable | var, |
const Linear_Expression & | lb_expr, | ||
const Linear_Expression & | ub_expr, | ||
Coefficient_traits::const_reference | denominator = Coefficient_one() |
||
) |
Assigns to *this
the preimage of *this
with respect to the bounded affine relation .
var | The variable updated by the affine relation; |
lb_expr | The numerator of the lower bounding affine expression; |
ub_expr | The numerator of the upper bounding affine expression; |
denominator | The (common) denominator for the lower and upper bounding affine expressions (optional argument with default value 1). |
std::invalid_argument | Thrown if denominator is zero or if lb_expr (resp., ub_expr ) and *this are dimension-incompatible or if var is not a space dimension of *this . |
void Parma_Polyhedra_Library::Grid::time_elapse_assign | ( | const Grid & | y | ) |
Assigns to *this
the result of computing the time-elapse between *this
and y
.
std::invalid_argument | Thrown if *this and y are dimension-incompatible. |
void Parma_Polyhedra_Library::Grid::wrap_assign | ( | const Variables_Set & | vars, |
Bounded_Integer_Type_Width | w, | ||
Bounded_Integer_Type_Representation | r, | ||
Bounded_Integer_Type_Overflow | o, | ||
const Constraint_System * | cs_p = 0 , |
||
unsigned | complexity_threshold = 16 , |
||
bool | wrap_individually = true |
||
) |
Wraps the specified dimensions of the vector space.
vars | The set of Variable objects corresponding to the space dimensions to be wrapped. |
w | The width of the bounded integer type corresponding to all the dimensions to be wrapped. |
r | The representation of the bounded integer type corresponding to all the dimensions to be wrapped. |
o | The overflow behavior of the bounded integer type corresponding to all the dimensions to be wrapped. |
cs_p | Possibly null pointer to a constraint system. This argument is for compatibility with wrap_assign() for the other domains and only checked for dimension-compatibility. |
complexity_threshold | A precision parameter of the wrapping operator. This argument is for compatibility with wrap_assign() for the other domains and is ignored. |
wrap_individually | true if the dimensions should be wrapped individually. As wrapping dimensions collectively does not improve the precision, this argument is ignored. |
std::invalid_argument | Thrown if *this is dimension-incompatible with one of the Variable objects contained in vars or with *cs_p . |
Vars
represent integers. Thus, where the extra cost is negligible, the integrality of these variables is enforced; possibly causing a non-integral grid to become empty. void Parma_Polyhedra_Library::Grid::drop_some_non_integer_points | ( | Complexity_Class | complexity = ANY_COMPLEXITY | ) |
Possibly tightens *this
by dropping all points with non-integer coordinates.
complexity | This argument is ignored as the algorithm used has polynomial complexity. |
void Parma_Polyhedra_Library::Grid::drop_some_non_integer_points | ( | const Variables_Set & | vars, |
Complexity_Class | complexity = ANY_COMPLEXITY |
||
) |
Possibly tightens *this
by dropping all points with non-integer coordinates for the space dimensions corresponding to vars
.
vars | Points with non-integer coordinates for these variables/space-dimensions can be discarded. |
complexity | This argument is ignored as the algorithm used has polynomial complexity. |
void Parma_Polyhedra_Library::Grid::congruence_widening_assign | ( | const Grid & | y, |
unsigned * | tp = NULL |
||
) |
Assigns to *this
the result of computing the Grid widening between *this
and y
using congruence systems.
y | A grid that must be contained in *this ; |
tp | An optional pointer to an unsigned variable storing the number of available tokens (to be used when applying the widening with tokens delay technique). |
std::invalid_argument | Thrown if *this and y are dimension-incompatible. |
void Parma_Polyhedra_Library::Grid::generator_widening_assign | ( | const Grid & | y, |
unsigned * | tp = NULL |
||
) |
Assigns to *this
the result of computing the Grid widening between *this
and y
using generator systems.
y | A grid that must be contained in *this ; |
tp | An optional pointer to an unsigned variable storing the number of available tokens (to be used when applying the widening with tokens delay technique). |
std::invalid_argument | Thrown if *this and y are dimension-incompatible. |
void Parma_Polyhedra_Library::Grid::widening_assign | ( | const Grid & | y, |
unsigned * | tp = NULL |
||
) |
Assigns to *this
the result of computing the Grid widening between *this
and y
.
This widening uses either the congruence or generator systems depending on which of the systems describing x and y are up to date and minimized.
y | A grid that must be contained in *this ; |
tp | An optional pointer to an unsigned variable storing the number of available tokens (to be used when applying the widening with tokens delay technique). |
std::invalid_argument | Thrown if *this and y are dimension-incompatible. |
void Parma_Polyhedra_Library::Grid::limited_congruence_extrapolation_assign | ( | const Grid & | y, |
const Congruence_System & | cgs, | ||
unsigned * | tp = NULL |
||
) |
Improves the result of the congruence variant of Grid widening computation by also enforcing those congruences in cgs
that are satisfied by all the points of *this
.
y | A grid that must be contained in *this ; |
cgs | The system of congruences used to improve the widened grid; |
tp | An optional pointer to an unsigned variable storing the number of available tokens (to be used when applying the widening with tokens delay technique). |
std::invalid_argument | Thrown if *this , y and cgs are dimension-incompatible. |
void Parma_Polyhedra_Library::Grid::limited_generator_extrapolation_assign | ( | const Grid & | y, |
const Congruence_System & | cgs, | ||
unsigned * | tp = NULL |
||
) |
Improves the result of the generator variant of the Grid widening computation by also enforcing those congruences in cgs
that are satisfied by all the points of *this
.
y | A grid that must be contained in *this ; |
cgs | The system of congruences used to improve the widened grid; |
tp | An optional pointer to an unsigned variable storing the number of available tokens (to be used when applying the widening with tokens delay technique). |
std::invalid_argument | Thrown if *this , y and cgs are dimension-incompatible. |
void Parma_Polyhedra_Library::Grid::limited_extrapolation_assign | ( | const Grid & | y, |
const Congruence_System & | cgs, | ||
unsigned * | tp = NULL |
||
) |
Improves the result of the Grid widening computation by also enforcing those congruences in cgs
that are satisfied by all the points of *this
.
y | A grid that must be contained in *this ; |
cgs | The system of congruences used to improve the widened grid; |
tp | An optional pointer to an unsigned variable storing the number of available tokens (to be used when applying the widening with tokens delay technique). |
std::invalid_argument | Thrown if *this , y and cgs are dimension-incompatible. |
void Parma_Polyhedra_Library::Grid::add_space_dimensions_and_embed | ( | dimension_type | m | ) |
Adds m
new space dimensions and embeds the old grid in the new vector space.
m | The number of dimensions to add. |
std::length_error | Thrown if adding m new space dimensions would cause the vector space to exceed dimension max_space_dimension() . |
The new space dimensions will be those having the highest indexes in the new grid, which is characterized by a system of congruences in which the variables which are the new dimensions can have any value. For instance, when starting from the grid and adding a third space dimension, the result will be the grid
void Parma_Polyhedra_Library::Grid::add_space_dimensions_and_project | ( | dimension_type | m | ) |
Adds m
new space dimensions to the grid and does not embed it in the new vector space.
m | The number of space dimensions to add. |
std::length_error | Thrown if adding m new space dimensions would cause the vector space to exceed dimension max_space_dimension() . |
The new space dimensions will be those having the highest indexes in the new grid, which is characterized by a system of congruences in which the variables running through the new dimensions are all constrained to be equal to 0. For instance, when starting from the grid and adding a third space dimension, the result will be the grid
void Parma_Polyhedra_Library::Grid::concatenate_assign | ( | const Grid & | y | ) |
Assigns to *this
the concatenation of *this
and y
, taken in this order.
std::length_error | Thrown if the concatenation would cause the vector space to exceed dimension max_space_dimension() . |
void Parma_Polyhedra_Library::Grid::remove_space_dimensions | ( | const Variables_Set & | vars | ) |
void Parma_Polyhedra_Library::Grid::remove_higher_space_dimensions | ( | dimension_type | new_dimension | ) |
Removes the higher dimensions of the vector space so that the resulting space will have dimension new_dimension
..
std::invalid_argument | Thrown if new_dimensions is greater than the space dimension of *this . |
void Parma_Polyhedra_Library::Grid::map_space_dimensions | ( | const Partial_Function & | pfunc | ) |
Remaps the dimensions of the vector space according to a partial function.
If pfunc
maps only some of the dimensions of *this
then the rest will be projected away.
If the highest dimension mapped to by pfunc
is higher than the highest dimension in *this
then the number of dimensions in this
will be increased to the highest dimension mapped to by pfunc
.
pfunc | The partial function specifying the destiny of each space dimension. |
The template type parameter Partial_Function must provide the following methods.
returns true
if and only if the represented partial function has an empty codomain (i.e., it is always undefined). The has_empty_codomain()
method will always be called before the methods below. However, if has_empty_codomain()
returns true
, none of the functions below will be called.
returns the maximum value that belongs to the codomain of the partial function. The max_in_codomain()
method is called at most once.
Let be the represented function and
be the value of
i
. If is defined in
, then
is assigned to
j
and true
is returned. If is undefined in
, then
false
is returned. This method is called at most times, where
is the dimension of the vector space enclosing the grid.
The result is undefined if pfunc
does not encode a partial function with the properties described in the specification of the mapping operator.
void Parma_Polyhedra_Library::Grid::expand_space_dimension | ( | Variable | var, |
dimension_type | m | ||
) |
Creates m
copies of the space dimension corresponding to var
.
var | The variable corresponding to the space dimension to be replicated; |
m | The number of replicas to be created. |
std::invalid_argument | Thrown if var does not correspond to a dimension of the vector space. |
std::length_error | Thrown if adding m new space dimensions would cause the vector space to exceed dimension max_space_dimension() . |
If *this
has space dimension , with
, and
var
has space dimension , then the
-th space dimension is expanded to
m
new space dimensions ,
,
,
.
void Parma_Polyhedra_Library::Grid::fold_space_dimensions | ( | const Variables_Set & | vars, |
Variable | dest | ||
) |
Folds the space dimensions in vars
into dest
.
vars | The set of Variable objects corresponding to the space dimensions to be folded; |
dest | The variable corresponding to the space dimension that is the destination of the folding operation. |
std::invalid_argument | Thrown if *this is dimension-incompatible with dest or with one of the Variable objects contained in vars . Also thrown if dest is contained in vars . |
If *this
has space dimension , with
,
dest
has space dimension ,
vars
is a set of variables whose maximum space dimension is also less than or equal to , and
dest
is not a member of vars
, then the space dimensions corresponding to variables in vars
are folded into the -th space dimension.
|
inline |
Returns a 32-bit hash code for *this
.
If x
and y
are such that x == y
, then x.hash_code() == y.hash_code()
.
|
related |
Output operator.
Writes a textual representation of gr
on s:
false
is written if gr
is an empty grid; true
is written if gr
is a universe grid; a minimized system of congruences defining gr
is written otherwise, all congruences in one row separated by ", "s.
Returns true
if and only if x
and y
are the same grid.
Note that x
and y
may be dimension-incompatible grids: in those cases, the value false
is returned.
Returns true
if and only if x
and y
are different grids.
Note that x
and y
may be dimension-incompatible grids: in those cases, the value true
is returned.