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_DB_Matrix_defs_hh
00025 #define PPL_DB_Matrix_defs_hh 1
00026
00027 #include "DB_Matrix.types.hh"
00028 #include "globals.defs.hh"
00029 #include "DB_Row.defs.hh"
00030 #include "Checked_Number.types.hh"
00031 #include "Rounding_Dir.defs.hh"
00032 #include <vector>
00033 #include <cstddef>
00034 #include <iosfwd>
00035
00036 namespace Parma_Polyhedra_Library {
00037
00038 namespace IO_Operators {
00039
00040 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00041
00042
00043 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00044 template <typename T>
00045 std::ostream&
00046 operator<<(std::ostream& s, const DB_Matrix<T>& c);
00047
00048 }
00049
00050 }
00051
00052
00053 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00054
00055
00060 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00061 template <typename T>
00062 class Parma_Polyhedra_Library::DB_Matrix {
00063 public:
00065 static dimension_type max_num_rows();
00066
00068 static dimension_type max_num_columns();
00069
00071
00074 DB_Matrix();
00075
00077 explicit DB_Matrix(dimension_type n_rows);
00078
00080 DB_Matrix(const DB_Matrix& y);
00081
00083 template <typename U>
00084 explicit DB_Matrix(const DB_Matrix<U>& y);
00085
00087 ~DB_Matrix();
00088
00090 DB_Matrix& operator=(const DB_Matrix& y);
00091
00092 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00093
00094
00095 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00096 class const_iterator {
00097 private:
00098 typedef typename std::vector<DB_Row<T> >::const_iterator Iter;
00100 Iter i;
00101
00102 public:
00103 typedef std::forward_iterator_tag iterator_category;
00104 typedef typename std::iterator_traits<Iter>::value_type value_type;
00105 typedef typename std::iterator_traits<Iter>::difference_type
00106 difference_type;
00107 typedef typename std::iterator_traits<Iter>::pointer pointer;
00108 typedef typename std::iterator_traits<Iter>::reference reference;
00109
00111 const_iterator();
00112
00117 explicit const_iterator(const Iter& b);
00118
00120 const_iterator(const const_iterator& y);
00121
00123 const_iterator& operator=(const const_iterator& y);
00124
00126 reference operator*() const;
00127
00129 pointer operator->() const;
00130
00132 const_iterator& operator++();
00133
00135 const_iterator operator++(int);
00136
00141 bool operator==(const const_iterator& y) const;
00142
00147 bool operator!=(const const_iterator& y) const;
00148 };
00149
00155 const_iterator begin() const;
00156
00158 const_iterator end() const;
00159
00160 private:
00161 template <typename U> friend class DB_Matrix;
00162
00164 std::vector<DB_Row<T> > rows;
00165
00167 dimension_type row_size;
00168
00173 dimension_type row_capacity;
00174
00175 public:
00177 void swap(DB_Matrix& y);
00178
00179
00181
00189 void grow(dimension_type new_n_rows);
00190
00192
00199 void resize_no_copy(dimension_type new_n_rows);
00200
00202 dimension_type num_rows() const;
00203
00205
00206
00207 DB_Row<T>& operator[](dimension_type k);
00208
00210 const DB_Row<T>& operator[](dimension_type k) const;
00212
00213 PPL_OUTPUT_DECLARATIONS
00214
00220 bool ascii_load(std::istream& s);
00221
00223 memory_size_type total_memory_in_bytes() const;
00224
00226 memory_size_type external_memory_in_bytes() const;
00227
00229 bool OK() const;
00230 };
00231
00232 namespace std {
00233
00234 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00235
00236
00237 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00238 template <typename T>
00239 void swap(Parma_Polyhedra_Library::DB_Matrix<T>& x,
00240 Parma_Polyhedra_Library::DB_Matrix<T>& y);
00241
00242 }
00243
00244
00245 namespace Parma_Polyhedra_Library {
00246
00247 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00248
00249
00250 #endif // defined(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
00255
00256
00257 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00258 template <typename T>
00259 bool operator!=(const DB_Matrix<T>& x, const DB_Matrix<T>& y);
00260
00261 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00262
00263
00273 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00274 template <typename Temp, typename To, typename T>
00275 bool rectilinear_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00276 const DB_Matrix<T>& x,
00277 const DB_Matrix<T>& y,
00278 Rounding_Dir dir,
00279 Temp& tmp0,
00280 Temp& tmp1,
00281 Temp& tmp2);
00282
00283 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00284
00285
00295 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00296 template <typename Temp, typename To, typename T>
00297 bool euclidean_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00298 const DB_Matrix<T>& x,
00299 const DB_Matrix<T>& y,
00300 Rounding_Dir dir,
00301 Temp& tmp0,
00302 Temp& tmp1,
00303 Temp& tmp2);
00304
00305 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00306
00307
00317 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00318 template <typename Temp, typename To, typename T>
00319 bool l_infinity_distance_assign(Checked_Number<To, Extended_Number_Policy>& r,
00320 const DB_Matrix<T>& x,
00321 const DB_Matrix<T>& y,
00322 Rounding_Dir dir,
00323 Temp& tmp0,
00324 Temp& tmp1,
00325 Temp& tmp2);
00326
00327 }
00328
00329 #include "DB_Matrix.inlines.hh"
00330 #include "DB_Matrix.templates.hh"
00331
00332 #endif // !defined(PPL_DB_Matrix_defs_hh)