#include <Grid_Generator.defs.hh>
Public Types | |
enum | Type { LINE, PARAMETER, POINT } |
The generator type. More... | |
Public Member Functions | |
Grid_Generator (const Grid_Generator &g) | |
Ordinary copy-constructor. | |
~Grid_Generator () | |
Destructor. | |
Grid_Generator & | operator= (const Grid_Generator &g) |
Assignment operator. | |
Grid_Generator & | operator= (const Generator &g) |
Assignment operator. | |
dimension_type | space_dimension () const |
Returns the dimension of the vector space enclosing *this . | |
Type | type () const |
Returns the generator type of *this . | |
bool | is_line () const |
Returns true if and only if *this is a line. | |
bool | is_parameter () const |
Returns true if and only if *this is a parameter. | |
bool | is_line_or_parameter () const |
Returns true if and only if *this is a line or a parameter. | |
bool | is_point () const |
Returns true if and only if *this is a point. | |
bool | is_parameter_or_point () const |
Returns true if and only if *this row represents a parameter or a point. | |
Coefficient_traits::const_reference | coefficient (Variable v) const |
Returns the coefficient of v in *this . | |
Coefficient_traits::const_reference | divisor () const |
Returns the divisor of *this . | |
memory_size_type | total_memory_in_bytes () const |
Returns a lower bound to 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 | is_equivalent_to (const Grid_Generator &y) const |
Returns true if and only if *this and y are equivalent generators. | |
bool | is_equal_to (const Grid_Generator &y) const |
Returns true if *this is exactly equal to y . | |
bool | is_equal_at_dimension (dimension_type dim, const Grid_Generator &gg) const |
Returns true if *this is equal to gg in dimension dim . | |
bool | all_homogeneous_terms_are_zero () const |
Returns true if and only if all the homogeneous terms of *this are ![]() | |
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. | |
bool | OK () const |
Checks if all the invariants are satisfied. | |
void | swap (Grid_Generator &y) |
Swaps *this with y . | |
void | coefficient_swap (Grid_Generator &y) |
Swaps *this with y , leaving *this with the original capacity. | |
Static Public Member Functions | |
static Grid_Generator | grid_line (const Linear_Expression &e) |
Returns the line of direction e . | |
static Grid_Generator | parameter (const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one()) |
Returns the parameter of direction e and size e/d . | |
static Grid_Generator | grid_point (const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one()) |
Returns the point at e / d . | |
static dimension_type | max_space_dimension () |
Returns the maximum space dimension a Grid_Generator can handle. | |
static void | initialize () |
Initializes the class. | |
static void | finalize () |
Finalizes the class. | |
static const Grid_Generator & | zero_dim_point () |
Returns the origin of the zero-dimensional space ![]() | |
Private Member Functions | |
void | scale_to_divisor (Coefficient_traits::const_reference d) |
Scales *this to be represented with a divisor of d (if \*this is a parameter or point). | |
Grid_Generator (Generator g) | |
Constructs from polyhedron generator g , stealing the underlying data structures from g . | |
dimension_type | size () const |
Returns the actual size of this . | |
void | negate (dimension_type start, dimension_type end) |
Negates the elements from index start to index end . | |
void | set_divisor (Coefficient_traits::const_reference d) |
Sets the divisor of *this to d . | |
void | set_is_line () |
Sets the Linear_Row kind to LINE_OR_EQUALITY . | |
void | set_is_parameter_or_point () |
Sets the Linear_Row kind to RAY_OR_POINT_OR_INEQUALITY . | |
void | set_is_parameter () |
Converts the Grid_Generator into a parameter. | |
void | strong_normalize () |
Strong normalization: ensures that different Grid_Generator objects represent different hyperplanes or hyperspaces. | |
Coefficient & | operator[] (dimension_type k) |
Returns a reference to the element of the row indexed by k . | |
Coefficient_traits::const_reference | operator[] (dimension_type k) const |
Returns a constant reference to the element of the row indexed by k . | |
void | throw_invalid_argument (const char *method, const char *reason) const |
Throw a std::invalid_argument exception containing the appropriate error message. | |
Static Private Attributes | |
static const Grid_Generator * | zero_dim_point_p = 0 |
Holds (between class initialization and finalization) a pointer to the origin of the zero-dimensional space ![]() | |
Friends | |
class | Grid |
class | Parma_Polyhedra_Library::Box |
class | Grid_Generator_System |
class | Grid_Generator_System::const_iterator |
class | Congruence_System |
class | Scalar_Products |
class | Topology_Adjusted_Scalar_Product_Sign |
class | Linear_Expression |
std::ostream & | IO_Operators::operator<< (std::ostream &s, const Grid_Generator &g) |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &s, const Grid_Generator &g) |
Output operator. | |
void | swap (Parma_Polyhedra_Library::Grid_Generator &x, Parma_Polyhedra_Library::Grid_Generator &y) |
Specializes std::swap . | |
bool | operator== (const Grid_Generator &x, const Grid_Generator &y) |
Returns true if and only if x is equivalent to y . | |
bool | operator!= (const Grid_Generator &x, const Grid_Generator &y) |
Returns true if and only if x is not equivalent to y . | |
std::ostream & | operator<< (std::ostream &s, const Grid_Generator::Type &t) |
Output operator. |
An object of the class Grid_Generator is one of the following:
where is the dimension of the space and, for grid_points and parameters,
is the divisor.
grid_line
, parameter
or grid_point
) to a linear expression; the space dimension of the generator is defined as the space dimension of the corresponding linear expression. Linear expressions used to define a generator should be homogeneous (any constant term will be simply ignored). When defining grid points and parameters, an optional Coefficient argument can be used as a common divisor for all the coefficients occurring in the provided linear expression; the default value for this argument is 1.x
, y
and z
are defined as follows: Variable x(0); Variable y(1); Variable z(2);
Grid_Generator l = grid_line(x - y - z);
Grid_Generator l = grid_line(0*x);
Grid_Generator q = parameter(x - y - z);
q
is not the same as the parameter q1
defined by Grid_Generator q1 = parameter(2x - 2y - 2z);
Grid_Generator q = parameter(0*x);
Grid_Generator p = grid_point(1*x + 0*y + 2*z);
Grid_Generator p = grid_point(x + 2*z);
Grid_Generator origin3 = grid_point(0*x + 0*y + 0*z); Grid_Generator origin3_alt = grid_point(0*z);
Grid_Generator origin2 = grid_point(0*y);
point
is optional. Grid_Generator origin0 = Generator::zero_dim_point(); Grid_Generator origin0_alt = grid_point();
grid_point
(the divisor): Grid_Generator p = grid_point(2*x + 0*y + 4*z, 2);
Grid_Generator p1 = grid_point(-15*x + 32*y + 21*z, 10);
Grid_Generator q = parameter(2*x + 0*y + 4*z, 2);
Grid_Generator q = parameter(-15*x + 32*y + 21*z, 10);
g1
is a grid point having coordinates g2
having coordinates if (g1.is_point()) { cout << "Grid point g1: " << g1 << endl; Linear_Expression e; for (dimension_type i = g1.space_dimension(); i-- > 0; ) e += (i + 1) * g1.coefficient(Variable(i)) * Variable(i); Grid_Generator g2 = parameter(e, g1.divisor()); cout << "Parameter g2: " << g2 << endl; } else cout << "Grid Generator g1 is not a grid point." << endl;
Grid_Generator g1 = grid_point(2*x - y + 3*z, 2);
Definition at line 230 of file Grid_Generator.defs.hh.
The generator type.
LINE | The generator is a grid line. |
PARAMETER | The generator is a parameter. |
POINT | The generator is a grid point. |
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 285 of file Grid_Generator.defs.hh.
Parma_Polyhedra_Library::Grid_Generator::Grid_Generator | ( | const Grid_Generator & | g | ) | [inline] |
Ordinary copy-constructor.
Definition at line 29 of file Grid_Generator.inlines.hh.
Referenced by initialize().
00030 : Generator(g) { 00031 }
Parma_Polyhedra_Library::Grid_Generator::~Grid_Generator | ( | ) | [inline] |
Parma_Polyhedra_Library::Grid_Generator::Grid_Generator | ( | Generator | g | ) | [inline, explicit, private] |
Constructs from polyhedron generator g
, stealing the underlying data structures from g
.
The last column in g
becomes the parameter divisor column of the new Grid_Generator.
Definition at line 38 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::swap().
00039 : Generator(Generator::point()) { 00040 Generator::swap(g); 00041 }
PPL::Grid_Generator Parma_Polyhedra_Library::Grid_Generator::grid_line | ( | const Linear_Expression & | e | ) | [inline, static] |
Returns the line of direction e
.
Shorthand for Grid_Generator Grid_Generator::grid_line(const Linear_Expression& e).
std::invalid_argument | Thrown if the homogeneous part of e represents the origin of the vector space. |
Definition at line 209 of file Grid_Generator.inlines.hh.
00209 { 00210 return Grid_Generator::grid_line(e); 00211 }
PPL::Grid_Generator Parma_Polyhedra_Library::Grid_Generator::parameter | ( | const Linear_Expression & | e = Linear_Expression::zero() , |
|
Coefficient_traits::const_reference | d = Coefficient_one() | |||
) | [inline, static] |
Returns the parameter of direction e
and size e/d
.
Shorthand for Grid_Generator Grid_Generator::parameter(const Linear_Expression& e, Coefficient_traits::const_reference d).
Both e
and d
are optional arguments, with default values Linear_Expression::zero() and Coefficient_one(), respectively.
std::invalid_argument | Thrown if d is zero. |
Definition at line 215 of file Grid_Generator.inlines.hh.
00216 { 00217 return Grid_Generator::parameter(e, d); 00218 }
PPL::Grid_Generator Parma_Polyhedra_Library::Grid_Generator::grid_point | ( | const Linear_Expression & | e = Linear_Expression::zero() , |
|
Coefficient_traits::const_reference | d = Coefficient_one() | |||
) | [inline, static] |
Returns the point at e
/ d
.
Shorthand for Grid_Generator Grid_Generator::grid_point(const Linear_Expression& e, Coefficient_traits::const_reference d).
Both e
and d
are optional arguments, with default values Linear_Expression::zero() and Coefficient_one(), respectively.
std::invalid_argument | Thrown if d is zero. |
Definition at line 222 of file Grid_Generator.inlines.hh.
Referenced by initialize().
00223 { 00224 return Grid_Generator::grid_point(e, d); 00225 }
Grid_Generator & Parma_Polyhedra_Library::Grid_Generator::operator= | ( | const Grid_Generator & | g | ) | [inline] |
Assignment operator.
Definition at line 145 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::operator=().
00145 { 00146 Generator::operator=(g); 00147 return *this; 00148 }
Grid_Generator & Parma_Polyhedra_Library::Grid_Generator::operator= | ( | const Generator & | g | ) | [inline] |
Assignment operator.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 151 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::operator=().
00151 { 00152 Generator::operator=(g); 00153 return *this; 00154 }
dimension_type Parma_Polyhedra_Library::Grid_Generator::max_space_dimension | ( | ) | [inline, static] |
Returns the maximum space dimension a Grid_Generator can handle.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 49 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::max_space_dimension().
00049 { 00050 return Generator::max_space_dimension() - 1; 00051 }
dimension_type Parma_Polyhedra_Library::Grid_Generator::space_dimension | ( | ) | const [inline] |
Returns the dimension of the vector space enclosing *this
.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 64 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::space_dimension().
Referenced by Parma_Polyhedra_Library::Grid::add_grid_generator(), coefficient(), Parma_Polyhedra_Library::Grid_Generator_System::insert(), is_equivalent_to(), operator<<(), Parma_Polyhedra_Library::Grid::relation_with(), Parma_Polyhedra_Library::Congruence_System::satisfies_all_congruences(), Parma_Polyhedra_Library::Grid::select_wider_generators(), and Parma_Polyhedra_Library::Grid::throw_dimension_incompatible().
00064 { 00065 return Generator::space_dimension() - 1; 00066 }
Grid_Generator::Type Parma_Polyhedra_Library::Grid_Generator::type | ( | ) | const [inline] |
Returns the generator type of *this
.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 69 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::CLOSURE_POINT, LINE, Parma_Polyhedra_Library::Generator::LINE, PARAMETER, POINT, Parma_Polyhedra_Library::Generator::POINT, Parma_Polyhedra_Library::Generator::RAY, and Parma_Polyhedra_Library::Generator::type().
Referenced by ascii_dump(), is_equal_to(), is_equivalent_to(), Parma_Polyhedra_Library::Grid::map_space_dimensions(), OK(), and operator<<().
00069 { 00070 switch (Generator::type()) { 00071 case Generator::POINT: 00072 return POINT; 00073 case Generator::RAY: 00074 return PARAMETER; 00075 case Generator::LINE: 00076 return LINE; 00077 case Generator::CLOSURE_POINT: 00078 default: 00079 assert(false); 00080 return POINT; 00081 } 00082 }
bool Parma_Polyhedra_Library::Grid_Generator::is_line | ( | ) | const [inline] |
Returns true
if and only if *this
is a line.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 85 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::is_line().
Referenced by coefficient_swap(), Parma_Polyhedra_Library::Grid::constrains(), divisor(), Parma_Polyhedra_Library::Grid::get_covering_box(), Parma_Polyhedra_Library::Grid::multiply_grid(), Parma_Polyhedra_Library::Congruence_System::satisfies_all_congruences(), set_divisor(), set_is_parameter(), and Parma_Polyhedra_Library::Grid::simplify().
00085 { 00086 return Generator::is_line(); 00087 }
bool Parma_Polyhedra_Library::Grid_Generator::is_parameter | ( | ) | const [inline] |
Returns true
if and only if *this
is a parameter.
Definition at line 90 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::is_ray().
Referenced by Parma_Polyhedra_Library::Grid::add_grid_generator(), Parma_Polyhedra_Library::Grid_Generator_System::insert(), and is_equal_to().
00090 { 00091 return is_ray(); 00092 }
bool Parma_Polyhedra_Library::Grid_Generator::is_line_or_parameter | ( | ) | const [inline] |
Returns true
if and only if *this
is a line or a parameter.
Definition at line 95 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::is_line_or_ray().
Referenced by Parma_Polyhedra_Library::Grid::add_grid_generator(), Parma_Polyhedra_Library::Grid::bounds(), divisor(), Parma_Polyhedra_Library::Grid::is_bounded(), Parma_Polyhedra_Library::Grid::relation_with(), set_divisor(), and set_is_parameter().
00095 { 00096 return is_line_or_ray(); 00097 }
bool Parma_Polyhedra_Library::Grid_Generator::is_point | ( | ) | const [inline] |
Returns true
if and only if *this
is a point.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 100 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::is_point().
Referenced by Parma_Polyhedra_Library::Box< ITV >::Box(), Parma_Polyhedra_Library::Grid::get_covering_box(), and Parma_Polyhedra_Library::Grid::time_elapse_assign().
00100 { 00101 return Generator::is_point(); 00102 }
bool Parma_Polyhedra_Library::Grid_Generator::is_parameter_or_point | ( | ) | const [inline] |
Returns true
if and only if *this
row represents a parameter or a point.
Definition at line 105 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::is_ray_or_point_or_inequality().
Referenced by Parma_Polyhedra_Library::Grid::add_grid_generator(), Parma_Polyhedra_Library::Grid::multiply_grid(), Parma_Polyhedra_Library::Grid::normalize_divisors(), Parma_Polyhedra_Library::Grid::reduce_parameter_with_line(), scale_to_divisor(), and Parma_Polyhedra_Library::Grid::simplify().
00105 { 00106 return is_ray_or_point_or_inequality(); 00107 }
Coefficient_traits::const_reference Parma_Polyhedra_Library::Grid_Generator::coefficient | ( | Variable | v | ) | const [inline] |
Returns the coefficient of v
in *this
.
std::invalid_argument | Thrown if the index of v is greater than or equal to the space dimension of *this . |
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 163 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::coefficient(), space_dimension(), Parma_Polyhedra_Library::Variable::space_dimension(), and Parma_Polyhedra_Library::Generator::throw_dimension_incompatible().
Referenced by Parma_Polyhedra_Library::Grid::constrains(), Parma_Polyhedra_Library::Grid::map_space_dimensions(), Parma_Polyhedra_Library::Grid::max_min(), Parma_Polyhedra_Library::Grid::relation_with(), and Parma_Polyhedra_Library::Grid::select_wider_generators().
00163 { 00164 if (v.space_dimension() > space_dimension()) 00165 throw_dimension_incompatible("coefficient(v)", "v", v); 00166 return Generator::coefficient(v); 00167 }
Coefficient_traits::const_reference Parma_Polyhedra_Library::Grid_Generator::divisor | ( | ) | const [inline] |
Returns the divisor of *this
.
std::invalid_argument | Thrown if *this is a line. |
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 119 of file Grid_Generator.inlines.hh.
References is_line(), is_line_or_parameter(), Parma_Polyhedra_Library::Row::operator[](), size(), and throw_invalid_argument().
Referenced by Parma_Polyhedra_Library::Box< ITV >::Box(), Parma_Polyhedra_Library::Grid::get_covering_box(), Parma_Polyhedra_Library::Grid::Grid(), is_equal_at_dimension(), Parma_Polyhedra_Library::Grid::map_space_dimensions(), Parma_Polyhedra_Library::Grid::max_min(), Parma_Polyhedra_Library::Grid::normalize_divisors(), OK(), operator<<(), Parma_Polyhedra_Library::Congruence_System::satisfies_all_congruences(), and scale_to_divisor().
00119 { 00120 if (is_line()) 00121 throw_invalid_argument("divisor()", "*this is a line"); 00122 if (is_line_or_parameter()) 00123 return Generator::operator[](size() - 1); 00124 else 00125 return Generator::operator[](0); 00126 }
void Parma_Polyhedra_Library::Grid_Generator::initialize | ( | ) | [static] |
Initializes the class.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 268 of file Grid_Generator.cc.
References Grid_Generator(), grid_point(), and zero_dim_point_p.
00268 { 00269 assert(zero_dim_point_p == 0); 00270 zero_dim_point_p 00271 = new Grid_Generator(grid_point()); 00272 }
void Parma_Polyhedra_Library::Grid_Generator::finalize | ( | ) | [static] |
Finalizes the class.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 275 of file Grid_Generator.cc.
References zero_dim_point_p.
00275 { 00276 assert(zero_dim_point_p != 0); 00277 delete zero_dim_point_p; 00278 zero_dim_point_p = 0; 00279 }
const Grid_Generator & Parma_Polyhedra_Library::Grid_Generator::zero_dim_point | ( | ) | [inline, static] |
Returns the origin of the zero-dimensional space .
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 180 of file Grid_Generator.inlines.hh.
References zero_dim_point_p.
Referenced by Parma_Polyhedra_Library::Grid_Generator_System::initialize().
00180 { 00181 assert(zero_dim_point_p != 0); 00182 return *zero_dim_point_p; 00183 }
memory_size_type Parma_Polyhedra_Library::Grid_Generator::total_memory_in_bytes | ( | ) | const [inline] |
Returns a lower bound to the total size in bytes of the memory occupied by *this
.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 170 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::total_memory_in_bytes().
00170 { 00171 return Generator::total_memory_in_bytes(); 00172 }
memory_size_type Parma_Polyhedra_Library::Grid_Generator::external_memory_in_bytes | ( | ) | const [inline] |
Returns the size in bytes of the memory managed by *this
.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 175 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::external_memory_in_bytes().
00175 { 00176 return Generator::external_memory_in_bytes(); 00177 }
bool Parma_Polyhedra_Library::Grid_Generator::is_equivalent_to | ( | const Grid_Generator & | y | ) | const |
Returns true
if and only if *this
and y
are equivalent generators.
Generators having different space dimensions are not equivalent.
Definition at line 200 of file Grid_Generator.cc.
References LINE, POINT, space_dimension(), and type().
Referenced by operator==().
00200 { 00201 const Grid_Generator& x = *this; 00202 dimension_type x_space_dim = x.space_dimension(); 00203 if (x_space_dim != y.space_dimension()) 00204 return false; 00205 00206 const Type x_type = x.type(); 00207 if (x_type != y.type()) 00208 return false; 00209 00210 Grid_Generator tmp = *this; 00211 Grid_Generator tmp_y = y; 00212 dimension_type& last = x_space_dim; 00213 ++last; 00214 if (x_type == POINT || x_type == LINE) { 00215 tmp[last] = 0; 00216 tmp_y[last] = 0; 00217 } 00218 // Normalize the copies, including the divisor column. 00219 tmp.Row::normalize(); 00220 tmp_y.Row::normalize(); 00221 // Check for equality. 00222 while (last-- > 0) 00223 if (tmp[last] != tmp_y[last]) 00224 return false; 00225 return true; 00226 }
bool Parma_Polyhedra_Library::Grid_Generator::is_equal_to | ( | const Grid_Generator & | y | ) | const |
Returns true
if *this
is exactly equal to y
.
Definition at line 229 of file Grid_Generator.cc.
References is_parameter(), size(), and type().
Referenced by Parma_Polyhedra_Library::Grid::OK().
00229 { 00230 if (type() != y.type()) 00231 return false; 00232 for (dimension_type col = (is_parameter() ? size() : size() - 1); 00233 col-- > 0; ) 00234 if (Generator::operator[](col) != y.Generator::operator[](col)) 00235 return false; 00236 return true; 00237 }
bool Parma_Polyhedra_Library::Grid_Generator::is_equal_at_dimension | ( | dimension_type | dim, | |
const Grid_Generator & | gg | |||
) | const [inline] |
Returns true
if *this
is equal to gg
in dimension dim
.
Definition at line 129 of file Grid_Generator.inlines.hh.
References divisor(), and operator[]().
Referenced by Parma_Polyhedra_Library::Grid::select_wider_generators().
00130 { 00131 return operator[](dim) * gg.divisor() == gg[dim] * divisor(); 00132 }
bool Parma_Polyhedra_Library::Grid_Generator::all_homogeneous_terms_are_zero | ( | ) | const |
Returns true
if and only if all the homogeneous terms of *this
are .
Reimplemented from Parma_Polyhedra_Library::Linear_Row.
Definition at line 240 of file Grid_Generator.cc.
References size().
Referenced by Parma_Polyhedra_Library::Grid_Generator_System::insert().
00240 { 00241 // Start at size() - 1 to avoid the extra grid generator column. 00242 for (dimension_type i = size() - 1; --i > 0; ) 00243 if (operator[](i) != 0) 00244 return false; 00245 return true; 00246 }
void Parma_Polyhedra_Library::Grid_Generator::ascii_dump | ( | ) | const |
Writes to std::cerr
an ASCII representation of *this
.
Reimplemented from Parma_Polyhedra_Library::Generator.
void Parma_Polyhedra_Library::Grid_Generator::ascii_dump | ( | std::ostream & | s | ) | const |
Writes to s
an ASCII representation of *this
.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 132 of file Grid_Generator.cc.
References Parma_Polyhedra_Library::Generator::LINE, Parma_Polyhedra_Library::Generator::POINT, Parma_Polyhedra_Library::Generator::RAY, size(), and type().
00132 { 00133 const Grid_Generator& x = *this; 00134 const dimension_type x_size = x.size(); 00135 s << "size " << x_size << " "; 00136 for (dimension_type i = 0; i < x_size; ++i) 00137 s << x[i] << ' '; 00138 switch (x.type()) { 00139 case Generator::LINE: 00140 s << "L"; 00141 break; 00142 case Generator::RAY: 00143 s << "Q"; 00144 break; 00145 case Generator::POINT: 00146 s << "P"; 00147 break; 00148 } 00149 s << "\n"; 00150 }
void Parma_Polyhedra_Library::Grid_Generator::print | ( | ) | const |
bool Parma_Polyhedra_Library::Grid_Generator::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.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 155 of file Grid_Generator.cc.
References set_is_line(), Parma_Polyhedra_Library::Generator::set_is_ray_or_point(), Parma_Polyhedra_Library::Row::shrink(), Parma_Polyhedra_Library::Row::size(), and Parma_Polyhedra_Library::Row::swap().
00155 { 00156 std::string str; 00157 if (!(s >> str) || str != "size") 00158 return false; 00159 dimension_type new_size; 00160 if (!(s >> new_size)) 00161 return false; 00162 00163 Row& x = *this; 00164 const dimension_type old_size = x.size(); 00165 if (new_size < old_size) 00166 x.shrink(new_size); 00167 else if (new_size > old_size) { 00168 Row y(new_size, Row::Flags()); 00169 x.swap(y); 00170 } 00171 00172 for (dimension_type col = 0; col < new_size; ++col) 00173 if (!(s >> x[col])) 00174 return false; 00175 00176 if (!(s >> str)) 00177 return false; 00178 if (str == "L") 00179 set_is_line(); 00180 else if (str == "P" || str == "Q") 00181 set_is_ray_or_point(); 00182 else 00183 return false; 00184 00185 return true; 00186 }
bool Parma_Polyhedra_Library::Grid_Generator::OK | ( | ) | const |
Checks if all the invariants are satisfied.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 368 of file Grid_Generator.cc.
References divisor(), Parma_Polyhedra_Library::Linear_Row::is_necessarily_closed(), LINE, PARAMETER, POINT, size(), and type().
00368 { 00369 if (!is_necessarily_closed()) { 00370 #ifndef NDEBUG 00371 std::cerr << "Grid_Generator should be necessarily closed." 00372 << std::endl; 00373 #endif 00374 return false; 00375 } 00376 00377 // Topology consistency check. 00378 if (size() < 1) { 00379 #ifndef NDEBUG 00380 std::cerr << "Grid_Generator has fewer coefficients than the minimum " 00381 << "allowed:" << std::endl 00382 << "size is " << size() << ", minimum is 1." << std::endl; 00383 #endif 00384 return false; 00385 } 00386 00387 switch (type()) { 00388 case Grid_Generator::LINE: 00389 if (operator[](0) != 0) { 00390 #ifndef NDEBUG 00391 std::cerr << "Inhomogeneous terms of lines must be zero!" 00392 << std::endl; 00393 #endif 00394 return false; 00395 } 00396 break; 00397 00398 case Grid_Generator::PARAMETER: 00399 if (operator[](0) != 0) { 00400 #ifndef NDEBUG 00401 std::cerr << "Inhomogeneous terms of parameters must be zero!" 00402 << std::endl; 00403 #endif 00404 return false; 00405 } 00406 // Fall through. 00407 00408 case Grid_Generator::POINT: 00409 if (divisor() <= 0) { 00410 #ifndef NDEBUG 00411 std::cerr << "Points and parameters must have positive divisors!" 00412 << std::endl; 00413 #endif 00414 return false; 00415 } 00416 break; 00417 00418 } 00419 00420 // All tests passed. 00421 return true; 00422 }
void Parma_Polyhedra_Library::Grid_Generator::swap | ( | Grid_Generator & | y | ) | [inline] |
Swaps *this
with y
.
Definition at line 191 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::swap().
Referenced by swap().
00191 { 00192 Generator::swap(y); 00193 }
void Parma_Polyhedra_Library::Grid_Generator::coefficient_swap | ( | Grid_Generator & | y | ) |
Swaps *this
with y
, leaving *this
with the original capacity.
All elements up to and including the last element of the smaller of *this
and y
are swapped. The parameter divisor element of y
is swapped with the divisor element of *this
.
Definition at line 113 of file Grid_Generator.cc.
References is_line(), set_is_line(), Parma_Polyhedra_Library::Generator::set_is_ray_or_point(), size(), and Parma_Polyhedra_Library::swap().
Referenced by Parma_Polyhedra_Library::Grid_Generator_System::recycling_insert().
00113 { 00114 // Swap one coefficient at a time into *this. Doing this instead of 00115 // swapping the entire row ensures that the row keeps the same 00116 // capacity. 00117 if (y.is_line()) 00118 set_is_line(); 00119 else 00120 set_is_ray_or_point(); 00121 assert(size() > 0); 00122 assert(y.size() > 0); 00123 dimension_type sz = size() - 1; 00124 dimension_type y_sz = y.size() - 1; 00125 // Swap parameter divisors. 00126 std::swap(operator[](sz), y[y_sz]); 00127 for (dimension_type j = (sz > y_sz ? y_sz : sz); j-- > 0; ) 00128 std::swap(operator[](j), y[j]); 00129 }
void Parma_Polyhedra_Library::Grid_Generator::scale_to_divisor | ( | Coefficient_traits::const_reference | d | ) | [private] |
Scales *this
to be represented with a divisor of d
(if \*this is a parameter or point).
It is assumed that d
is a multiple of the current divisor.
std::invalid_argument | Thrown if d is zero. |
Definition at line 249 of file Grid_Generator.cc.
References divisor(), Parma_Polyhedra_Library::exact_div_assign(), is_parameter_or_point(), set_divisor(), size(), and TEMP_INTEGER.
Referenced by Parma_Polyhedra_Library::Grid::Grid().
00249 { 00250 if (is_parameter_or_point()) { 00251 if (d == 0) 00252 throw std::invalid_argument("PPL::Grid_Generator::scale_to_divisor(d):\n" 00253 "d == 0."); 00254 00255 TEMP_INTEGER(factor); 00256 exact_div_assign(factor, d, divisor()); 00257 set_divisor(d); 00258 assert(factor > 0); 00259 if (factor > 1) 00260 for (dimension_type col = size() - 2; col >= 1; --col) 00261 Generator::operator[](col) *= factor; 00262 } 00263 }
dimension_type Parma_Polyhedra_Library::Grid_Generator::size | ( | ) | const [inline, private] |
Returns the actual size of this
.
Reimplemented from Parma_Polyhedra_Library::Row.
Definition at line 44 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Row::size().
Referenced by all_homogeneous_terms_are_zero(), ascii_dump(), Parma_Polyhedra_Library::Scalar_Products::assign(), coefficient_swap(), divisor(), Parma_Polyhedra_Library::Scalar_Products::homogeneous_assign(), Parma_Polyhedra_Library::Grid_Generator_System::insert(), is_equal_to(), Parma_Polyhedra_Library::Grid::OK(), OK(), Parma_Polyhedra_Library::Grid_Generator_System::recycling_insert(), Parma_Polyhedra_Library::Grid::reduce_line_with_line(), Parma_Polyhedra_Library::Scalar_Products::reduced_assign(), Parma_Polyhedra_Library::Grid::relation_with(), scale_to_divisor(), set_divisor(), and set_is_parameter().
00044 { 00045 return Generator::size(); 00046 }
void Parma_Polyhedra_Library::Grid_Generator::negate | ( | dimension_type | start, | |
dimension_type | end | |||
) | [inline, private] |
Negates the elements from index start
to index end
.
Definition at line 157 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::neg_assign().
Referenced by Parma_Polyhedra_Library::Grid::simplify().
00157 { 00158 while (start <= end) 00159 neg_assign(operator[](start++)); 00160 }
void Parma_Polyhedra_Library::Grid_Generator::set_divisor | ( | Coefficient_traits::const_reference | d | ) | [inline, private] |
Sets the divisor of *this
to d
.
std::invalid_argument | Thrown if *this is a line. |
Definition at line 110 of file Grid_Generator.inlines.hh.
References is_line(), is_line_or_parameter(), Parma_Polyhedra_Library::Row::operator[](), and size().
Referenced by Parma_Polyhedra_Library::Box< ITV >::Box(), Parma_Polyhedra_Library::Grid::get_covering_box(), and scale_to_divisor().
00110 { 00111 assert(!is_line()); 00112 if (is_line_or_parameter()) 00113 Generator::operator[](size() - 1) = d; 00114 else 00115 Generator::operator[](0) = d; 00116 }
void Parma_Polyhedra_Library::Grid_Generator::set_is_line | ( | ) | [inline, private] |
Sets the Linear_Row kind to LINE_OR_EQUALITY
.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 135 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::set_is_line().
Referenced by ascii_load(), coefficient_swap(), and Parma_Polyhedra_Library::Grid::conversion().
00135 { 00136 Generator::set_is_line(); 00137 }
void Parma_Polyhedra_Library::Grid_Generator::set_is_parameter_or_point | ( | ) | [inline, private] |
Sets the Linear_Row kind to RAY_OR_POINT_OR_INEQUALITY
.
Definition at line 140 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::set_is_ray_or_point().
Referenced by Parma_Polyhedra_Library::Grid::conversion(), and set_is_parameter().
00140 { 00141 Generator::set_is_ray_or_point(); 00142 }
void Parma_Polyhedra_Library::Grid_Generator::set_is_parameter | ( | ) | [private] |
Converts the Grid_Generator into a parameter.
Definition at line 189 of file Grid_Generator.cc.
References is_line(), is_line_or_parameter(), Parma_Polyhedra_Library::Row::operator[](), set_is_parameter_or_point(), and size().
Referenced by Parma_Polyhedra_Library::Grid::relation_with(), and Parma_Polyhedra_Library::Grid::time_elapse_assign().
00189 { 00190 if (is_line()) 00191 set_is_parameter_or_point(); 00192 else if (!is_line_or_parameter()) { 00193 // The generator is a point. 00194 Generator::operator[](size() - 1) = Generator::operator[](0); 00195 Generator::operator[](0) = 0; 00196 } 00197 }
void Parma_Polyhedra_Library::Grid_Generator::strong_normalize | ( | ) | [inline, private] |
Strong normalization: ensures that different Grid_Generator objects represent different hyperplanes or hyperspaces.
Applies both Linear_Row::normalize() and Linear_Row::sign_normalize().
This is simply a wrapper around the Generator::strong_normalize, which means applying it to a parameter may change the parameter.
Reimplemented from Parma_Polyhedra_Library::Linear_Row.
Definition at line 186 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::strong_normalize().
00186 { 00187 Generator::strong_normalize(); 00188 }
Coefficient & Parma_Polyhedra_Library::Grid_Generator::operator[] | ( | dimension_type | k | ) | [inline, private] |
Returns a reference to the element of the row indexed by k
.
Reimplemented from Parma_Polyhedra_Library::Row.
Definition at line 54 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Row::operator[]().
Referenced by is_equal_at_dimension().
00054 { 00055 return Generator::operator[](k); 00056 }
Coefficient_traits::const_reference Parma_Polyhedra_Library::Grid_Generator::operator[] | ( | dimension_type | k | ) | const [inline, private] |
Returns a constant reference to the element of the row indexed by k
.
Reimplemented from Parma_Polyhedra_Library::Row.
Definition at line 59 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Row::operator[]().
00059 { 00060 return Generator::operator[](k); 00061 }
void Parma_Polyhedra_Library::Grid_Generator::throw_invalid_argument | ( | const char * | method, | |
const char * | reason | |||
) | const [private] |
Throw a std::invalid_argument
exception containing the appropriate error message.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 32 of file Grid_Generator.cc.
Referenced by divisor().
00033 { 00034 std::ostringstream s; 00035 s << "PPL::Grid_Generator::" << method << ":" << std::endl 00036 << reason << "."; 00037 throw std::invalid_argument(s.str()); 00038 }
friend class Grid [friend] |
Definition at line 480 of file Grid_Generator.defs.hh.
friend class Parma_Polyhedra_Library::Box [friend] |
Definition at line 487 of file Grid_Generator.defs.hh.
friend class Grid_Generator_System [friend] |
Definition at line 489 of file Grid_Generator.defs.hh.
friend class Grid_Generator_System::const_iterator [friend] |
Definition at line 490 of file Grid_Generator.defs.hh.
friend class Congruence_System [friend] |
Definition at line 491 of file Grid_Generator.defs.hh.
friend class Scalar_Products [friend] |
Definition at line 492 of file Grid_Generator.defs.hh.
friend class Topology_Adjusted_Scalar_Product_Sign [friend] |
Definition at line 493 of file Grid_Generator.defs.hh.
friend class Linear_Expression [friend] |
Definition at line 494 of file Grid_Generator.defs.hh.
std::ostream& IO_Operators::operator<< | ( | std::ostream & | s, | |
const Grid_Generator & | g | |||
) | [friend] |
std::ostream & operator<< | ( | std::ostream & | s, | |
const Grid_Generator & | g | |||
) | [related] |
Output operator.
Definition at line 283 of file Grid_Generator.cc.
References divisor(), LINE, Parma_Polyhedra_Library::neg_assign(), PARAMETER, POINT, space_dimension(), TEMP_INTEGER, and type().
00283 { 00284 bool need_divisor = false; 00285 bool extra_parentheses = false; 00286 const dimension_type num_variables = g.space_dimension(); 00287 Grid_Generator::Type t = g.type(); 00288 switch (t) { 00289 case Grid_Generator::LINE: 00290 s << "l("; 00291 break; 00292 case Grid_Generator::PARAMETER: 00293 s << "q("; 00294 if (g[num_variables + 1] == 1) 00295 break; 00296 goto any_point; 00297 case Grid_Generator::POINT: 00298 s << "p("; 00299 if (g[0] > 1) { 00300 any_point: 00301 need_divisor = true; 00302 dimension_type num_non_zero_coefficients = 0; 00303 for (dimension_type v = 0; v < num_variables; ++v) 00304 if (g[v+1] != 0) 00305 if (++num_non_zero_coefficients > 1) { 00306 extra_parentheses = true; 00307 s << "("; 00308 break; 00309 } 00310 } 00311 break; 00312 } 00313 00314 TEMP_INTEGER(gv); 00315 bool first = true; 00316 for (dimension_type v = 0; v < num_variables; ++v) { 00317 gv = g[v+1]; 00318 if (gv != 0) { 00319 if (!first) { 00320 if (gv > 0) 00321 s << " + "; 00322 else { 00323 s << " - "; 00324 neg_assign(gv); 00325 } 00326 } 00327 else 00328 first = false; 00329 if (gv == -1) 00330 s << "-"; 00331 else if (gv != 1) 00332 s << gv << "*"; 00333 s << PPL::Variable(v); 00334 } 00335 } 00336 if (first) 00337 // A generator in the origin. 00338 s << 0; 00339 if (extra_parentheses) 00340 s << ")"; 00341 if (need_divisor) 00342 s << "/" << g.divisor(); 00343 s << ")"; 00344 return s; 00345 }
void swap | ( | Parma_Polyhedra_Library::Grid_Generator & | x, | |
Parma_Polyhedra_Library::Grid_Generator & | y | |||
) | [related] |
Specializes std::swap
.
Definition at line 233 of file Grid_Generator.inlines.hh.
References swap().
00234 { 00235 x.swap(y); 00236 }
bool operator== | ( | const Grid_Generator & | x, | |
const Grid_Generator & | y | |||
) | [related] |
Returns true
if and only if x
is equivalent to y
.
Definition at line 197 of file Grid_Generator.inlines.hh.
References is_equivalent_to().
bool operator!= | ( | const Grid_Generator & | x, | |
const Grid_Generator & | y | |||
) | [related] |
Returns true
if and only if x
is not equivalent to y
.
Definition at line 203 of file Grid_Generator.inlines.hh.
std::ostream & operator<< | ( | std::ostream & | s, | |
const Grid_Generator::Type & | t | |||
) | [related] |
Output operator.
Definition at line 349 of file Grid_Generator.cc.
References LINE, PARAMETER, and Parma_Polyhedra_Library::Generator::POINT.
00350 { 00351 const char* n = 0; 00352 switch (t) { 00353 case Grid_Generator::LINE: 00354 n = "LINE"; 00355 break; 00356 case Grid_Generator::PARAMETER: 00357 n = "PARAMETER"; 00358 break; 00359 case Generator::POINT: 00360 n = "POINT"; 00361 break; 00362 } 00363 s << n; 00364 return s; 00365 }
const PPL::Grid_Generator * Parma_Polyhedra_Library::Grid_Generator::zero_dim_point_p = 0 [static, private] |
Holds (between class initialization and finalization) a pointer to the origin of the zero-dimensional space .
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 407 of file Grid_Generator.defs.hh.
Referenced by finalize(), initialize(), and zero_dim_point().