00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef PPL_OR_Matrix_defs_hh
00026 #define PPL_OR_Matrix_defs_hh 1
00027
00028 #include "globals.defs.hh"
00029 #include "OR_Matrix.types.hh"
00030 #include "DB_Row.defs.hh"
00031 #include "Checked_Number.defs.hh"
00032 #include <cstddef>
00033 #include <iosfwd>
00034
00035 #ifndef PPL_OR_MATRIX_EXTRA_DEBUG
00036 #ifdef PPL_ABI_BREAKING_EXTRA_DEBUG
00037 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00038
00044 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00045 #define PPL_OR_MATRIX_EXTRA_DEBUG 1
00046 #else // !defined(PPL_ABI_BREAKING_EXTRA_DEBUG)
00047 #define PPL_OR_MATRIX_EXTRA_DEBUG 0
00048 #endif // !defined(PPL_ABI_BREAKING_EXTRA_DEBUG)
00049 #endif // !defined(PPL_OR_MATRIX_EXTRA_DEBUG)
00050
00051 namespace Parma_Polyhedra_Library {
00052
00053 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00054
00055
00056 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00057 template <typename T>
00058 bool operator==(const OR_Matrix<T>& x, const OR_Matrix<T>& y);
00059
00060 namespace IO_Operators {
00061
00062 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00063
00064
00065 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00066 template <typename T>
00067 std::ostream&
00068 operator<<(std::ostream& s, const OR_Matrix<T>& m);
00069
00070 }
00071
00072 }
00073
00074
00075 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00076
00077
00103 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00104
00105 template <typename T>
00106 class Parma_Polyhedra_Library::OR_Matrix {
00107 private:
00112 template <typename U>
00113 class Pseudo_Row {
00114 public:
00120 template <typename V>
00121 Pseudo_Row(const Pseudo_Row<V>& y);
00122
00124 ~Pseudo_Row();
00125
00127 U& operator[](dimension_type k) const;
00128
00130 Pseudo_Row();
00131
00133 Pseudo_Row& operator=(const Pseudo_Row& y);
00134
00135 #if !defined(__GNUC__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 0)
00136 private:
00137 #else
00138
00139 public:
00140 #endif
00141
00142 #if PPL_OR_MATRIX_EXTRA_DEBUG
00143
00145 Pseudo_Row(U& y, dimension_type s);
00146
00147 #else // !PPL_OR_MATRIX_EXTRA_DEBUG
00148
00150 explicit Pseudo_Row(U& y);
00151
00152 #endif // !PPL_OR_MATRIX_EXTRA_DEBUG
00153
00155 U* first;
00156
00157 #if !defined(__GNUC__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 0)
00158 #else
00159
00160 private:
00161 #endif
00162
00163 #if PPL_OR_MATRIX_EXTRA_DEBUG
00164
00166 dimension_type size_;
00167
00169 dimension_type size() const;
00170
00171 #endif // PPL_OR_MATRIX_EXTRA_DEBUG
00172
00173
00174
00175
00176 #ifdef __EDG__
00177 template <typename V> template<typename W>
00178 friend class OR_Matrix<V>::Pseudo_Row;
00179 template <typename V> template<typename W>
00180 friend class OR_Matrix<V>::any_row_iterator;
00181 #else
00182 template <typename V> friend class Pseudo_Row;
00183 template <typename V> friend class any_row_iterator;
00184 #endif
00185
00186 friend class OR_Matrix;
00187 };
00188
00189 public:
00191 typedef Pseudo_Row<T> row_reference_type;
00192
00194 typedef Pseudo_Row<const T> const_row_reference_type;
00195
00196 private:
00201 template <typename U>
00202 class any_row_iterator {
00203 public:
00204 typedef std::random_access_iterator_tag iterator_category;
00205 typedef Pseudo_Row<U> value_type;
00206 typedef long difference_type;
00207 typedef const Pseudo_Row<U>* pointer;
00208 typedef const Pseudo_Row<U>& reference;
00209
00211 any_row_iterator(dimension_type n_rows);
00212
00217 explicit any_row_iterator(U& base);
00218
00223 template <typename V>
00224 any_row_iterator(const any_row_iterator<V>& y);
00225
00230 template <typename V>
00231 any_row_iterator& operator=(const any_row_iterator<V>& y);
00232
00234 reference operator*() const;
00235
00237 pointer operator->() const;
00238
00240 any_row_iterator& operator++();
00241
00243 any_row_iterator operator++(int);
00244
00246 any_row_iterator& operator--();
00247
00249 any_row_iterator operator--(int);
00250
00252 reference operator[](difference_type m) const;
00253
00255 any_row_iterator& operator+=(difference_type m);
00256
00258 any_row_iterator& operator-=(difference_type m);
00259
00261 difference_type operator-(const any_row_iterator& y) const;
00262
00264 any_row_iterator operator+(difference_type m) const;
00265
00267 any_row_iterator operator-(difference_type m) const;
00268
00270 bool operator==(const any_row_iterator& y) const;
00271
00276 bool operator!=(const any_row_iterator& y) const;
00277
00279 bool operator<(const any_row_iterator& y) const;
00280
00285 bool operator<=(const any_row_iterator& y) const;
00286
00288 bool operator>(const any_row_iterator& y) const;
00289
00294 bool operator>=(const any_row_iterator& y) const;
00295
00296 dimension_type row_size() const;
00297
00298 dimension_type index() const;
00299
00300 private:
00302 Pseudo_Row<U> value;
00303
00305 dimension_type e;
00306
00308 dimension_type i;
00309
00310
00311
00312
00313 #ifdef __EDG__
00314 template <typename V> template<typename W>
00315 friend class OR_Matrix<V>::any_row_iterator;
00316 #else
00317 template <typename V> friend class any_row_iterator;
00318 #endif
00319 };
00320
00321 public:
00323 typedef any_row_iterator<T> row_iterator;
00324
00326 typedef any_row_iterator<const T> const_row_iterator;
00327
00329 typedef typename DB_Row<T>::iterator element_iterator;
00330
00332 typedef typename DB_Row<T>::const_iterator const_element_iterator;
00333
00334 public:
00336 static dimension_type max_num_rows();
00337
00339
00346 OR_Matrix(dimension_type space_dim);
00347
00349 OR_Matrix(const OR_Matrix& y);
00350
00352 template <typename U>
00353 explicit OR_Matrix(const OR_Matrix<U>& y);
00354
00356 ~OR_Matrix();
00357
00359 OR_Matrix& operator=(const OR_Matrix& y);
00360
00361 private:
00362 template <typename U> friend class OR_Matrix;
00363
00365
00372 DB_Row<T> vec;
00373
00375 dimension_type space_dim;
00376
00378 dimension_type vec_capacity;
00379
00381 OR_Matrix();
00382
00387 static dimension_type row_first_element_index(dimension_type k);
00388
00389 public:
00391 static dimension_type row_size(dimension_type k);
00392
00394 void swap(OR_Matrix& y);
00395
00396
00398
00409 void grow(dimension_type new_dim);
00410
00412
00419 void shrink(dimension_type new_dim);
00420
00422
00433 void resize_no_copy(dimension_type new_dim);
00434
00436 dimension_type space_dimension() const;
00437
00439 dimension_type num_rows() const;
00440
00442
00443
00444 row_reference_type operator[](dimension_type k);
00445
00447 const_row_reference_type operator[](dimension_type k) const;
00449
00450
00456 row_iterator row_begin();
00457
00459 row_iterator row_end();
00460
00466 const_row_iterator row_begin() const;
00467
00469 const_row_iterator row_end() const;
00470
00476 element_iterator element_begin();
00477
00479 element_iterator element_end();
00480
00486 const_element_iterator element_begin() const;
00487
00489 const_element_iterator element_end() const;
00490
00492 void clear();
00493
00494 PPL_OUTPUT_DECLARATIONS
00495
00501 bool ascii_load(std::istream& s);
00502
00504 memory_size_type total_memory_in_bytes() const;
00505
00507 memory_size_type external_memory_in_bytes() const;
00508
00509 friend bool operator==<T>(const OR_Matrix<T>& x, const OR_Matrix<T>& y);
00510
00512 bool OK() const;
00513 };
00514
00515 namespace std {
00516
00517 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00518
00519
00520 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00521 template <typename T>
00522 void swap(Parma_Polyhedra_Library::OR_Matrix<T>& x,
00523 Parma_Polyhedra_Library::OR_Matrix<T>& y);
00524
00525 }
00526
00527
00528 namespace Parma_Polyhedra_Library {
00529
00530 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00531
00532
00533 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00534 template <typename T>
00535 bool operator!=(const OR_Matrix<T>& x, const OR_Matrix<T>& y);
00536
00537 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00538
00539
00549 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00550 template <typename Temp, typename To, typename T>
00551 bool rectilinear_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00552 const OR_Matrix<T>& x,
00553 const OR_Matrix<T>& y,
00554 Rounding_Dir dir,
00555 Temp& tmp0,
00556 Temp& tmp1,
00557 Temp& tmp2);
00558
00559 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00560
00561
00571 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00572 template <typename Temp, typename To, typename T>
00573 bool euclidean_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00574 const OR_Matrix<T>& x,
00575 const OR_Matrix<T>& y,
00576 Rounding_Dir dir,
00577 Temp& tmp0,
00578 Temp& tmp1,
00579 Temp& tmp2);
00580
00581 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00582
00583
00593 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00594 template <typename Temp, typename To, typename T>
00595 bool l_infinity_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00596 const OR_Matrix<T>& x,
00597 const OR_Matrix<T>& y,
00598 Rounding_Dir dir,
00599 Temp& tmp0,
00600 Temp& tmp1,
00601 Temp& tmp2);
00602
00603 }
00604
00605 #include "OR_Matrix.inlines.hh"
00606 #include "OR_Matrix.templates.hh"
00607
00608 #endif // !defined(PPL_OR_Matrix_defs_hh)