Parma_Polyhedra_Library::Variable Class Reference
[C++ Language Interface]

A dimension of the vector space. More...

#include <Variable.defs.hh>

List of all members.

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.

Public Member Functions

 Variable (dimension_type i)
 Builds the variable corresponding to the Cartesian axis of index i.
dimension_type id () const
 Returns the index of the Cartesian axis associated to the variable.
dimension_type space_dimension () const
 Returns the dimension of the vector space enclosing *this.
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.
bool OK () const
 Checks if all the invariants are satisfied.

Static Public Member Functions

static dimension_type max_space_dimension ()
 Returns the maximum space dimension a Variable can handle.
static void set_output_function (output_function_type *p)
 Sets the output function to be used for printing Variable objects.
static output_function_typeget_output_function ()
 Returns the pointer to the current output function.

Static Private Member Functions

static void default_output_function (std::ostream &s, const Variable &v)
 The default output function.

Private Attributes

dimension_type varid
 The index of the Cartesian axis.

Static Private Attributes

static output_function_typecurrent_output_function = 0
 Pointer to the current output function.

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)
 Output operator.
bool less (Variable v, Variable w)
 Defines a total ordering on variables.

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 81 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 114 of file Variable.defs.hh.


Constructor & Destructor Documentation

Parma_Polyhedra_Library::Variable::Variable ( dimension_type  i  )  [inline, explicit]

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

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

Definition at line 38 of file Variable.inlines.hh.

00039   : varid(i < max_space_dimension()
00040           ? i
00041           : (throw std::length_error("PPL::Variable::Variable(i):\n"
00042                                      "i exceeds the maximum allowed "
00043                                      "variable identifier."), i)) {
00044 }


Member Function Documentation

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

The default output function.

Definition at line 39 of file Variable.cc.

References id(), and varid.

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

00039                                                                      {
00040   dimension_type varid = v.id();
00041   s << static_cast<char>('A' + varid % 26);
00042   if (dimension_type i = varid / 26)
00043     s << i;
00044 }

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().

00057                                          {
00058   return 0;
00059 }

Variable::output_function_type * Parma_Polyhedra_Library::Variable::get_output_function (  )  [inline, static]

Returns the pointer to the current output function.

Definition at line 72 of file Variable.inlines.hh.

References current_output_function.

