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 // defined(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 // defined(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 // defined(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 memory_size_type total_memory_in_bytes() const;
00223
00225 memory_size_type external_memory_in_bytes() const;
00226
00228 bool OK() const;
00229 };
00230
00231 namespace std {
00232
00233 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00235
00236 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00237 template <typename T>
00238 void swap(Parma_Polyhedra_Library::DB_Matrix<T>& x,
00239 Parma_Polyhedra_Library::DB_Matrix<T>& y);
00240
00241 }
00242
00243
00244 namespace Parma_Polyhedra_Library {
00245
00246 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00248
00249 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00250 template <typename T>
00251 bool operator==(const DB_Matrix<T>& x, const DB_Matrix<T>& y);
00252
00253 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00255
00256 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00257 template <typename T>
00258 bool operator!=(const DB_Matrix<T>& x, const DB_Matrix<T>& y);
00259
00260 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00262
00272 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00273 template <typename Temp, typename To, typename T>
00274 bool rectilinear_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00275 const DB_Matrix<T>& x,
00276 const DB_Matrix<T>& y,
00277 Rounding_Dir dir,
00278 Temp& tmp0,
00279 Temp& tmp1,
00280 Temp& tmp2);
00281
00282 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00284
00294 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00295 template <typename Temp, typename To, typename T>
00296 bool euclidean_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00297 const DB_Matrix<T>& x,
00298 const DB_Matrix<T>& y,
00299 Rounding_Dir dir,
00300 Temp& tmp0,
00301 Temp& tmp1,
00302 Temp& tmp2);
00303
00304 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00306
00316 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00317 template <typename Temp, typename To, typename T>
00318 bool l_infinity_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00319 const DB_Matrix<T>& x,
00320 const DB_Matrix<T>& y,
00321 Rounding_Dir dir,
00322 Temp& tmp0,
00323 Temp& tmp1,
00324 Temp& tmp2);
00325
00326 }
00327
00328 #include "DB_Matrix.inlines.hh"
00329 #include "DB_Matrix.templates.hh"
00330
00331 #endif // !defined(PPL_DB_Matrix_defs_hh)