#include <Grid_Generator.defs.hh>
Public Types | |
enum | Type { LINE, PARAMETER, POINT } |
The generator type. More... | |
Public Member Functions | |
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. | |
Grid_Generator & | operator= (const Grid_Generator &g) |
Assignment operator. | |
Grid_Generator & | operator= (const Generator &g) |
Assignment operator. | |
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 | all_homogeneous_terms_are_zero () const |
Returns true if and only if all the homogeneous terms of *this are ![]() | |
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). | |
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. | |
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) and sets *this accordingly. Returns true if successful, false otherwise. | |
Static Public Member Functions | |
static Grid_Generator | 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 at e . | |
static Grid_Generator | point (const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one()) |
Returns the point at e / d . | |
Private Member Functions | |
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 . | |
Coefficient & | divisor () |
Returns the divisor of *this . | |
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 | 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. | |
Friends | |
class | Grid |
class | Grid_Generator_System |
class | Grid_Generator_System::const_iterator |
class | Congruence_System |
class | Scalar_Products |
class | Topology_Adjusted_Scalar_Product_Sign |
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 . | |
Grid_Generator | grid_line (const Linear_Expression &e) |
Shorthand for Grid_Generator Grid_Generator::line(const Linear_Expression& e). | |
Grid_Generator | grid_point (const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one()) |
Shorthand for Grid_Generator Grid_Generator::point(const Linear_Expression& e, Coefficient_traits::const_reference d). | |
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 points and parameters,
is the divisor.
line
, parameter
or 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 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 point having coordinates g2
having coordinates if (g1.is_point()) { cout << "Point g1: " << g1 << endl; Linear_Expression e; for (int i = g1.space_dimension() - 1; i >= 0; i--) 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 point." << endl;
Grid_Generator g1 = grid_point(2*x - y + 3*z, 2);
Point g1: p((2*A - B + 3*C)/2) Parameter g2: parameter((2*A - 2*B + 9*C)/2)
Definition at line 226 of file Grid_Generator.defs.hh.
The generator type.
LINE | The generator is a line. |
PARAMETER | The generator is a parameter. |
POINT | The generator is a point. |
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 234 of file Grid_Generator.defs.hh.
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 31 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::swap().
00032 : Generator(Generator::point()) { 00033 Generator::swap(g); 00034 }
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 37 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::space_dimension().
Referenced by Parma_Polyhedra_Library::Grid::add_generator(), 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(), and Parma_Polyhedra_Library::Grid::throw_dimension_incompatible().
00037 { 00038 return Generator::space_dimension() - 1; 00039 }
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 42 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 is_equal_to(), is_equivalent_to(), Parma_Polyhedra_Library::Grid::map_space_dimensions(), OK(), and operator<<().
00042 { 00043 switch (Generator::type()) { 00044 case Generator::POINT: 00045 return POINT; 00046 case Generator::RAY: 00047 return PARAMETER; 00048 case Generator::LINE: 00049 return LINE; 00050 case Generator::CLOSURE_POINT: 00051 default: 00052 assert(false); 00053 return POINT; 00054 } 00055 }
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 58 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::is_line().
Referenced by coefficient_swap(), divisor(), Parma_Polyhedra_Library::Grid::get_covering_box(), Parma_Polyhedra_Library::Grid::multiply_grid(), Parma_Polyhedra_Library::Congruence_System::satisfies_all_congruences(), and Parma_Polyhedra_Library::Grid::simplify().
00058 { 00059 return Generator::is_line(); 00060 }
bool Parma_Polyhedra_Library::Grid_Generator::is_parameter | ( | ) | const [inline] |
Returns true
if and only if *this
is a parameter.
Definition at line 63 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::is_ray().
Referenced by Parma_Polyhedra_Library::Grid::add_generator(), Parma_Polyhedra_Library::Grid_Generator_System::insert(), and is_equal_to().
00063 { 00064 return is_ray(); 00065 }
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 68 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::is_line_or_ray().
Referenced by Parma_Polyhedra_Library::Grid::add_generator(), Parma_Polyhedra_Library::Grid::bounds(), divisor(), and Parma_Polyhedra_Library::Grid::is_bounded().
00068 { 00069 return is_line_or_ray(); 00070 }
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 73 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::is_point().
Referenced by Parma_Polyhedra_Library::Grid::get_covering_box(), Parma_Polyhedra_Library::Grid::shrink_bounding_box(), and Parma_Polyhedra_Library::Grid::time_elapse_assign().
00073 { 00074 return Generator::is_point(); 00075 }
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 78 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_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().
00078 { 00079 return is_ray_or_point_or_inequality(); 00080 }
PPL::Grid_Generator Parma_Polyhedra_Library::Grid_Generator::line | ( | const Linear_Expression & | e | ) | [static] |
Returns the line of direction e
.
std::invalid_argument | Thrown if the homogeneous part of e represents the origin of the vector space. |
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 92 of file Grid_Generator.cc.
References Parma_Polyhedra_Library::Linear_Row::all_homogeneous_terms_are_zero(), Parma_Polyhedra_Library::Generator::LINE, Parma_Polyhedra_Library::NECESSARILY_CLOSED, Parma_Polyhedra_Library::Linear_Expression::space_dimension(), and strong_normalize().
Referenced by Parma_Polyhedra_Library::Grid::generalized_affine_image(), Parma_Polyhedra_Library::Grid::generalized_affine_preimage(), and grid_line().
00092 { 00093 // The origin of the space cannot be a line. 00094 if (e.all_homogeneous_terms_are_zero()) 00095 throw std::invalid_argument("PPL::grid_line(e):\n" 00096 "e == 0, but the origin cannot be a line."); 00097 00098 // Add 2 to space dimension to allow for parameter divisor column. 00099 Linear_Expression ec(e, 00100 e.space_dimension() + 2); 00101 Generator g(ec, Generator::LINE, NECESSARILY_CLOSED); 00102 g[0] = 0; 00103 // Using this constructor saves reallocation when creating the 00104 // coefficients. 00105 Grid_Generator gg(g); 00106 00107 // Enforce normalization. 00108 gg.strong_normalize(); 00109 return gg; 00110 }
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 at e
.
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 193 of file Grid_Generator.inlines.hh.
00194 { 00195 return Grid_Generator::parameter(e, d); 00196 }
PPL::Grid_Generator Parma_Polyhedra_Library::Grid_Generator::point | ( | const Linear_Expression & | e = Linear_Expression::zero() , |
|
Coefficient_traits::const_reference | d = Coefficient_one() | |||
) | [static] |
Returns the point at e
/ 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. |
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 66 of file Grid_Generator.cc.
References Parma_Polyhedra_Library::NECESSARILY_CLOSED, Parma_Polyhedra_Library::neg_assign(), Parma_Polyhedra_Library::Generator::POINT, size(), and Parma_Polyhedra_Library::Linear_Expression::space_dimension().
Referenced by grid_point(), Parma_Polyhedra_Library::Grid::max_min(), and Parma_Polyhedra_Library::Grid::set_zero_dim_univ().
00067 { 00068 if (d == 0) 00069 throw std::invalid_argument("PPL::grid_point(e, d):\n" 00070 "d == 0."); 00071 // Add 2 to space dimension to allow for parameter divisor column. 00072 Linear_Expression ec(e, 00073 e.space_dimension() + 2); 00074 Generator g(ec, Generator::POINT, NECESSARILY_CLOSED); 00075 g[0] = d; 00076 // Using this constructor saves reallocation when creating the 00077 // coefficients. 00078 Grid_Generator gg(g); 00079 00080 // If the divisor is negative, negate it and all the coefficients of 00081 // the parameter. This ensures that divisors are always positive. 00082 if (d < 0) 00083 for (dimension_type i = gg.size(); i-- > 0; ) 00084 neg_assign(gg[i]); 00085 00086 // Enforce normalization. 00087 gg.normalize(); 00088 return gg; 00089 }
Grid_Generator & Parma_Polyhedra_Library::Grid_Generator::operator= | ( | const Grid_Generator & | g | ) | [inline] |
Assignment operator.
Definition at line 93 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::operator=().
00093 { 00094 Generator::operator=(g); 00095 return *this; 00096 }
Grid_Generator & Parma_Polyhedra_Library::Grid_Generator::operator= | ( | const Generator & | g | ) | [inline] |
Assignment operator.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 99 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::operator=().
00099 { 00100 Generator::operator=(g); 00101 return *this; 00102 }
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 120 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::Grid::get_covering_box(), 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(), scale_to_divisor(), Parma_Polyhedra_Library::Grid::shrink_bounding_box(), and Parma_Polyhedra_Library::Grid::time_elapse_assign().
00120 { 00121 if (is_line()) 00122 throw_invalid_argument("divisor()", "*this is a line"); 00123 if (is_line_or_parameter()) 00124 return Generator::operator[](size() - 1); 00125 return Generator::operator[](0); 00126 }
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 129 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Checked::total_memory_in_bytes().
00129 { 00130 return Generator::total_memory_in_bytes(); 00131 }
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 134 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Checked::external_memory_in_bytes().
00134 { 00135 return Generator::external_memory_in_bytes(); 00136 }
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 132 of file Grid_Generator.cc.
References LINE, POINT, space_dimension(), and type().
Referenced by operator==().
00132 { 00133 const Grid_Generator& x = *this; 00134 dimension_type x_space_dim = x.space_dimension(); 00135 if (x_space_dim != y.space_dimension()) 00136 return false; 00137 00138 const Type x_type = x.type(); 00139 if (x_type != y.type()) 00140 return false; 00141 00142 Grid_Generator tem(*this); 00143 Grid_Generator tem_y(y); 00144 dimension_type& last = x_space_dim; 00145 ++last; 00146 if (x_type == POINT || x_type == LINE) { 00147 tem[last] = 0; 00148 tem_y[last] = 0; 00149 } 00150 // Normalize the copies, including the divisor column. 00151 tem.Row::normalize(); 00152 tem_y.Row::normalize(); 00153 // Check for equality. 00154 while (last-- > 0) 00155 if (tem[last] != tem_y[last]) 00156 return false; 00157 return true; 00158 }
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 161 of file Grid_Generator.cc.
References is_parameter(), size(), and type().
Referenced by Parma_Polyhedra_Library::Grid::OK().
00161 { 00162 if (type() != y.type()) 00163 return false; 00164 for (dimension_type col = (is_parameter() ? size() : size() - 1); 00165 col-- > 0; ) 00166 if (Generator::operator[](col) != y.Generator::operator[](col)) 00167 return false; 00168 return true; 00169 }
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 172 of file Grid_Generator.cc.
References size().
Referenced by Parma_Polyhedra_Library::Grid_Generator_System::insert().
00172 { 00173 // Start at size() - 1 to avoid the extra grid generator column. 00174 for (dimension_type i = size() - 1; --i > 0; ) 00175 if (operator[](i) != 0) 00176 return false; 00177 return true; 00178 }
void Parma_Polyhedra_Library::Grid_Generator::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).
std::invalid_argument | Thrown if d is zero. |
Definition at line 181 of file Grid_Generator.cc.
References divisor(), is_parameter_or_point(), size(), and TEMP_INTEGER.
00181 { 00182 if (is_parameter_or_point()) { 00183 if (d == 0) 00184 throw std::invalid_argument("PPL::Grid_Generator::scale_to_divisor(d):\n" 00185 "d == 0."); 00186 00187 TEMP_INTEGER(factor); 00188 factor = d / divisor(); 00189 divisor() = d; 00190 assert(factor > 0); 00191 if (factor > 1) 00192 for (dimension_type col = size() - 2; col >= 1; --col) 00193 Generator::operator[](col) *= factor; 00194 } 00195 }
bool Parma_Polyhedra_Library::Grid_Generator::OK | ( | ) | const |
Checks if all the invariants are satisfied.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 283 of file Grid_Generator.cc.
References divisor(), Parma_Polyhedra_Library::Linear_Row::is_necessarily_closed(), LINE, PARAMETER, POINT, size(), and type().
00283 { 00284 if (!is_necessarily_closed()) { 00285 #ifndef NDEBUG 00286 std::cerr << "Grid_Generator Generator should be necessarily closed." 00287 << std::endl; 00288 #endif 00289 return false; 00290 } 00291 00292 // Topology consistency check. 00293 if (size() < 1) { 00294 #ifndef NDEBUG 00295 std::cerr << "Grid_Generator has fewer coefficients than the minimum " 00296 << "allowed:" << std::endl 00297 << "size is " << size() << ", minimum is 1." << std::endl; 00298 #endif 00299 return false; 00300 } 00301 00302 switch (type()) { 00303 case Grid_Generator::LINE: 00304 if (operator[](0) != 0) { 00305 #ifndef NDEBUG 00306 std::cerr << "Inhomogeneous terms of lines must be zero!" 00307 << std::endl; 00308 #endif 00309 return false; 00310 } 00311 break; 00312 00313 case Grid_Generator::PARAMETER: 00314 if (operator[](0) != 0) { 00315 #ifndef NDEBUG 00316 std::cerr << "Inhomogeneous terms of parameters must be zero!" 00317 << std::endl; 00318 #endif 00319 return false; 00320 } 00321 // Fall through. 00322 00323 case Grid_Generator::POINT: 00324 if (divisor() <= 0) { 00325 #ifndef NDEBUG 00326 std::cerr << "Points and parameters must have positive divisors!" 00327 << std::endl; 00328 #endif 00329 return false; 00330 } 00331 break; 00332 00333 } 00334 00335 // All tests passed. 00336 return true; 00337 }
void Parma_Polyhedra_Library::Grid_Generator::swap | ( | Grid_Generator & | y | ) | [inline] |
Swaps *this
with y
.
Definition at line 149 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::swap().
Referenced by swap().
00149 { 00150 Generator::swap(y); 00151 }
void Parma_Polyhedra_Library::Grid_Generator::coefficient_swap | ( | Grid_Generator & | y | ) |
Swaps *this
with y
, leaving *this
with the original capacity.
All 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(), and size().
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::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 [inline] |
Writes to s
an ASCII representation of *this
.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 154 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::ascii_dump().
00154 { 00155 Generator::ascii_dump(s); 00156 }
void Parma_Polyhedra_Library::Grid_Generator::print | ( | ) | const |
bool Parma_Polyhedra_Library::Grid_Generator::ascii_load | ( | std::istream & | s | ) | [inline] |
Loads from s
an ASCII representation (as produced by ascii_dump) and sets *this
accordingly. Returns true
if successful, false
otherwise.
Reimplemented from Parma_Polyhedra_Library::Generator.
Definition at line 159 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::ascii_load().
00159 { 00160 return Generator::ascii_load(s); 00161 }
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 144 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Row::size().
Referenced by all_homogeneous_terms_are_zero(), 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(), point(), Parma_Polyhedra_Library::Grid_Generator_System::recycling_insert(), Parma_Polyhedra_Library::Grid::reduce_line_with_line(), Parma_Polyhedra_Library::Scalar_Products::reduced_assign(), and scale_to_divisor().
00144 { 00145 return Generator::size(); 00146 }
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 105 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::neg_assign().
Referenced by Parma_Polyhedra_Library::Grid::simplify().
00105 { 00106 while (start <= end) 00107 neg_assign(operator[](start++)); 00108 }
Coefficient & Parma_Polyhedra_Library::Grid_Generator::divisor | ( | ) | [inline, private] |
Returns the divisor of *this
.
std::invalid_argument | Thrown if *this is a line. |
Definition at line 111 of file Grid_Generator.inlines.hh.
References is_line(), is_line_or_parameter(), Parma_Polyhedra_Library::Row::operator[](), size(), and throw_invalid_argument().
00111 { 00112 if (is_line()) 00113 throw_invalid_argument("divisor()", "*this is a line"); 00114 if (is_line_or_parameter()) 00115 return Generator::operator[](size() - 1); 00116 return Generator::operator[](0); 00117 }
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 83 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::set_is_line().
Referenced by coefficient_swap(), and Parma_Polyhedra_Library::Grid::conversion().
00083 { 00084 Generator::set_is_line(); 00085 }
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 88 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Generator::set_is_ray_or_point().
Referenced by Parma_Polyhedra_Library::Grid::conversion().
00088 { 00089 Generator::set_is_ray_or_point(); 00090 }
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 139 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::strong_normalize().
Referenced by line(), and Parma_Polyhedra_Library::Grid::max_min().
00139 { 00140 Generator::strong_normalize(); 00141 }
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 164 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Row::operator[]().
00164 { 00165 return Generator::operator[](k); 00166 }
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 169 of file Grid_Generator.inlines.hh.
References Parma_Polyhedra_Library::Row::operator[]().
00169 { 00170 return Generator::operator[](k); 00171 }
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 433 of file Grid_Generator.defs.hh.
friend class Grid_Generator_System [friend] |
Definition at line 435 of file Grid_Generator.defs.hh.
friend class Grid_Generator_System::const_iterator [friend] |
Definition at line 436 of file Grid_Generator.defs.hh.
friend class Congruence_System [friend] |
Definition at line 437 of file Grid_Generator.defs.hh.
friend class Scalar_Products [friend] |
Definition at line 438 of file Grid_Generator.defs.hh.
friend class Topology_Adjusted_Scalar_Product_Sign [friend] |
Definition at line 439 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 199 of file Grid_Generator.cc.
References divisor(), LINE, Parma_Polyhedra_Library::neg_assign(), PARAMETER, POINT, space_dimension(), and type().
00199 { 00200 bool need_divisor = false; 00201 bool extra_parentheses = false; 00202 const int num_variables = g.space_dimension(); 00203 Grid_Generator::Type t = g.type(); 00204 switch (t) { 00205 case Grid_Generator::LINE: 00206 s << "l("; 00207 break; 00208 case Grid_Generator::PARAMETER: 00209 s << "r("; 00210 if (g[num_variables + 1] == 1) 00211 break; 00212 goto any_point; 00213 case Grid_Generator::POINT: 00214 s << "p("; 00215 if (g[0] > 1) { 00216 any_point: 00217 need_divisor = true; 00218 int num_non_zero_coefficients = 0; 00219 for (int v = 0; v < num_variables; ++v) 00220 if (g[v+1] != 0) 00221 if (++num_non_zero_coefficients > 1) { 00222 extra_parentheses = true; 00223 s << "("; 00224 break; 00225 } 00226 } 00227 break; 00228 } 00229 00230 bool first = true; 00231 for (int v = 0; v < num_variables; ++v) { 00232 Coefficient gv = g[v+1]; 00233 if (gv != 0) { 00234 if (!first) { 00235 if (gv > 0) 00236 s << " + "; 00237 else { 00238 s << " - "; 00239 neg_assign(gv); 00240 } 00241 } 00242 else 00243 first = false; 00244 if (gv == -1) 00245 s << "-"; 00246 else if (gv != 1) 00247 s << gv << "*"; 00248 s << PPL::Variable(v); 00249 } 00250 } 00251 if (first) 00252 // A generator in the origin. 00253 s << 0; 00254 if (extra_parentheses) 00255 s << ")"; 00256 if (need_divisor) 00257 s << "/" << g.divisor(); 00258 s << ")"; 00259 return s; 00260 }
void swap | ( | Parma_Polyhedra_Library::Grid_Generator & | x, | |
Parma_Polyhedra_Library::Grid_Generator & | y | |||
) | [related] |
Specializes std::swap
.
Definition at line 211 of file Grid_Generator.inlines.hh.
References swap().
00212 { 00213 x.swap(y); 00214 }
Grid_Generator grid_line | ( | const Linear_Expression & | e | ) | [related] |
Shorthand for Grid_Generator Grid_Generator::line(const Linear_Expression& e).
Definition at line 187 of file Grid_Generator.inlines.hh.
References line().
00187 { 00188 return Grid_Generator::line(e); 00189 }
Grid_Generator grid_point | ( | const Linear_Expression & | e = Linear_Expression::zero() , |
|
Coefficient_traits::const_reference | d = Coefficient_one() | |||
) | [related] |
Shorthand for Grid_Generator Grid_Generator::point(const Linear_Expression& e, Coefficient_traits::const_reference d).
Definition at line 200 of file Grid_Generator.inlines.hh.
References point().
00201 { 00202 return Grid_Generator::point(e, d); 00203 }
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 175 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 181 of file Grid_Generator.inlines.hh.
std::ostream & operator<< | ( | std::ostream & | s, | |
const Grid_Generator::Type & | t | |||
) | [related] |
Output operator.
Definition at line 264 of file Grid_Generator.cc.
References LINE, PARAMETER, and Parma_Polyhedra_Library::Generator::POINT.
00265 { 00266 const char* n = 0; 00267 switch (t) { 00268 case Grid_Generator::LINE: 00269 n = "LINE"; 00270 break; 00271 case Grid_Generator::PARAMETER: 00272 n = "PARAMETER"; 00273 break; 00274 case Generator::POINT: 00275 n = "POINT"; 00276 break; 00277 } 00278 s << n; 00279 return s; 00280 }