CMR  1.3.0
matroid_permuted.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "matroid.hpp"
4 
5 namespace tu
6 {
7 
12  template <typename MatroidType>
14  {
15  public:
16  typedef MatroidType matroid_type;
17  typedef typename MatroidType::size_type size_type;
18  typedef typename MatroidType::name_type name_type;
19  typedef typename boost::mpl::if_ <boost::is_const <MatroidType>, typename MatroidType::const_reference_type, typename MatroidType::reference_type>::type
24 
31  matroid_permuted(MatroidType& matroid) :
32  _matroid(matroid), _perm1(matroid.size1()), _perm2(matroid.size2())
33  {
34 
35  }
36 
41  inline size_type size1() const
42  {
43  return _perm1.size();
44  }
45 
50  inline size_type size2() const
51  {
52  return _perm2.size();
53  }
54 
59  inline const permutation_type& perm1() const
60  {
61  return _perm1;
62  }
63 
69  {
70  return _perm1;
71  }
72 
77  inline const permutation_type& perm2() const
78  {
79  return _perm2;
80  }
81 
87  {
88  return _perm2;
89  }
90 
97  {
98  return _matroid.name1(_perm1(index));
99  }
100 
107  {
108  return _matroid.name1(_perm1(index));
109  }
110 
117  {
118  return _matroid.name2(_perm2(index));
119  }
120 
127  {
128  return _matroid.name2(_perm2(index));
129  }
130 
135  inline matroid_type& data()
136  {
137  return _matroid;
138  }
139 
140  private:
141  MatroidType& _matroid;
142  permutation_type _perm1;
143  permutation_type _perm2;
144 
145  };
146 
155  template <typename MatroidType>
156  inline void matroid_permute1(matroid_permuted <MatroidType>& matroid, size_t index1, size_t index2)
157  {
158  matroid.perm1().swap(index1, index2);
159  }
160 
169  template <typename MatroidType>
170  inline void matroid_permute2(matroid_permuted <MatroidType>& matroid, size_t index1, size_t index2)
171  {
172  matroid.perm2().swap(index1, index2);
173  }
174 
183  template <typename MatroidType>
185  {
186  matroid_binary_pivot(matroid.data(), matroid.perm1()(i), matroid.perm2()(j));
187  }
188 
189  template <typename MatroidType>
191  {
192  matroid.perm1() = permutation;
193  }
194 
195  template <typename MatroidType>
197  {
198  matroid.perm2() = permutation;
199  }
200 
201  template <typename MatroidType>
203  {
205  }
206 
207  template <typename MatroidType>
209  {
211  }
212 
213 } /* namespace tu */
Definition: matroid_permuted.hpp:14
permutation permutation_type
Definition: matroid_permuted.hpp:23
size_type size1() const
Definition: matroid_permuted.hpp:41
const permutation_type & perm2() const
Definition: matroid_permuted.hpp:77
const_reference_type name2(size_type index) const
Definition: matroid_permuted.hpp:126
MatroidType::size_type size_type
Definition: matroid_permuted.hpp:17
const name_type & const_reference_type
Definition: matroid_permuted.hpp:21
const permutation_type & perm1() const
Definition: matroid_permuted.hpp:59
permutation_type & perm1()
Definition: matroid_permuted.hpp:68
reference_type name1(size_type index)
Definition: matroid_permuted.hpp:96
size_type size2() const
Definition: matroid_permuted.hpp:50
matroid_permuted< name_type > self_type
Definition: matroid_permuted.hpp:22
const_reference_type name1(size_type index) const
Definition: matroid_permuted.hpp:106
boost::mpl::if_< boost::is_const< MatroidType >, typename MatroidType::const_reference_type, typename MatroidType::reference_type >::type reference_type
Definition: matroid_permuted.hpp:20
MatroidType matroid_type
Definition: matroid_permuted.hpp:16
matroid_type & data()
Definition: matroid_permuted.hpp:135
MatroidType::name_type name_type
Definition: matroid_permuted.hpp:18
reference_type name2(size_type index)
Definition: matroid_permuted.hpp:116
permutation_type & perm2()
Definition: matroid_permuted.hpp:86
matroid_permuted(MatroidType &matroid)
Definition: matroid_permuted.hpp:31
Definition: matroid_transposed.hpp:14
Definition: matroid.hpp:22
Definition: permutations.hpp:44
size_type size() const
Definition: permutations.hpp:150
Definition: algorithm.hpp:14
void matroid_permute1(matroid< NameType > &matroid, size_t index1, size_t index2)
Definition: matroid.hpp:162
void matroid_permute2(matroid< NameType > &matroid, size_t index1, size_t index2)
Definition: matroid.hpp:192
void matroid_set_perm1(matroid_permuted< MatroidType > &matroid, const permutation &permutation)
Definition: matroid_permuted.hpp:190
void matroid_binary_pivot(matroid< NameType > &matroid, size_t i, size_t j)
Definition: matroid.hpp:222
void matroid_set_perm2(matroid_permuted< MatroidType > &matroid, const permutation &permutation)
Definition: matroid_permuted.hpp:196