CMR  1.3.0
matrix_transposed.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <boost/numeric/ublas/matrix_expression.hpp>
4 
5 #include "env_internal.h"
6 
7 namespace tu
8 {
9 
10  template <typename MatrixType>
11  void matrix_binary_pivot(MatrixType& matrix, size_t i, size_t j);
12 
13  namespace detail
14  {
15 
17 
18  template <typename OrientationCategory>
20  {
21  typedef boost::numeric::ublas::unknown_orientation_tag orientation_category;
22  };
23 
25 
26  template <>
27  struct transpose_orientation <boost::numeric::ublas::row_major_tag>
28  {
29  typedef boost::numeric::ublas::column_major_tag orientation_category;
30  };
31 
33 
34  template <>
35  struct transpose_orientation <boost::numeric::ublas::column_major_tag>
36  {
37  typedef boost::numeric::ublas::row_major_tag orientation_category;
38  };
39  }
40 
45  template <typename M>
46  class matrix_transposed: public boost::numeric::ublas::matrix_expression <matrix_transposed <M> >
47  {
48  public:
50  typedef M matrix_type;
51  typedef typename M::size_type size_type;
52  typedef typename M::difference_type difference_type;
53  typedef typename M::value_type value_type;
54  typedef typename M::const_reference const_reference;
55  typedef typename boost::mpl::if_ <boost::is_const <M>, typename M::const_reference, typename M::reference>::type reference;
56  typedef typename boost::mpl::if_ <boost::is_const <M>, typename M::const_closure_type, typename M::closure_type>::type matrix_closure_type;
60  typedef typename M::storage_category storage_category;
61 
62  private:
63  matrix_type& _data;
64 
65  public:
66 
74  _data(matrix)
75  {
76 
77  }
78 
83  inline size_type size1() const
84  {
85  return _data.size2();
86  }
87 
92  inline size_type size2() const
93  {
94  return _data.size1();
95  }
96 
101  inline matrix_type& data()
102  {
103  return _data;
104  }
105 
115  {
116  return _data(j, i);
117  }
118 
128  {
129  return _data(j, i);
130  }
131 
132  typedef boost::numeric::ublas::indexed_iterator1 <self_type, typename matrix_type::iterator2::iterator_category> iterator1;
133  typedef boost::numeric::ublas::indexed_iterator2 <self_type, typename matrix_type::iterator1::iterator_category> iterator2;
134  typedef boost::numeric::ublas::indexed_const_iterator1 <self_type, typename matrix_type::const_iterator2::iterator_category>
136  typedef boost::numeric::ublas::indexed_const_iterator2 <self_type, typename matrix_type::const_iterator1::iterator_category>
138  };
139 
147  template <typename MatrixType>
149  {
150  return matrix_transposed <MatrixType> (matrix);
151  }
152 
162  template <typename MatrixType>
163  inline void matrix_set_value(matrix_transposed <MatrixType>& matrix, size_t row, size_t column, typename MatrixType::value_type value)
164  {
165  matrix(row, column) = value;
166  }
167 
172  template <typename MatrixType>
173  inline void matrix_set_value(matrix_transposed <const MatrixType>& matrix, size_t row, size_t column, typename MatrixType::value_type value)
174  {
175  CMR_UNUSED(matrix);
176  CMR_UNUSED(row);
177  CMR_UNUSED(column);
178  CMR_UNUSED(value);
179  }
180 
189  template <typename MatrixType>
190  inline void matrix_binary_pivot(matrix_transposed <MatrixType>& matrix, size_t i, size_t j)
191  {
192  matrix_binary_pivot(matrix.data(), j, i);
193  }
194 
195 } /* namespace tu */
Definition: matrix_transposed.hpp:47
M::storage_category storage_category
Definition: matrix_transposed.hpp:60
matrix_transposed< M > self_type
Definition: matrix_transposed.hpp:49
self_type closure_type
Definition: matrix_transposed.hpp:58
boost::numeric::ublas::indexed_iterator1< self_type, typename matrix_type::iterator2::iterator_category > iterator1
Definition: matrix_transposed.hpp:132
M::value_type value_type
Definition: matrix_transposed.hpp:53
M matrix_type
Definition: matrix_transposed.hpp:50
M::difference_type difference_type
Definition: matrix_transposed.hpp:52
boost::numeric::ublas::indexed_iterator2< self_type, typename matrix_type::iterator1::iterator_category > iterator2
Definition: matrix_transposed.hpp:133
boost::numeric::ublas::indexed_const_iterator2< self_type, typename matrix_type::const_iterator1::iterator_category > const_iterator2
Definition: matrix_transposed.hpp:137
boost::numeric::ublas::indexed_const_iterator1< self_type, typename matrix_type::const_iterator2::iterator_category > const_iterator1
Definition: matrix_transposed.hpp:135
const self_type const_closure_type
Definition: matrix_transposed.hpp:57
M::size_type size_type
Definition: matrix_transposed.hpp:51
matrix_type & data()
Definition: matrix_transposed.hpp:101
size_type size1() const
Definition: matrix_transposed.hpp:83
M::const_reference const_reference
Definition: matrix_transposed.hpp:54
matrix_transposed(matrix_type &matrix)
Definition: matrix_transposed.hpp:73
const_reference operator()(size_type i, size_type j) const
Definition: matrix_transposed.hpp:114
size_type size2() const
Definition: matrix_transposed.hpp:92
boost::mpl::if_< boost::is_const< M >, typename M::const_reference, typename M::reference >::type reference
Definition: matrix_transposed.hpp:55
detail::transpose_orientation< typename M::orientation_category >::orientation_category orientation_category
Definition: matrix_transposed.hpp:59
boost::mpl::if_< boost::is_const< M >, typename M::const_closure_type, typename M::closure_type >::type matrix_closure_type
Definition: matrix_transposed.hpp:56
#define CMR_UNUSED(x)
Definition: env.h:24
Definition: matroid_graph.hpp:26
Definition: algorithm.hpp:14
matrix_transposed< MatrixType > make_transposed_matrix(MatrixType &matrix)
Definition: matrix_transposed.hpp:148
void matrix_set_value(matrix_permuted< MatrixType > &matrix, size_t row, size_t column, typename MatrixType::value_type value)
Definition: matrix_permuted.hpp:168
void matrix_binary_pivot(matrix_permuted< MatrixType > &matrix, size_t i, size_t j)
Definition: matrix_permuted.hpp:224
boost::numeric::ublas::row_major_tag orientation_category
Definition: matrix_transposed.hpp:37
boost::numeric::ublas::column_major_tag orientation_category
Definition: matrix_transposed.hpp:29
Helper struct to manage orientation tags.
Definition: matrix_transposed.hpp:20
boost::numeric::ublas::unknown_orientation_tag orientation_category
Definition: matrix_transposed.hpp:21