00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef PPL_DB_Matrix_defs_hh
00024 #define PPL_DB_Matrix_defs_hh 1
00025
00026 #include "DB_Matrix.types.hh"
00027 #include "globals.defs.hh"
00028 #include "DB_Row.defs.hh"
00029 #include "Checked_Number.types.hh"
00030 #include "Rounding_Dir.defs.hh"
00031 #include <vector>
00032 #include <cstddef>
00033 #include <iosfwd>
00034
00035 namespace Parma_Polyhedra_Library {
00036
00037 namespace IO_Operators {
00038
00039 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00041
00042 #endif // PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00043 template <typename T>
00044 std::ostream&
00045 operator<<(std::ostream& s, const DB_Matrix<T>& c);
00046
00047 }
00048
00049 }
00050
00051
00052 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00054
00059 #endif // PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00060 template <typename T>
00061 class Parma_Polyhedra_Library::DB_Matrix {
00062 public:
00064 static dimension_type max_num_rows();
00065
00067 static dimension_type max_num_columns();
00068
00070
00073 DB_Matrix();
00074
00076 explicit DB_Matrix(dimension_type n_rows);
00077
00079 DB_Matrix(const DB_Matrix& y);
00080
00082 template <typename U>
00083 explicit DB_Matrix(const DB_Matrix<U>& y);
00084
00086 ~DB_Matrix();
00087
00089 DB_Matrix& operator=(const DB_Matrix& y);
00090
00091 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00093
00094 #endif // PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00095 class const_iterator {
00096 private:
00097 typedef typename std::vector<DB_Row<T> >::const_iterator Iter;
00099 Iter i;
00100
00101 public:
00102 typedef std::forward_iterator_tag iterator_category;
00103 typedef typename std::iterator_traits<Iter>::value_type value_type;
00104 typedef typename std::iterator_traits<Iter>::difference_type
00105 difference_type;
00106 typedef typename std::iterator_traits<Iter>::pointer pointer;
00107 typedef typename std::iterator_traits<Iter>::reference reference;
00108
00110 const_iterator();
00111
00116 explicit const_iterator(const Iter& b);
00117
00119 const_iterator(const const_iterator& y);
00120
00122 const_iterator& operator=(const const_iterator& y);
00123
00125 reference operator*() const;
00126
00128 pointer operator->() const;
00129
00131 const_iterator& operator++();
00132
00134 const_iterator operator++(int);
00135
00140 bool operator==(const const_iterator& y) const;
00141
00146 bool operator!=(const const_iterator& y) const;
00147 };
00148
00154 const_iterator begin() const;
00155
00157 const_iterator end() const;
00158
00159 private:
00160 template <typename U> friend class DB_Matrix;
00161
00163 std::vector<DB_Row<T> > rows;
00164
00166 dimension_type row_size;
00167
00172 dimension_type row_capacity;
00173
00174 public:
00176 void swap(DB_Matrix& y);
00177
00178
00180
00188 void grow(dimension_type new_n_rows);
00189
00191
00198 void resize_no_copy(dimension_type new_n_rows);
00199
00201 dimension_type num_rows() const;
00202
00204
00205
00206 DB_Row<T>& operator[](dimension_type k);
00207
00209 const DB_Row<T>& operator[](dimension_type k) const;
00211
00212 PPL_OUTPUT_DECLARATIONS;
00213
00219 bool ascii_load(std::istream& s);
00220
00222 bool OK() const;
00223 };
00224
00225 namespace std {
00226
00227 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00229
00230 #endif // PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00231 template <typename T>
00232 void swap(Parma_Polyhedra_Library::DB_Matrix<T>& x,
00233 Parma_Polyhedra_Library::DB_Matrix<T>& y);
00234
00235 }
00236
00237
00238 namespace Parma_Polyhedra_Library {
00239
00240 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00242
00243 #endif // PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00244 template <typename T>
00245 bool operator==(const DB_Matrix<T>& x, const DB_Matrix<T>& y);
00246
00247 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00249
00250 #endif // PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00251 template <typename T>
00252 bool operator!=(const DB_Matrix<T>& x, const DB_Matrix<T>& y);
00253
00254 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00256
00266 #endif // PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00267 template <typename Temp, typename To, typename T>
00268 bool rectilinear_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00269 const DB_Matrix<T>& x,
00270 const DB_Matrix<T>& y,
00271 const Rounding_Dir dir,
00272 Temp& tmp0,
00273 Temp& tmp1,
00274 Temp& tmp2);
00275
00276 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00278
00288 #endif // PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00289 template <typename Temp, typename To, typename T>
00290 bool euclidean_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00291 const DB_Matrix<T>& x,
00292 const DB_Matrix<T>& y,
00293 const Rounding_Dir dir,
00294 Temp& tmp0,
00295 Temp& tmp1,
00296 Temp& tmp2);
00297
00298 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00300
00310 #endif // PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00311 template <typename Temp, typename To, typename T>
00312 bool l_infinity_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00313 const DB_Matrix<T>& x,
00314 const DB_Matrix<T>& y,
00315 const Rounding_Dir dir,
00316 Temp& tmp0,
00317 Temp& tmp1,
00318 Temp& tmp2);
00319
00320 }
00321
00322 #include "DB_Matrix.inlines.hh"
00323
00324 #endif // !defined(PPL_DB_Matrix_defs_hh)