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_Matrix_inlines_hh
00024 #define PPL_Matrix_inlines_hh 1
00025
00026 #include "globals.defs.hh"
00027 #include <algorithm>
00028 #include <cassert>
00029
00030 namespace Parma_Polyhedra_Library {
00031
00032 inline dimension_type
00033 Matrix::max_num_rows() {
00034 return std::vector<Row>().max_size();
00035 }
00036
00037 inline dimension_type
00038 Matrix::max_num_columns() {
00039 return Row::max_size();
00040 }
00041
00042 inline memory_size_type
00043 Matrix::total_memory_in_bytes() const {
00044 return sizeof(*this) + external_memory_in_bytes();
00045 }
00046
00047 inline
00048 Matrix::const_iterator::const_iterator()
00049 : i(Iter()) {
00050 }
00051
00052 inline
00053 Matrix::const_iterator::const_iterator(const Iter& b)
00054 : i(b) {
00055 }
00056
00057 inline
00058 Matrix::const_iterator::const_iterator(const const_iterator& y)
00059 : i(y.i) {
00060 }
00061
00062 inline Matrix::const_iterator&
00063 Matrix::const_iterator::operator=(const const_iterator& y) {
00064 i = y.i;
00065 return *this;
00066 }
00067
00068 inline Matrix::const_iterator::reference
00069 Matrix::const_iterator::operator*() const {
00070 return *i;
00071 }
00072
00073 inline Matrix::const_iterator::pointer
00074 Matrix::const_iterator::operator->() const {
00075 return &*i;
00076 }
00077
00078 inline Matrix::const_iterator&
00079 Matrix::const_iterator::operator++() {
00080 ++i;
00081 return *this;
00082 }
00083
00084 inline Matrix::const_iterator
00085 Matrix::const_iterator::operator++(int) {
00086 return const_iterator(i++);
00087 }
00088
00089 inline bool
00090 Matrix::const_iterator::operator==(const const_iterator& y) const {
00091 return i == y.i;
00092 }
00093
00094 inline bool
00095 Matrix::const_iterator::operator!=(const const_iterator& y) const {
00096 return !operator==(y);
00097 }
00098
00099 inline Matrix::const_iterator
00100 Matrix::begin() const {
00101 return const_iterator(rows.begin());
00102 }
00103
00104 inline Matrix::const_iterator
00105 Matrix::end() const {
00106 return const_iterator(rows.end());
00107 }
00108
00109 inline void
00110 Matrix::swap(Matrix& y) {
00111 std::swap(rows, y.rows);
00112 std::swap(row_size, y.row_size);
00113 std::swap(row_capacity, y.row_capacity);
00114 }
00115
00116 inline
00117 Matrix::Matrix()
00118 : rows(),
00119 row_size(0),
00120 row_capacity(0) {
00121 }
00122
00123 inline
00124 Matrix::Matrix(const Matrix& y)
00125 : rows(y.rows),
00126 row_size(y.row_size),
00127 row_capacity(compute_capacity(y.row_size, max_num_columns())) {
00128 }
00129
00130 inline
00131 Matrix::~Matrix() {
00132 }
00133
00134 inline Matrix&
00135 Matrix::operator=(const Matrix& y) {
00136
00137
00138
00139
00140 if (this != &y) {
00141
00142 rows = y.rows;
00143 row_size = y.row_size;
00144
00145
00146 row_capacity = compute_capacity(y.row_size, max_num_columns());
00147 }
00148 return *this;
00149 }
00150
00151 inline void
00152 Matrix::add_row(const Row& y) {
00153 Row new_row(y, row_capacity);
00154 add_recycled_row(new_row);
00155 }
00156
00157 inline Row&
00158 Matrix::operator[](const dimension_type k) {
00159 assert(k < rows.size());
00160 return rows[k];
00161 }
00162
00163 inline const Row&
00164 Matrix::operator[](const dimension_type k) const {
00165 assert(k < rows.size());
00166 return rows[k];
00167 }
00168
00169 inline dimension_type
00170 Matrix::num_rows() const {
00171 return rows.size();
00172 }
00173
00174 inline dimension_type
00175 Matrix::num_columns() const {
00176 return row_size;
00177 }
00178
00180 inline bool
00181 operator!=(const Matrix& x, const Matrix& y) {
00182 return !(x == y);
00183 }
00184
00185 inline void
00186 Matrix::erase_to_end(const dimension_type first_to_erase) {
00187 assert(first_to_erase <= rows.size());
00188 if (first_to_erase < rows.size())
00189 rows.erase(rows.begin() + first_to_erase, rows.end());
00190 }
00191
00192 inline void
00193 Matrix::clear() {
00194
00195 std::vector<Row>().swap(rows);
00196 row_size = 0;
00197 row_capacity = 0;
00198 }
00199
00200 }
00201
00202 namespace std {
00203
00205 inline void
00206 swap(Parma_Polyhedra_Library::Matrix& x,
00207 Parma_Polyhedra_Library::Matrix& y) {
00208 x.swap(y);
00209 }
00210
00211 }
00212
00213 #endif // !defined(PPL_Matrix_inlines_hh)