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

A dimension of the vector space. More...

#include <Variable.defs.hh>

List of all members.

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.
typedef void output_function_type (std::ostream &s, const Variable &v)
 Type of output functions.

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_type * get_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_type * current_output_function = 0
 Pointer to the current output function.

Friends

class Init
std::ostream & operator<< (std::ostream &s, const Variable &v)
 Output operator.

Related Functions

(Note that these are not member functions.)

bool less (Variable v, Variable w)
 Defines a total ordering on variables.

Classes

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


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 80 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 the i+1 exceeds Variable::max_space_dimension().

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

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


Member Function Documentation

dimension_type Parma_Polyhedra_Library::Variable::id (  )  const [inline]

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

Returns the maximum space dimension a Variable can handle.

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

References Parma_Polyhedra_Library::not_a_dimension().

Referenced by OK().

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

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 51 of file Variable.inlines.hh.

References varid.

Referenced by Parma_Polyhedra_Library::Polyhedron::affine_image(), Parma_Polyhedra_Library::Grid::affine_image(), Parma_Polyhedra_Library::Polyhedron::affine_preimage(), Parma_Polyhedra_Library::Grid::affine_preimage(), Parma_Polyhedra_Library::Polyhedron::bounded_affine_image(), Parma_Polyhedra_Library::Polyhedron::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::expand_space_dimension(), Parma_Polyhedra_Library::Grid::expand_space_dimension(), Parma_Polyhedra_Library::Polyhedron::fold_space_dimensions(), Parma_Polyhedra_Library::Grid::fold_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_image(), Parma_Polyhedra_Library::Grid::generalized_affine_image(), Parma_Polyhedra_Library::Polyhedron::generalized_affine_preimage(), Parma_Polyhedra_Library::Grid::generalized_affine_preimage(), Parma_Polyhedra_Library::BD_Shape< T >::relation_with(), 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(), and Parma_Polyhedra_Library::Congruence::throw_dimension_incompatible().

00051                                 {
00052   return varid + 1;
00053 }

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 61 of file Variable.inlines.hh.

References external_memory_in_bytes().

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

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 56 of file Variable.inlines.hh.

Referenced by total_memory_in_bytes().

00056                                          {
00057   return 0;
00058 }

bool Parma_Polyhedra_Library::Variable::OK (  )  const

Checks if all the invariants are satisfied.

Definition at line 35 of file Variable.cc.

References id(), and max_space_dimension().

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

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

Type of output functions.

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 66 of file Variable.inlines.hh.

References current_output_function.

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

00066                                                      {
00067   current_output_function = p;
00068 }

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

Returns the pointer to the current output function.

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

References current_output_function.

00071                               {
00072   return current_output_function;
00073 }

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

The default output function.

Definition at line 40 of file Variable.cc.

References id(), and varid.

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

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


Friends And Related Function Documentation

friend class Init [friend]

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

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

Output operator.

Definition at line 49 of file Variable.cc.

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

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

Defines a total ordering on variables.

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

References id().

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

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


Member Data Documentation

The index of the Cartesian axis.

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

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

PPL::Variable::output_function_type * Parma_Polyhedra_Library::Variable::current_output_function = 0 [static, private]

Pointer to the current output function.

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

Referenced by get_output_function(), and set_output_function().


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

Generated on Wed Jul 16 22:55:46 2008 for PPL by  doxygen 1.5.6