[Lemon-commits] [lemon_svn] deba: r2280 - in hugo/trunk: lemon test
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:51:28 CET 2006
Author: deba
Date: Wed Nov 2 16:24:38 2005
New Revision: 2280
Modified:
hugo/trunk/lemon/matrix_maps.h
hugo/trunk/test/matrix_maps_test.cc
Log:
Swap col and row map
Modified: hugo/trunk/lemon/matrix_maps.h
==============================================================================
--- hugo/trunk/lemon/matrix_maps.h (original)
+++ hugo/trunk/lemon/matrix_maps.h Wed Nov 2 16:24:38 2005
@@ -35,168 +35,168 @@
///
/// Map for the coloumn view of the matrix.
template <typename _MatrixMap>
- class MatrixColMap : public MapTraits<_MatrixMap> {
+ class MatrixRowMap : public MapTraits<_MatrixMap> {
public:
typedef _MatrixMap MatrixMap;
typedef typename MatrixMap::SecondKey Key;
typedef typename MatrixMap::Value Value;
- MatrixColMap(MatrixMap& _matrix, typename MatrixMap::FirstKey _col)
- : matrix(_matrix), col(_col) {}
+ MatrixRowMap(MatrixMap& _matrix, typename MatrixMap::FirstKey _row)
+ : matrix(_matrix), row(_row) {}
/// \brief Subscription operator
///
/// Subscription operator.
typename MapTraits<MatrixMap>::ReturnValue
- operator[](Key row) {
- return matrix(col, row);
+ operator[](Key col) {
+ return matrix(row, col);
}
/// \brief Setter function
///
/// Setter function.
- void set(Key row, const Value& val) {
- matrix.set(col, row, val);
+ void set(Key col, const Value& val) {
+ matrix.set(row, col, val);
}
/// \brief Subscription operator
///
/// Subscription operator.
typename MapTraits<MatrixMap>::ConstReturnValue
- operator[](Key row) const {
- return matrix(col, row);
+ operator[](Key col) const {
+ return matrix(row, col);
}
private:
MatrixMap& matrix;
- typename MatrixMap::FirstKey col;
+ typename MatrixMap::FirstKey row;
};
- /// \brief Map for the coloumn view of the matrix
+ /// \brief Map for the row view of the matrix
///
- /// Map for the coloumn view of the matrix.
+ /// Map for the row view of the matrix.
template <typename _MatrixMap>
- class ConstMatrixColMap : public MapTraits<_MatrixMap> {
+ class ConstMatrixRowMap : public MapTraits<_MatrixMap> {
public:
typedef _MatrixMap MatrixMap;
typedef typename MatrixMap::SecondKey Key;
typedef typename MatrixMap::Value Value;
- ConstMatrixColMap(const MatrixMap& _matrix,
- typename MatrixMap::FirstKey _col)
- : matrix(_matrix), col(_col) {}
+ ConstMatrixRowMap(const MatrixMap& _matrix,
+ typename MatrixMap::FirstKey _row)
+ : matrix(_matrix), row(_row) {}
/// \brief Subscription operator
///
/// Subscription operator.
typename MapTraits<MatrixMap>::ConstReturnValue
- operator[](Key row) const {
- return matrix(col, row);
+ operator[](Key col) const {
+ return matrix(row, col);
}
private:
const MatrixMap& matrix;
- typename MatrixMap::FirstKey col;
+ typename MatrixMap::FirstKey row;
};
- /// \brief Gives back a coloumn view of the matrix map
+ /// \brief Gives back a row view of the matrix map
///
- /// Gives back a coloumn view of the matrix map.
+ /// Gives back a row view of the matrix map.
template <typename MatrixMap>
- MatrixColMap<MatrixMap> matrixColMap(MatrixMap& matrixMap,
- typename MatrixMap::FirstKey col) {
- return MatrixColMap<MatrixMap>(matrixMap, col);
+ MatrixRowMap<MatrixMap> matrixRowMap(MatrixMap& matrixMap,
+ typename MatrixMap::FirstKey row) {
+ return MatrixRowMap<MatrixMap>(matrixMap, row);
}
template <typename MatrixMap>
- ConstMatrixColMap<MatrixMap>
- matrixColMap(const MatrixMap& matrixMap, typename MatrixMap::FirstKey col) {
- return ConstMatrixColMap<MatrixMap>(matrixMap, col);
+ ConstMatrixRowMap<MatrixMap>
+ matrixRowMap(const MatrixMap& matrixMap, typename MatrixMap::FirstKey row) {
+ return ConstMatrixRowMap<MatrixMap>(matrixMap, row);
}
/// \brief Map for the row view of the matrix
///
/// Map for the row view of the matrix.
template <typename _MatrixMap>
- class MatrixRowMap : public MapTraits<_MatrixMap> {
+ class MatrixColMap : public MapTraits<_MatrixMap> {
public:
typedef _MatrixMap MatrixMap;
typedef typename MatrixMap::FirstKey Key;
typedef typename MatrixMap::Value Value;
- MatrixRowMap(MatrixMap& _matrix, typename MatrixMap::SecondKey _row)
- : matrix(_matrix), row(_row) {}
+ MatrixColMap(MatrixMap& _matrix, typename MatrixMap::SecondKey _col)
+ : matrix(_matrix), col(_col) {}
/// \brief Subscription operator
///
/// Subscription operator.
typename MapTraits<MatrixMap>::ReturnValue
- operator[](Key col) {
- return matrix(col, row);
+ operator[](Key row) {
+ return matrix(row, col);
}
/// \brief Setter function
///
/// Setter function.
- void set(Key col, const Value& val) {
- matrix.set(col, row, val);
+ void set(Key row, const Value& val) {
+ matrix.set(row, col, val);
}
/// \brief Subscription operator
///
/// Subscription operator.
typename MapTraits<MatrixMap>::ConstReturnValue
- operator[](Key col) const {
- return matrix(col, row);
+ operator[](Key row) const {
+ return matrix(row, col);
}
private:
MatrixMap& matrix;
- typename MatrixMap::SecondKey row;
+ typename MatrixMap::SecondKey col;
};
- /// \brief Map for the row view of the matrix
+ /// \brief Map for the col view of the matrix
///
- /// Map for the row view of the matrix.
+ /// Map for the col view of the matrix.
template <typename _MatrixMap>
- class ConstMatrixRowMap : public MapTraits<_MatrixMap> {
+ class ConstMatrixColMap : public MapTraits<_MatrixMap> {
public:
typedef _MatrixMap MatrixMap;
typedef typename MatrixMap::FirstKey Key;
typedef typename MatrixMap::Value Value;
- ConstMatrixRowMap(const MatrixMap& _matrix,
- typename MatrixMap::SecondKey _row)
- : matrix(_matrix), row(_row) {}
+ ConstMatrixColMap(const MatrixMap& _matrix,
+ typename MatrixMap::SecondKey _col)
+ : matrix(_matrix), col(_col) {}
/// \brief Subscription operator
///
/// Subscription operator.
typename MapTraits<MatrixMap>::ConstReturnValue
- operator[](Key col) const {
- return matrix(col, row);
+ operator[](Key row) const {
+ return matrix(row, col);
}
private:
const MatrixMap& matrix;
- typename MatrixMap::SecondKey row;
+ typename MatrixMap::SecondKey col;
};
- /// \brief Gives back a row view of the matrix map
+ /// \brief Gives back a col view of the matrix map
///
- /// Gives back a row view of the matrix map.
+ /// Gives back a col view of the matrix map.
template <typename MatrixMap>
- MatrixRowMap<MatrixMap> matrixRowMap(MatrixMap& matrixMap,
- typename MatrixMap::SecondKey row) {
- return MatrixRowMap<MatrixMap>(matrixMap, row);
+ MatrixColMap<MatrixMap> matrixColMap(MatrixMap& matrixMap,
+ typename MatrixMap::SecondKey col) {
+ return MatrixColMap<MatrixMap>(matrixMap, col);
}
template <typename MatrixMap>
- ConstMatrixRowMap<MatrixMap>
- matrixRowMap(const MatrixMap& matrixMap, typename MatrixMap::SecondKey row) {
- return ConstMatrixRowMap<MatrixMap>(matrixMap, row);
+ ConstMatrixColMap<MatrixMap>
+ matrixColMap(const MatrixMap& matrixMap, typename MatrixMap::SecondKey col) {
+ return ConstMatrixColMap<MatrixMap>(matrixMap, col);
}
/// \brief Container for store values for each ordered pair of graph items
Modified: hugo/trunk/test/matrix_maps_test.cc
==============================================================================
--- hugo/trunk/test/matrix_maps_test.cc (original)
+++ hugo/trunk/test/matrix_maps_test.cc Wed Nov 2 16:24:38 2005
@@ -53,15 +53,15 @@
int val = urandom(100);
matrix.set(it, jt, val);
check(matrix(it, jt) == val, "Wrong assign");
- check(matrix(it, jt) == matrixColMap(matrix, it)[jt], "Wrong colMap");
- check(matrix(it, jt) == matrixRowMap(matrix, jt)[it], "Wrong rowMap");
+ check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
+ check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
}
}
const IntMatrixMap& cm = matrix;
for (Graph::NodeIt it(graph); it != INVALID; ++it) {
for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
- check(cm(it, jt) == matrixColMap(cm, it)[jt], "Wrong colMap");
- check(cm(it, jt) == matrixRowMap(cm, jt)[it], "Wrong rowMap");
+ check(cm(it, jt) == matrixRowMap(cm, it)[jt], "Wrong rowMap");
+ check(cm(it, jt) == matrixColMap(cm, jt)[it], "Wrong colMap");
}
}
}
@@ -95,15 +95,15 @@
matrix.set(it, jt, val);
check(matrix(it, jt) == val, "Wrong assign");
check(matrix(jt, it) == val, "Wrong assign");
- check(matrix(it, jt) == matrixColMap(matrix, it)[jt], "Wrong colMap");
- check(matrix(it, jt) == matrixRowMap(matrix, jt)[it], "Wrong rowMap");
+ check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
+ check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
}
}
const IntMatrixMap& cm = matrix;
for (Graph::NodeIt it(graph); it != INVALID; ++it) {
for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
- check(cm(it, jt) == matrixColMap(cm, it)[jt], "Wrong colMap");
- check(cm(it, jt) == matrixRowMap(cm, jt)[it], "Wrong rowMap");
+ check(cm(it, jt) == matrixRowMap(cm, it)[jt], "Wrong rowMap");
+ check(cm(it, jt) == matrixColMap(cm, jt)[it], "Wrong colMap");
}
}
}
More information about the Lemon-commits
mailing list