00072                               {
00073   return current_output_function;
00074 }

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::Octagonal_Shape< T >::affine_image(), Parma_Polyhedra_Library::Box< ITV >::affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::affine_image(), Parma_Polyhedra_Library::Octagonal_Shape< T >::affine_preimage(), Parma_Polyhedra_Library::Box< ITV >::affine_preimage(), Parma_Polyhedra_Library::BD_Shape< T >::affine_preimage(), Parma_Polyhedra_Library::Octagonal_Shape< T >::bounded_affine_image(), Parma_Polyhedra_Library::Box< ITV >::bounded_affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::bounded_affine_image(), Parma_Polyhedra_Library::Octagonal_Shape< T >::bounded_affine_preimage(), Parma_Polyhedra_Library::Box< ITV >::bounded_affine_preimage(), Parma_Polyhedra_Library::BD_Shape< T >::bounded_affine_preimage(), Parma_Polyhedra_Library::Linear_Expression::coefficient(), Parma_Polyhedra_Library::Generator::coefficient(), Parma_Polyhedra_Library::Constraint::coefficient(), Parma_Polyhedra_Library::Congruence::coefficient(), Parma_Polyhedra_Library::Polyhedron::constrains(), Parma_Polyhedra_Library::Grid::constrains(), default_output_function(), Parma_Polyhedra_Library::Polyhedron::expand_space_dimension(), Parma_Polyhedra_Library::Octagonal_Shape< T >::expand_space_dimension(), Parma_Polyhedra_Library::Grid::expand_space_dimension(), Parma_Polyhedra_Library::Box< ITV >::expand_space_dimension(), Parma_Polyhedra_Library::BD_Shape< T >::expand_space_dimension(), Parma_Polyhedra_Library::Polyhedron::fold_space_dimensions(), Parma_Polyhedra_Library::Octagonal_Shape< T >::fold_space_dimensions(), Parma_Polyhedra_Library::Grid::fold_space_dimensions(), Parma_Polyhedra_Library::Box< ITV >::fold_space_dimensions(), Parma_Polyhedra_Library::BD_Shape< T >::fold_space_dimensions(), Parma_Polyhedra_Library::Octagonal_Shape< T >::generalized_affine_image(), Parma_Polyhedra_Library::Box< ITV >::generalized_affine_image(), Parma_Polyhedra_Library::BD_Shape< T >::generalized_affine_image(), Parma_Polyhedra_Library::Octagonal_Shape< T >::generalized_affine_preimage(), Parma_Polyhedra_Library::BD_Shape< T >::generalized_affine_preimage(), Parma_Polyhedra_Library::Box< ITV >::get_interval(), 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(), OK(), Parma_Polyhedra_Library::PIP_Solution_Node::parametric_values(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine(), Parma_Polyhedra_Library::BD_Shape< T >::refine(), Parma_Polyhedra_Library::Box< ITV >::set_interval(), Parma_Polyhedra_Library::Octagonal_Shape< T >::unconstrain(), Parma_Polyhedra_Library::Box< ITV >::unconstrain(), and Parma_Polyhedra_Library::Variables_Set::Variables_Set().

00047                    {
00048   return varid;
00049 }

dimension_type Parma_Polyhedra_Library::Variable::max_space_dimension (  )  [inline, static]

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 OK().

00033                               {
00034   return not_a_dimension() - 1;
00035 }

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().

00034                       {
00035   return id() < max_space_dimension();
00036 }

void Parma_Polyhedra_Library::Variable::set_output_function ( output_function_type p  )  [inline, static]

Sets the output function to be used for printing Variable objects.

Definition at line 67 of file Variable.inlines.hh.

References current_output_function.

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

00067                                                      {
00068   current_output_function = p;
00069 }

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::Polyhedron::affine_image(), Parma_Polyhedra_Library::Grid::affine_image(), Parma_Polyhedra_Library::Box< ITV >::affine_image(), Parma_Polyhedra_Library::Polyhedron::affine_preimage(), Parma_Polyhedra_Library::Grid::affine_preimage(), Parma_Polyhedra_Library::Box< ITV >::affine_preimage(), Parma_Polyhedra_Library::Polyhedron::bounded_affine_image(), Parma_Polyhedra_Library::Grid::bounded_affine_image(), Parma_Polyhedra_Library::Box< ITV >::bounded_affine_image(), Parma_Polyhedra_Library::Polyhedron::bounded_affine_preimage(), Parma_Polyhedra_Library::Grid::bounded_affine_preimage(), Parma_Polyhedra_Library::Box< ITV >::bounded_affine_preimage(), Parma_Polyhedra_Library::Linear_Expression::coefficient(), Parma_Polyhedra_Library::Grid_Generator::coefficient(), Parma_Polyhedra_Library::Generator::coefficient(), Parma_Polyhedra_Library::Constraint::coefficient(), Parma_Polyhedra_Library::Congruence::coefficient(), Parma_Polyhedra_Library::Polyhedron::constrains(), Parma_Polyhedra_Library::Pointset_Powerset< PSET >::constrains(), Parma_Polyhedra_Library::Octagonal_Shape< T >::constrains(), Parma_Polyhedra_Library::Grid::constrains(), Parma_Polyhedra_Library::Box< ITV >::constrains(), Parma_Polyhedra_Library::BD_Shape< T >::constrains(), Parma_Polyhedra_Library::Polyhedron::expand_space_dimension(), Parma_Polyhedra_Library::Grid::expand_space_dimension(), Parma_Polyhedra_Library::Box< ITV >::expand_space_dimension(), Parma_Polyhedra_Library::BD_Shape< T >::expand_space_dimension(), Parma_Polyhedra_Library::Polyhedron::fold_space_dimensions(), Parma_Polyhedra_Library::Octagonal_Shape< T >::fold_space_dimensions(), Parma_Polyhedra_Library::Grid::fold_space_dimensions(), Parma_Polyhedra_Library::Box< ITV >::fold_space_dimensions(), Parma_Polyhedra_Library::BD_Shape< T >::fold_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_image(), Parma_Polyhedra_Library::Grid::generalized_affine_image(), Parma_Polyhedra_Library::Box< ITV >::generalized_affine_image(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_preimage(), Parma_Polyhedra_Library::Grid::generalized_affine_preimage(), Parma_Polyhedra_Library::Box< ITV >::generalized_affine_preimage(), Parma_Polyhedra_Library::Box< ITV >::get_interval(), Parma_Polyhedra_Library::Linear_Expression::Linear_Expression(), Parma_Polyhedra_Library::PIP_Solution_Node::parametric_values(), Parma_Polyhedra_Library::Octagonal_Shape< T >::relation_with(), Parma_Polyhedra_Library::Box< ITV >::set_interval(), Parma_Polyhedra_Library::Polyhedron::throw_dimension_incompatible(), Parma_Polyhedra_Library::Grid::throw_dimension_incompatible(), Parma_Polyhedra_Library::Generator::throw_dimension_incompatible(), Parma_Polyhedra_Library::Constraint::throw_dimension_incompatible(), Parma_Polyhedra_Library::Congruence::throw_dimension_incompatible(), Parma_Polyhedra_Library::Polyhedron::unconstrain(), Parma_Polyhedra_Library::Grid::unconstrain(), and Parma_Polyhedra_Library::BD_Shape< T >::unconstrain().

00052                                 {
00053   return varid + 1;
00054 }

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().

00062                                       {
00063   return sizeof(*this) + external_memory_in_bytes();
00064 }


Friends And Related Function Documentation

friend class Init [friend]

Definition at line 134 of file Variable.defs.hh.

bool less ( Variable  v,
Variable  w 
) [related]

Defines a total ordering on variables.

Definition at line 78 of file Variable.inlines.hh.

References id().

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

00078                                          {
00079   return v.id() < w.id();
00080 }

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

Output operator.

Definition at line 48 of file Variable.cc.

00048                                                             {
00049   (*Variable::current_output_function)(s, v);
00050   return s;
00051 }

std::ostream& Parma_Polyhedra_Library::IO_Operators::operator<< ( std::ostream &  s,
const Variable v 
) [friend]

Member Data Documentation

Pointer to the current output function.

Definition at line 141 of file Variable.defs.hh.

Referenced by get_output_function(), and set_output_function().

The index of the Cartesian axis.

Definition at line 131 of file Variable.defs.hh.

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


The documentation for this class was generated from the following files:
Generated on Sun Feb 27 16:20:23 2011 for PPL by  doxygen 1.6.3