00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef PPL_OR_Matrix_defs_hh
00025 #define PPL_OR_Matrix_defs_hh 1
00026
00027 #include "globals.defs.hh"
00028 #include "OR_Matrix.types.hh"
00029 #include "DB_Row.defs.hh"
00030 #include "Checked_Number.defs.hh"
00031 #include <cstddef>
00032 #include <iosfwd>
00033
00034 #ifndef PPL_OR_MATRIX_EXTRA_DEBUG
00035 #ifdef PPL_ABI_BREAKING_EXTRA_DEBUG
00036 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00037
00043 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00044 #define PPL_OR_MATRIX_EXTRA_DEBUG 1
00045 #else // !defined(PPL_ABI_BREAKING_EXTRA_DEBUG)
00046 #define PPL_OR_MATRIX_EXTRA_DEBUG 0
00047 #endif // !defined(PPL_ABI_BREAKING_EXTRA_DEBUG)
00048 #endif // !defined(PPL_OR_MATRIX_EXTRA_DEBUG)
00049
00050 namespace Parma_Polyhedra_Library {
00051
00052 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00054
00055 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00056 template <typename T>
00057 bool operator==(const OR_Matrix<T>& x, const OR_Matrix<T>& y);
00058
00059 namespace IO_Operators {
00060
00061 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00063
00064 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00065 template <typename T>
00066 std::ostream&
00067 operator<<(std::ostream& s, const OR_Matrix<T>& m);
00068
00069 }
00070
00071 }
00072
00073
00074 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00076
00102 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00103
00104 template <typename T>
00105 class Parma_Polyhedra_Library::OR_Matrix {
00106 private:
00111 template <typename U>
00112 class Pseudo_Row {
00113 public:
00119 template <typename V>
00120 Pseudo_Row(const Pseudo_Row<V>& y);
00121
00123 ~Pseudo_Row();
00124
00126 U& operator[](dimension_type k) const;
00127
00129 Pseudo_Row();
00130
00132 Pseudo_Row& operator=(const Pseudo_Row& y);
00133
00134 #if !defined(__GNUC__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 0)
00135 private:
00136 #else
00137
00138 public:
00139 #endif
00140
00141 #if PPL_OR_MATRIX_EXTRA_DEBUG
00142
00144 Pseudo_Row(U& y, dimension_type s);
00145
00146 #else // !PPL_OR_MATRIX_EXTRA_DEBUG
00147
00149 explicit Pseudo_Row(U& y);
00150
00151 #endif // !PPL_OR_MATRIX_EXTRA_DEBUG
00152
00154 U* first;
00155
00156 #if !defined(__GNUC__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 0)
00157 #else
00158
00159 private:
00160 #endif
00161
00162 #if PPL_OR_MATRIX_EXTRA_DEBUG
00163
00165 dimension_type size_;
00166
00168 dimension_type size() const;
00169
00170 #endif // PPL_OR_MATRIX_EXTRA_DEBUG
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 template <typename V> friend class Pseudo_Row;
00183 template <typename V> friend class any_row_iterator;
00184
00185 friend class OR_Matrix;
00186 };
00187
00188 public:
00190 typedef Pseudo_Row<T> row_reference_type;
00191
00193 typedef Pseudo_Row<const T> const_row_reference_type;
00194
00195 private:
00200 template <typename U>
00201 class any_row_iterator {
00202 public:
00203 typedef std::random_access_iterator_tag iterator_category;
00204 typedef Pseudo_Row<U> value_type;
00205 typedef long difference_type;
00206 typedef const Pseudo_Row<U>* pointer;
00207 typedef const Pseudo_Row<U>& reference;
00208
00210 any_row_iterator(dimension_type n_rows);
00211
00216 explicit any_row_iterator(U& base);
00217
00222 template <typename V>
00223 any_row_iterator(const any_row_iterator<V>& y);
00224
00229 template <typename V>
00230 any_row_iterator& operator=(const any_row_iterator<V>& y);
00231
00233 reference operator*() const;
00234
00236 pointer operator->() const;
00237
00239 any_row_iterator& operator++();
00240
00242 any_row_iterator operator++(int);
00243
00245 any_row_iterator& operator--();
00246
00248 any_row_iterator operator--(int);
00249
00251 reference operator[](difference_type m) const;
00252
00254 any_row_iterator& operator+=(difference_type m);
00255
00257 any_row_iterator& operator-=(difference_type m);
00258
00260 difference_type operator-(const any_row_iterator& y) const;
00261
00263 any_row_iterator operator+(difference_type m) const;
00264
00266 any_row_iterator operator-(difference_type m) const;
00267
00269 bool operator==(const any_row_iterator& y) const;
00270
00275 bool operator!=(const any_row_iterator& y) const;
00276
00278 bool operator<(const any_row_iterator& y) const;
00279
00284 bool operator<=(const any_row_iterator& y) const;
00285
00287 bool operator>(const any_row_iterator& y) const;
00288
00293 bool operator>=(const any_row_iterator& y) const;
00294
00295 dimension_type row_size() const;
00296
00297 dimension_type index() const;
00298
00299 private:
00301 Pseudo_Row<U> value;
00302
00304 dimension_type e;
00305
00307 dimension_type i;
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317 template <typename V> friend class any_row_iterator;
00318 };
00319
00320 public:
00322 typedef any_row_iterator<T> row_iterator;
00323
00325 typedef any_row_iterator<const T> const_row_iterator;
00326
00328 typedef typename DB_Row<T>::iterator element_iterator;
00329
00331 typedef typename DB_Row<T>::const_iterator const_element_iterator;
00332
00333 public:
00335 static dimension_type max_num_rows();
00336
00338
00345 OR_Matrix(dimension_type space_dim);
00346
00348 OR_Matrix(const OR_Matrix& y);
00349
00351 template <typename U>
00352 explicit OR_Matrix(const OR_Matrix<U>& y);
00353
00355 ~OR_Matrix();
00356
00358 OR_Matrix& operator=(const OR_Matrix& y);
00359
00360 private:
00361 template <typename U> friend class OR_Matrix;
00362
00364
00371 DB_Row<T> vec;
00372
00374 dimension_type space_dim;
00375
00377 dimension_type vec_capacity;
00378
00380 OR_Matrix();
00381
00386 static dimension_type row_first_element_index(dimension_type k);
00387
00388 public:
00390 static dimension_type row_size(dimension_type k);
00391
00393 void swap(OR_Matrix& y);
00394
00395
00397
00408 void grow(dimension_type new_dim);
00409
00411
00418 void shrink(dimension_type new_dim);
00419
00421
00432 void resize_no_copy(dimension_type new_dim);
00433
00435 dimension_type space_dimension() const;
00436
00438 dimension_type num_rows() const;
00439
00441
00442
00443 row_reference_type operator[](dimension_type k);
00444
00446 const_row_reference_type operator[](dimension_type k) const;
00448
00449
00455 row_iterator row_begin();
00456
00458 row_iterator row_end();
00459
00465 const_row_iterator row_begin() const;
00466
00468 const_row_iterator row_end() const;
00469
00475 element_iterator element_begin();
00476
00478 element_iterator element_end();
00479
00485 const_element_iterator element_begin() const;
00486
00488 const_element_iterator element_end() const;
00489
00491 void clear();
00492
00493 PPL_OUTPUT_DECLARATIONS
00494
00500 bool ascii_load(std::istream& s);
00501
00503 memory_size_type total_memory_in_bytes() const;
00504
00506 memory_size_type external_memory_in_bytes() const;
00507
00508 friend bool operator==<T>(const OR_Matrix<T>& x, const OR_Matrix<T>& y);
00509
00511 bool OK() const;
00512 };
00513
00514 namespace std {
00515
00516 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00518
00519 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00520 template <typename T>
00521 void swap(Parma_Polyhedra_Library::OR_Matrix<T>& x,
00522 Parma_Polyhedra_Library::OR_Matrix<T>& y);
00523
00524 }
00525
00526
00527 namespace Parma_Polyhedra_Library {
00528
00529 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00531
00532 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00533 template <typename T>
00534 bool operator!=(const OR_Matrix<T>& x, const OR_Matrix<T>& y);
00535
00536 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00538
00548 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00549 template <typename Temp, typename To, typename T>
00550 bool rectilinear_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00551 const OR_Matrix<T>& x,
00552 const OR_Matrix<T>& y,
00553 Rounding_Dir dir,
00554 Temp& tmp0,
00555 Temp& tmp1,
00556 Temp& tmp2);
00557
00558 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00560
00570 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00571 template <typename Temp, typename To, typename T>
00572 bool euclidean_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00573 const OR_Matrix<T>& x,
00574 const OR_Matrix<T>& y,
00575 Rounding_Dir dir,
00576 Temp& tmp0,
00577 Temp& tmp1,
00578 Temp& tmp2);
00579
00580 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00582
00592 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00593 template <typename Temp, typename To, typename T>
00594 bool l_infinity_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00595 const OR_Matrix<T>& x,
00596 const OR_Matrix<T>& y,
00597 Rounding_Dir dir,
00598 Temp& tmp0,
00599 Temp& tmp1,
00600 Temp& tmp2);
00601
00602 }
00603
00604 #include "OR_Matrix.inlines.hh"
00605 #include "OR_Matrix.templates.hh"
00606
00607 #endif // !defined(PPL_OR_Matrix_defs_hh)