91 return upper_right_rank_;
100 return lower_left_rank_;
116 const std::pair <size_t, size_t>&
split()
const
127 return split_.first > 0 || split_.second > 0;
139 return witnesses_[index];
151 special_swap_ = std::make_pair(type, index);
160 return special_swap_.first != 0;
169 return special_swap_.first ==
'r';
178 return special_swap_.second;
192 template <
typename Matro
idType,
typename MatrixType>
203 upper_left_matroid.
resize(split_.first, split_.second);
204 for (
size_t row = 0; row < upper_left_matroid.
size1(); ++row)
206 for (
size_t column = 0; column < upper_left_matroid.
size2(); ++column)
208 upper_left_matrix.resize(split_.first, split_.second,
false);
209 for (
size_t row = 0; row < upper_left_matrix.size1(); ++row)
211 for (
size_t column = 0; column < upper_left_matrix.size2(); ++column)
212 upper_left_matrix(row, column) = matrix(row, column);
216 for (
size_t row = 0; row < lower_right_matroid.
size1(); ++row)
218 for (
size_t column = 0; column < lower_right_matroid.
size2(); ++column)
220 lower_right_matrix.resize(matrix.size1() - split_.first, matrix.size2() - split_.second,
false);
221 for (
size_t row = 0; row < lower_right_matrix.size1(); ++row)
223 for (
size_t column = 0; column < lower_right_matrix.size2(); ++column)
224 lower_right_matrix(row, column) = matrix(split_.first + row, split_.second + column);
227 else if (
rank() == 1 &&
witness().first >= split_.first)
231 upper_left_matroid.
resize(split_.first + 1, split_.second);
232 for (
size_t row = 0; row < split_.first; ++row)
235 for (
size_t column = 0; column < upper_left_matroid.
size2(); ++column)
238 upper_left_matrix.resize(split_.first + 1, split_.second,
false);
239 for (
size_t column = 0; column < upper_left_matrix.size2(); ++column)
241 for (
size_t row = 0; row < split_.first; ++row)
242 upper_left_matrix(row, column) = matrix(row, column);
243 upper_left_matrix(split_.first, column) = matrix(
witness().first, column);
247 for (
size_t row = 0; row < lower_right_matroid.
size1(); ++row)
249 for (
size_t column = 1; column < lower_right_matroid.
size2(); ++column)
253 lower_right_matrix.resize(matrix.size1() - split_.first, matrix.size2() - split_.second + 1,
false);
254 for (
size_t row = 0; row < lower_right_matrix.size1(); ++row)
256 for (
size_t column = 1; column < lower_right_matrix.size2(); ++column)
257 lower_right_matrix(row, column) = matrix(split_.first + row, split_.second + column - 1);
258 lower_right_matrix(row, 0) = matrix(split_.first + row,
witness().second);
261 else if (
rank() == 1 &&
witness().second >= split_.second)
265 upper_left_matroid.
resize(split_.first, split_.second + 1);
266 for (
size_t row = 0; row < split_.first; ++row)
268 for (
size_t column = 0; column < split_.second; ++column)
272 upper_left_matrix.resize(split_.first, split_.second + 1,
false);
273 for (
size_t row = 0; row < split_.first; ++row)
275 for (
size_t column = 0; column < split_.second; ++column)
276 upper_left_matrix(row, column) = matrix(row, column);
277 upper_left_matrix(row, split_.second) = matrix(row,
witness().second);
281 for (
size_t row = 1; row < lower_right_matroid.
size1(); ++row)
283 for (
size_t column = 0; column < lower_right_matroid.
size2(); ++column)
287 lower_right_matrix.resize(matrix.size1() - split_.first + 1, matrix.size2() - split_.second,
false);
288 for (
size_t column = 0; column < lower_right_matrix.size2(); ++column)
290 for (
size_t row = 1; row < lower_right_matrix.size1(); ++row)
291 lower_right_matrix(row, column) = matrix(split_.first + row - 1, split_.second + column);
292 lower_right_matrix(0, column) = matrix(
witness().first, split_.second + column);
299 upper_left_matroid.
resize(split_.first + 2, split_.second + 1);
300 for (
size_t row = 0; row < split_.first + 2; ++row)
302 for (
size_t column = 0; column < split_.second + 1; ++column)
305 upper_left_matrix.resize(split_.first + 2, split_.second + 1,
false);
306 for (
size_t row = 0; row < split_.first + 2; ++row)
308 for (
size_t column = 0; column < split_.second + 1; ++column)
309 upper_left_matrix(row, column) = matrix(row, column);
313 for (
size_t row = 0; row < lower_right_matroid.
size1(); ++row)
315 for (
size_t column = 0; column < lower_right_matroid.
size2(); ++column)
318 lower_right_matrix.resize(matrix.size1() - split_.first + 1, matrix.size2() - split_.second + 2,
false);
319 for (
size_t column = 0; column < lower_right_matrix.size2(); ++column)
321 for (
size_t row = 0; row < lower_right_matrix.size1(); ++row)
322 lower_right_matrix(row, column) = matrix(split_.first + row - 1, split_.second + column - 2);
328 std::pair <size_t, size_t> split_;
329 std::vector <std::pair <size_t, size_t> > witnesses_;
330 int upper_right_rank_;
331 int lower_left_rank_;
332 std::pair <char, size_t> special_swap_;
Definition: matroid.hpp:22
void resize(size_t size1, size_t size2)
Definition: matroid.hpp:63
size_t size1() const
Definition: matroid.hpp:77
size_t size2() const
Definition: matroid.hpp:86
name_type & name2(size_t index)
Definition: matroid.hpp:116
name_type & name1(size_t index)
Definition: matroid.hpp:96
Definition: separation.hpp:18
const witness_type & witness(size_t index=0) const
Definition: separation.hpp:137
void create_components(const MatroidType &matroid, const MatrixType &matrix, integer_matroid &upper_left_matroid, integer_matrix &upper_left_matrix, integer_matroid &lower_right_matroid, integer_matrix &lower_right_matrix) const
Definition: separation.hpp:193
size_t get_special_swap_index() const
Definition: separation.hpp:176
bool has_special_swap() const
Definition: separation.hpp:158
separation transposed()
Definition: separation.cpp:161
int rank() const
Definition: separation.hpp:107
separation()
Definition: separation.cpp:15
std::pair< std::size_t, std::size_t > split_type
Definition: separation.hpp:20
separation & operator=(const separation &other)
Definition: separation.cpp:137
int upper_right_rank() const
Definition: separation.hpp:89
~separation()
Definition: separation.cpp:152
bool has_special_row_swap() const
Definition: separation.hpp:167
bool is_valid() const
Definition: separation.hpp:125
void set_special_swap(char type, size_t index)
Definition: separation.hpp:149
int lower_left_rank() const
Definition: separation.hpp:98
const std::pair< size_t, size_t > & split() const
Definition: separation.hpp:116
std::pair< std::size_t, std::size_t > witness_type
Definition: separation.hpp:21
Definition: algorithm.hpp:14
boost::numeric::ublas::matrix< long long > integer_matrix
Definition: common.hpp:27