PPL  1.2
Parma_Polyhedra_Library::Variable Class Reference

A dimension of the vector space. More...

#include <Variable_defs.hh>

Classes

struct  Compare
 Binary predicate defining the total ordering on variables. More...
 

Public Types

typedef void output_function_type(std::ostream &s, const Variable v)
 Type of output functions. More...
 

Public Member Functions

 Variable (dimension_type i)
 Builds the variable corresponding to the Cartesian axis of index i. More...
 
dimension_type id () const
 Returns the index of the Cartesian axis associated to the variable. More...
 
dimension_type space_dimension () const
 Returns the dimension of the vector space enclosing *this. More...
 
memory_size_type total_memory_in_bytes () const
 Returns the total size in bytes of the memory occupied by *this. More...
 
memory_size_type external_memory_in_bytes () const
 Returns the size in bytes of the memory managed by *this. More...
 
bool OK () const
 Checks if all the invariants are satisfied. More...
 
void m_swap (Variable &v)
 Swaps *this and v. More...
 

Static Public Member Functions

static dimension_type max_space_dimension ()
 Returns the maximum space dimension a Variable can handle. More...
 
static void default_output_function (std::ostream &s, const Variable v)
 The default output function. More...
 
static void set_output_function (output_function_type *p)
 Sets the output function to be used for printing Variable objects. More...
 
static output_function_typeget_output_function ()
 Returns the pointer to the current output function. More...
 

Private Attributes

dimension_type varid
 The index of the Cartesian axis. More...
 

Static Private Attributes

static output_function_typecurrent_output_function = 0
 Pointer to the current output function. More...
 

Friends

class Init
 
std::ostream & Parma_Polyhedra_Library::IO_Operators::operator<< (std::ostream &s, const Variable v)
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &s, const Variable v)
 
std::ostream & operator<< (std::ostream &s, const Variable v)
 Output operator. More...
 
bool less (Variable v, Variable w)
 Defines a total ordering on variables. More...
 
void swap (Variable &x, Variable &y)
 
bool less (const Variable v, const Variable w)
 

Detailed Description

A dimension of the vector space.

An object of the class Variable represents a dimension of the space, that is one of the Cartesian axes. Variables are used as basic blocks in order to build more complex linear expressions. Each variable is identified by a non-negative integer, representing the index of the corresponding Cartesian axis (the first axis has index 0). The space dimension of a variable is the dimension of the vector space made by all the Cartesian axes having an index less than or equal to that of the considered variable; thus, if a variable has index $i$, its space dimension is $i+1$.

Note that the ``meaning'' of an object of the class Variable is completely specified by the integer index provided to its constructor: be careful not to be mislead by C++ language variable names. For instance, in the following example the linear expressions e1 and e2 are equivalent, since the two variables x and z denote the same Cartesian axis.

Variable x(0);
Variable y(1);
Variable z(0);
Linear_Expression e1 = x + y;
Linear_Expression e2 = y + z;

Definition at line 85 of file Variable_defs.hh.

Member Typedef Documentation

typedef void Parma_Polyhedra_Library::Variable::output_function_type(std::ostream &s, const Variable v)

Type of output functions.

Definition at line 118 of file Variable_defs.hh.

Constructor & Destructor Documentation

Parma_Polyhedra_Library::Variable::Variable ( dimension_type  i)
inlineexplicit

Builds the variable corresponding to the Cartesian axis of index i.

Exceptions
std::length_errorThrown if i+1 exceeds Variable::max_space_dimension().

Definition at line 38 of file Variable_inlines.hh.

39  : varid((i < max_space_dimension())
40  ? i
41  : (throw std::length_error("PPL::Variable::Variable(i):\n"
42  "i exceeds the maximum allowed "
43  "variable identifier."), i)) {
44 }
dimension_type varid
The index of the Cartesian axis.
static dimension_type max_space_dimension()
Returns the maximum space dimension a Variable can handle.

Member Function Documentation

void Parma_Polyhedra_Library::Variable::default_output_function ( std::ostream &  s,
const Variable  v 
)
static

The default output function.

Definition at line 39 of file Variable.cc.

References id().

Referenced by Parma_Polyhedra_Library::Init::Init().

