Changeset 1751:a2a454f1232d in lemon0.x for lemon/matrix_maps.h
 Timestamp:
 11/02/05 16:24:38 (17 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@2280
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/matrix_maps.h
r1720 r1751 36 36 /// Map for the coloumn view of the matrix. 37 37 template <typename _MatrixMap> 38 class Matrix ColMap : public MapTraits<_MatrixMap> {38 class MatrixRowMap : public MapTraits<_MatrixMap> { 39 39 public: 40 40 typedef _MatrixMap MatrixMap; … … 43 43 44 44 45 Matrix ColMap(MatrixMap& _matrix, typename MatrixMap::FirstKey _col)46 : matrix(_matrix), col(_col) {}45 MatrixRowMap(MatrixMap& _matrix, typename MatrixMap::FirstKey _row) 46 : matrix(_matrix), row(_row) {} 47 47 48 48 /// \brief Subscription operator … … 50 50 /// Subscription operator. 51 51 typename MapTraits<MatrixMap>::ReturnValue 52 operator[](Key row) {53 return matrix( col, row);52 operator[](Key col) { 53 return matrix(row, col); 54 54 } 55 55 … … 57 57 /// 58 58 /// Setter function. 59 void set(Key row, const Value& val) {60 matrix.set( col, row, val);59 void set(Key col, const Value& val) { 60 matrix.set(row, col, val); 61 61 } 62 62 … … 65 65 /// Subscription operator. 66 66 typename MapTraits<MatrixMap>::ConstReturnValue 67 operator[](Key row) const {68 return matrix( col, row);67 operator[](Key col) const { 68 return matrix(row, col); 69 69 } 70 70 71 71 private: 72 72 MatrixMap& matrix; 73 typename MatrixMap::FirstKey col;74 }; 75 76 /// \brief Map for the coloumnview of the matrix77 /// 78 /// Map for the coloumnview of the matrix.73 typename MatrixMap::FirstKey row; 74 }; 75 76 /// \brief Map for the row view of the matrix 77 /// 78 /// Map for the row view of the matrix. 79 79 template <typename _MatrixMap> 80 class ConstMatrix ColMap : public MapTraits<_MatrixMap> {80 class ConstMatrixRowMap : public MapTraits<_MatrixMap> { 81 81 public: 82 82 typedef _MatrixMap MatrixMap; … … 85 85 86 86 87 ConstMatrix ColMap(const MatrixMap& _matrix,88 typename MatrixMap::FirstKey _ col)89 : matrix(_matrix), col(_col) {}87 ConstMatrixRowMap(const MatrixMap& _matrix, 88 typename MatrixMap::FirstKey _row) 89 : matrix(_matrix), row(_row) {} 90 90 91 91 /// \brief Subscription operator … … 93 93 /// Subscription operator. 94 94 typename MapTraits<MatrixMap>::ConstReturnValue 95 operator[](Key row) const {96 return matrix( col, row);95 operator[](Key col) const { 96 return matrix(row, col); 97 97 } 98 98 99 99 private: 100 100 const MatrixMap& matrix; 101 typename MatrixMap::FirstKey col;102 }; 103 104 /// \brief Gives back a coloumnview of the matrix map105 /// 106 /// Gives back a coloumnview of the matrix map.101 typename MatrixMap::FirstKey row; 102 }; 103 104 /// \brief Gives back a row view of the matrix map 105 /// 106 /// Gives back a row view of the matrix map. 107 107 template <typename MatrixMap> 108 Matrix ColMap<MatrixMap> matrixColMap(MatrixMap& matrixMap,109 typename MatrixMap::FirstKey col) {110 return Matrix ColMap<MatrixMap>(matrixMap, col);108 MatrixRowMap<MatrixMap> matrixRowMap(MatrixMap& matrixMap, 109 typename MatrixMap::FirstKey row) { 110 return MatrixRowMap<MatrixMap>(matrixMap, row); 111 111 } 112 112 113 113 template <typename MatrixMap> 114 ConstMatrix ColMap<MatrixMap>115 matrix ColMap(const MatrixMap& matrixMap, typename MatrixMap::FirstKey col) {116 return ConstMatrix ColMap<MatrixMap>(matrixMap, col);114 ConstMatrixRowMap<MatrixMap> 115 matrixRowMap(const MatrixMap& matrixMap, typename MatrixMap::FirstKey row) { 116 return ConstMatrixRowMap<MatrixMap>(matrixMap, row); 117 117 } 118 118 … … 121 121 /// Map for the row view of the matrix. 122 122 template <typename _MatrixMap> 123 class Matrix RowMap : public MapTraits<_MatrixMap> {123 class MatrixColMap : public MapTraits<_MatrixMap> { 124 124 public: 125 125 typedef _MatrixMap MatrixMap; … … 127 127 typedef typename MatrixMap::Value Value; 128 128 129 Matrix RowMap(MatrixMap& _matrix, typename MatrixMap::SecondKey _row)130 : matrix(_matrix), row(_row) {}129 MatrixColMap(MatrixMap& _matrix, typename MatrixMap::SecondKey _col) 130 : matrix(_matrix), col(_col) {} 131 131 132 132 /// \brief Subscription operator … … 134 134 /// Subscription operator. 135 135 typename MapTraits<MatrixMap>::ReturnValue 136 operator[](Key col) {137 return matrix( col, row);136 operator[](Key row) { 137 return matrix(row, col); 138 138 } 139 139 … … 141 141 /// 142 142 /// Setter function. 143 void set(Key col, const Value& val) {144 matrix.set( col, row, val);143 void set(Key row, const Value& val) { 144 matrix.set(row, col, val); 145 145 } 146 146 … … 149 149 /// Subscription operator. 150 150 typename MapTraits<MatrixMap>::ConstReturnValue 151 operator[](Key col) const {152 return matrix( col, row);151 operator[](Key row) const { 152 return matrix(row, col); 153 153 } 154 154 155 155 private: 156 156 MatrixMap& matrix; 157 typename MatrixMap::SecondKey row;158 }; 159 160 /// \brief Map for the rowview of the matrix161 /// 162 /// Map for the rowview of the matrix.157 typename MatrixMap::SecondKey col; 158 }; 159 160 /// \brief Map for the col view of the matrix 161 /// 162 /// Map for the col view of the matrix. 163 163 template <typename _MatrixMap> 164 class ConstMatrix RowMap : public MapTraits<_MatrixMap> {164 class ConstMatrixColMap : public MapTraits<_MatrixMap> { 165 165 public: 166 166 typedef _MatrixMap MatrixMap; … … 168 168 typedef typename MatrixMap::Value Value; 169 169 170 ConstMatrix RowMap(const MatrixMap& _matrix,171 typename MatrixMap::SecondKey _ row)172 : matrix(_matrix), row(_row) {}170 ConstMatrixColMap(const MatrixMap& _matrix, 171 typename MatrixMap::SecondKey _col) 172 : matrix(_matrix), col(_col) {} 173 173 174 174 /// \brief Subscription operator … … 176 176 /// Subscription operator. 177 177 typename MapTraits<MatrixMap>::ConstReturnValue 178 operator[](Key col) const {179 return matrix( col, row);178 operator[](Key row) const { 179 return matrix(row, col); 180 180 } 181 181 182 182 private: 183 183 const MatrixMap& matrix; 184 typename MatrixMap::SecondKey row;185 }; 186 187 /// \brief Gives back a rowview of the matrix map188 /// 189 /// Gives back a rowview of the matrix map.184 typename MatrixMap::SecondKey col; 185 }; 186 187 /// \brief Gives back a col view of the matrix map 188 /// 189 /// Gives back a col view of the matrix map. 190 190 template <typename MatrixMap> 191 Matrix RowMap<MatrixMap> matrixRowMap(MatrixMap& matrixMap,192 typename MatrixMap::SecondKey row) {193 return Matrix RowMap<MatrixMap>(matrixMap, row);191 MatrixColMap<MatrixMap> matrixColMap(MatrixMap& matrixMap, 192 typename MatrixMap::SecondKey col) { 193 return MatrixColMap<MatrixMap>(matrixMap, col); 194 194 } 195 195 196 196 template <typename MatrixMap> 197 ConstMatrix RowMap<MatrixMap>198 matrix RowMap(const MatrixMap& matrixMap, typename MatrixMap::SecondKey row) {199 return ConstMatrix RowMap<MatrixMap>(matrixMap, row);197 ConstMatrixColMap<MatrixMap> 198 matrixColMap(const MatrixMap& matrixMap, typename MatrixMap::SecondKey col) { 199 return ConstMatrixColMap<MatrixMap>(matrixMap, col); 200 200 } 201 201
Note: See TracChangeset
for help on using the changeset viewer.