39  {
40  const dimension_type varid = v.id();
41  static const char var_name_letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
42  const dimension_type num_letters = sizeof(var_name_letters) - 1;
43  s << var_name_letters[varid % num_letters];
44  if (const dimension_type i = varid / num_letters) {
45  s << i;
46  }
47 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type varid
The index of the Cartesian axis.
memory_size_type Parma_Polyhedra_Library::Variable::external_memory_in_bytes ( ) const
inline

Returns the size in bytes of the memory managed by *this.

Definition at line 57 of file Variable_inlines.hh.

Referenced by total_memory_in_bytes().

57  {
58  return 0;
59 }
dimension_type Parma_Polyhedra_Library::Variable::id ( ) const
inline

Returns the index of the Cartesian axis associated to the variable.

Definition at line 47 of file Variable_inlines.hh.

References varid.

Referenced by Parma_Polyhedra_Library::affine_form_image(), Parma_Polyhedra_Library::Box< ITV >::affine_form_image(), Parma_Polyhedra_Library::Octagonal_Shape< T >::affine_form_image(), Parma_Polyhedra_Library::BD_Shape< T >::affine_form_image(), Parma_Polyhedra_Library::Polyhedron::affine_form_image(), Parma_Polyhedra_Library::Box< ITV >::affine_image(), Parma_Polyhedra_Library::Octagonal_Shape< T >::affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::affine_image(), Parma_Polyhedra_Library::Box< ITV >::affine_preimage(), Parma_Polyhedra_Library::Octagonal_Shape< T >::affine_preimage(), Parma_Polyhedra_Library::BD_Shape< T >::affine_preimage(), Parma_Polyhedra_Library::Box< ITV >::bounded_affine_image(), Parma_Polyhedra_Library::Octagonal_Shape< T >::bounded_affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::bounded_affine_image(), Parma_Polyhedra_Library::Box< ITV >::bounded_affine_preimage(), Parma_Polyhedra_Library::Octagonal_Shape< T >::bounded_affine_preimage(), Parma_Polyhedra_Library::BD_Shape< T >::bounded_affine_preimage(), Parma_Polyhedra_Library::Box< ITV >::bounds(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::coefficient(), Parma_Polyhedra_Library::Linear_Form< C >::coefficient(), Parma_Polyhedra_Library::Polyhedron::constrains(), default_output_function(), Parma_Polyhedra_Library::Box< ITV >::expand_space_dimension(), Parma_Polyhedra_Library::Octagonal_Shape< T >::expand_space_dimension(), Parma_Polyhedra_Library::BD_Shape< T >::expand_space_dimension(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_system_PR(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_system_PR_original(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_systems_MS(), Parma_Polyhedra_Library::Box< ITV >::fold_space_dimensions(), Parma_Polyhedra_Library::Octagonal_Shape< T >::fold_space_dimensions(), Parma_Polyhedra_Library::BD_Shape< T >::fold_space_dimensions(), Parma_Polyhedra_Library::Grid::fold_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::fold_space_dimensions(), Parma_Polyhedra_Library::Box< ITV >::generalized_affine_image(), Parma_Polyhedra_Library::Octagonal_Shape< T >::generalized_affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::generalized_affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::generalized_affine_preimage(), Parma_Polyhedra_Library::Octagonal_Shape< T >::generalized_affine_preimage(), Parma_Polyhedra_Library::Box< ITV >::get_interval(), Parma_Polyhedra_Library::Box< ITV >::has_lower_bound(), Parma_Polyhedra_Library::Box< ITV >::has_upper_bound(), Parma_Polyhedra_Library::BD_Shape< T >::incremental_shortest_path_closure_assign(), Parma_Polyhedra_Library::Octagonal_Shape< T >::incremental_strong_closure_assign(), Parma_Polyhedra_Library::Variables_Set::insert(), less(), Parma_Polyhedra_Library::Polyhedron::modify_according_to_evolution(), OK(), Parma_Polyhedra_Library::PIP_Solution_Node::parametric_values(), Parma_Polyhedra_Library::Box< ITV >::propagate_constraint_no_check(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine(), Parma_Polyhedra_Library::BD_Shape< T >::refine(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::Box< ITV >::set_interval(), Parma_Polyhedra_Library::Linear_System< Row >::shift_space_dimensions(), Parma_Polyhedra_Library::Box< ITV >::unconstrain(), Parma_Polyhedra_Library::Octagonal_Shape< T >::unconstrain(), Parma_Polyhedra_Library::Variables_Set::Variables_Set(), and Parma_Polyhedra_Library::Implementation::wrap_assign_ind().

47  {
48  return varid;
49 }
dimension_type varid
The index of the Cartesian axis.
void Parma_Polyhedra_Library::Variable::m_swap ( Variable v)
inline

Swaps *this and v.

Definition at line 88 of file Variable_inlines.hh.

References swap(), Parma_Polyhedra_Library::swap(), and varid.

Referenced by Parma_Polyhedra_Library::swap().

88  {
89  using std::swap;
90  swap(varid, v.varid);
91 }
void swap(Variable &x, Variable &y)
dimension_type varid
The index of the Cartesian axis.
void swap(Variable &x, Variable &y)
dimension_type Parma_Polyhedra_Library::Variable::max_space_dimension ( )
inlinestatic

Returns the maximum space dimension a Variable can handle.

Definition at line 33 of file Variable_inlines.hh.

References Parma_Polyhedra_Library::not_a_dimension().

Referenced by Parma_Polyhedra_Library::max_space_dimension(), Parma_Polyhedra_Library::Variables_Set::max_space_dimension(), and OK().

33  {
34  return not_a_dimension() - 1;
35 }
dimension_type not_a_dimension()
Returns a value that does not designate a valid dimension.
bool Parma_Polyhedra_Library::Variable::OK ( ) const

Checks if all the invariants are satisfied.

Definition at line 34 of file Variable.cc.

References id(), and max_space_dimension().

Referenced by Parma_Polyhedra_Library::Variables_Set::OK().

34  {
35  return id() < max_space_dimension();
36 }
static dimension_type max_space_dimension()
Returns the maximum space dimension a Variable can handle.
dimension_type id() const
Returns the index of the Cartesian axis associated to the variable.
dimension_type Parma_Polyhedra_Library::Variable::space_dimension ( ) const
inline

Returns the dimension of the vector space enclosing *this.

The returned value is id()+1.

Definition at line 52 of file Variable_inlines.hh.

References varid.

Referenced by Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::add_mul_assign(), Parma_Polyhedra_Library::Box< ITV >::affine_form_image(), Parma_Polyhedra_Library::Grid_Generator_System::affine_image(), Parma_Polyhedra_Library::Generator_System::affine_image(), Parma_Polyhedra_Library::Box< ITV >::affine_image(), Parma_Polyhedra_Library::Grid::affine_image(), Parma_Polyhedra_Library::Polyhedron::affine_image(), Parma_Polyhedra_Library::Congruence::affine_preimage(), Parma_Polyhedra_Library::Constraint_System::affine_preimage(), Parma_Polyhedra_Library::Congruence_System::affine_preimage(), Parma_Polyhedra_Library::Box< ITV >::affine_preimage(), Parma_Polyhedra_Library::BD_Shape< T >::affine_preimage(), Parma_Polyhedra_Library::Grid::affine_preimage(), Parma_Polyhedra_Library::Polyhedron::affine_preimage(), Parma_Polyhedra_Library::Box< ITV >::bounded_affine_image(), Parma_Polyhedra_Library::Grid::bounded_affine_image(), Parma_Polyhedra_Library::Polyhedron::bounded_affine_image(), Parma_Polyhedra_Library::Box< ITV >::bounded_affine_preimage(), Parma_Polyhedra_Library::Grid::bounded_affine_preimage(), Parma_Polyhedra_Library::Polyhedron::bounded_affine_preimage(), Parma_Polyhedra_Library::Expression_Hide_Last< T >::coefficient(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::coefficient(), Parma_Polyhedra_Library::Congruence::coefficient(), Parma_Polyhedra_Library::Linear_Form< C >::coefficient(), Parma_Polyhedra_Library::Constraint::coefficient(), Parma_Polyhedra_Library::Grid_Generator::coefficient(), Parma_Polyhedra_Library::Generator::coefficient(), Parma_Polyhedra_Library::Pointset_Powerset< PSET >::constrains(), Parma_Polyhedra_Library::Box< ITV >::constrains(), Parma_Polyhedra_Library::Polyhedron::constrains(), Parma_Polyhedra_Library::Octagonal_Shape< T >::constrains(), Parma_Polyhedra_Library::Grid::constrains(), Parma_Polyhedra_Library::BD_Shape< T >::constrains(), Parma_Polyhedra_Library::BD_Shape< T >::deduce_u_minus_v_bounds(), Parma_Polyhedra_Library::Box< ITV >::expand_space_dimension(), Parma_Polyhedra_Library::BD_Shape< T >::expand_space_dimension(), Parma_Polyhedra_Library::Grid::expand_space_dimension(), Parma_Polyhedra_Library::Polyhedron::expand_space_dimension(), Parma_Polyhedra_Library::Box< ITV >::fold_space_dimensions(), Parma_Polyhedra_Library::Octagonal_Shape< T >::fold_space_dimensions(), Parma_Polyhedra_Library::BD_Shape< T >::fold_space_dimensions(), Parma_Polyhedra_Library::Grid::fold_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::fold_space_dimensions(), Parma_Polyhedra_Library::BD_Shape< T >::frequency(), Parma_Polyhedra_Library::Box< ITV >::generalized_affine_image(), Parma_Polyhedra_Library::Grid::generalized_affine_image(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_image(), Parma_Polyhedra_Library::Box< ITV >::generalized_affine_preimage(), Parma_Polyhedra_Library::Grid::generalized_affine_preimage(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_preimage(), Parma_Polyhedra_Library::Expression_Hide_Last< T >::get(), Parma_Polyhedra_Library::Linear_Expression::get(), Parma_Polyhedra_Library::Box< ITV >::get_interval(), Parma_Polyhedra_Library::Expression_Hide_Last< T >::have_a_common_variable(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::have_a_common_variable(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::linear_combine(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::Linear_Expression_Impl(), Parma_Polyhedra_Library::Linear_Form< C >::Linear_Form(), Parma_Polyhedra_Library::Expression_Hide_Last< T >::lower_bound(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::lower_bound(), Parma_Polyhedra_Library::Linear_Form< C >::operator+(), Parma_Polyhedra_Library::Linear_Expression::operator+(), Parma_Polyhedra_Library::Linear_Form< C >::operator+=(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::operator+=(), Parma_Polyhedra_Library::Linear_Expression::operator-(), Parma_Polyhedra_Library::Linear_Form< C >::operator-(), Parma_Polyhedra_Library::Linear_Form< C >::operator-=(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::operator-=(), Parma_Polyhedra_Library::Constraint::operator==(), Parma_Polyhedra_Library::Constraint::operator>(), Parma_Polyhedra_Library::Constraint::operator>=(), Parma_Polyhedra_Library::PIP_Solution_Node::parametric_values(), Parma_Polyhedra_Library::Octagonal_Shape< T >::relation_with(), Parma_Polyhedra_Library::Linear_Expression::set(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::set_coefficient(), Parma_Polyhedra_Library::Box< ITV >::set_interval(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::shift_space_dimensions(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::sub_mul_assign(), Parma_Polyhedra_Library::Linear_System< Row >::swap_space_dimensions(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::swap_space_dimensions(), Parma_Polyhedra_Library::Constraint::swap_space_dimensions(), Parma_Polyhedra_Library::Grid_Generator::swap_space_dimensions(), Parma_Polyhedra_Library::Generator::swap_space_dimensions(), Parma_Polyhedra_Library::Congruence::throw_dimension_incompatible(), Parma_Polyhedra_Library::Constraint::throw_dimension_incompatible(), Parma_Polyhedra_Library::Generator::throw_dimension_incompatible(), Parma_Polyhedra_Library::Grid_Generator::throw_dimension_incompatible(), Parma_Polyhedra_Library::Grid::throw_dimension_incompatible(), Parma_Polyhedra_Library::Polyhedron::throw_dimension_incompatible(), Parma_Polyhedra_Library::Polyhedron::unconstrain(), Parma_Polyhedra_Library::Grid::unconstrain(), and Parma_Polyhedra_Library::BD_Shape< T >::unconstrain().

52  {
53  return varid + 1;
54 }
dimension_type varid
The index of the Cartesian axis.
memory_size_type Parma_Polyhedra_Library::Variable::total_memory_in_bytes ( ) const
inline

Returns the total size in bytes of the memory occupied by *this.

Definition at line 62 of file Variable_inlines.hh.

References external_memory_in_bytes().

62  {
63  return sizeof(*this) + external_memory_in_bytes();
64 }
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.

Friends And Related Function Documentation

friend class Init
friend

Definition at line 144 of file Variable_defs.hh.

bool less ( Variable  v,
Variable  w 
)
related

Defines a total ordering on variables.

Referenced by Parma_Polyhedra_Library::Variable::Compare::operator()().

bool less ( const Variable  v,
const Variable  w 
)
related

Definition at line 78 of file Variable_inlines.hh.

References id().

78  {
79  return v.id() < w.id();
80 }
std::ostream & operator<< ( std::ostream &  s,
const Variable  v 
)
related

Output operator.

std::ostream & operator<< ( std::ostream &  s,
const Variable  v 
)
related

Definition at line 51 of file Variable.cc.

51  {
52  (*Variable::current_output_function)(s, v);
53  return s;
54 }
std::ostream& Parma_Polyhedra_Library::IO_Operators::operator<< ( std::ostream &  s,
const Variable  v 
)
friend
void swap ( Variable x,
Variable y 
)
related

Definition at line 94 of file Variable_inlines.hh.

Referenced by m_swap().

94  {
95  x.m_swap(y);
96 }

Member Data Documentation

PPL::Variable::output_function_type * Parma_Polyhedra_Library::Variable::current_output_function = 0
staticprivate

Pointer to the current output function.

Definition at line 151 of file Variable_defs.hh.

Referenced by get_output_function(), and set_output_function().

dimension_type Parma_Polyhedra_Library::Variable::varid
private

The index of the Cartesian axis.

Definition at line 141 of file Variable_defs.hh.

Referenced by id(), m_swap(), and space_dimension().


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