8 template <
typename MatrixType>
21 matrix_(matrix), data_(matrix.size2())
27 matrix_(other.matrix_)
29 dimension_ = other.dimension_;
39 for (
size_t column = 0; column < base_; ++column)
41 data_[column] = std::make_pair(
PARALLEL, column);
43 for (
size_t column = base_; column < matrix_.size2(); ++column)
47 for (
size_t r = 0; r < dimension_; ++r)
49 if (matrix_(r, column) != 0)
58 data_[column] = std::make_pair(
UNIT_VECTOR, last_one);
61 data_[column] = std::make_pair(
OTHER, 0);
62 for (
size_t b = 0; b < base_; ++b)
64 if (are_equal(0, dimension_, column, b))
66 data_[column] = std::make_pair(
PARALLEL, b);
90 return data_[index].first ==
PARALLEL;
105 return data_[index].first ==
OTHER;
110 return data_[index].second;
115 assert(index1 < dimension_);
116 assert(index2 < dimension_);
118 for (
size_t column = base_; column < data_.size(); ++column)
123 data_[column].second = index2;
125 data_[column].second = index1;
132 assert(index1 >= base_);
133 assert(index2 >= base_);
135 std::swap(data_[index1], data_[index2]);
142 data_[base_] = std::make_pair(
PARALLEL, base_);
143 for (
size_t column = base_ + 1; column < matrix_.size2(); ++column)
145 if (are_equal(0, dimension_, column, base_))
147 data_[column] = std::make_pair(
PARALLEL, base_);
156 for (
size_t column = base_; column < matrix_.size2(); ++column)
158 if (data_[column].first ==
OTHER)
163 for (
size_t row = 0; row < amount; ++row)
165 if (matrix_(dimension_ + row, column) != 0)
168 last_row = dimension_ + row;
172 if (data_[column].first ==
ZERO_VECTOR && count == 1)
174 data_[column] = std::make_pair(
UNIT_VECTOR, last_row);
176 else if ((data_[column].first ==
ZERO_VECTOR && count > 1) || (data_[column].first ==
UNIT_VECTOR && count > 0))
178 data_[column].first =
OTHER;
179 for (
size_t b = 0; b < base_; ++b)
181 if (are_equal(0, dimension_ + amount, column, b))
183 data_[column] = std::make_pair(
PARALLEL, b);
187 else if (data_[column].first ==
PARALLEL)
189 if (!are_equal(dimension_, dimension_ + amount, column, data_[column].second))
191 data_[column].first =
OTHER;
196 dimension_ += amount;
201 if (other.base_ != base_)
203 if (other.dimension_ != dimension_)
205 for (
size_t i = 0; i < data_.size(); ++i)
207 if (data_[i] != other.data_[i])
213 std::ostream&
print(std::ostream& stream)
215 stream <<
"base = " << base_ <<
", dim = " << dimension_ <<
"\n";
216 for (
size_t i = 0; i < data_.size(); ++i)
218 stream <<
"data[" << i <<
"] = " << ((int) data_[i].first) <<
", " << data_[i].second << std::endl;
225 bool are_equal(
size_t row_first,
size_t row_beyond,
size_t column1,
size_t column2)
227 for (
size_t row = row_first; row < row_beyond; ++row)
229 if (matrix_(row, column1) != matrix_(row, column2))
238 std::vector <vector_data> data_;
Definition: vector_three_connectivity.hpp:10
const unsigned char ZERO_VECTOR
Definition: vector_three_connectivity.hpp:15
const unsigned char OTHER
Definition: vector_three_connectivity.hpp:18
std::pair< unsigned char, size_t > vector_data
Definition: vector_three_connectivity.hpp:13
bool operator==(const vector_three_connectivity< MatrixType > &other)
Definition: vector_three_connectivity.hpp:199
void swap_cross(size_t index1, size_t index2)
Definition: vector_three_connectivity.hpp:113
size_t get_referred(size_t index) const
Definition: vector_three_connectivity.hpp:108
void reset(size_t dimension, size_t base)
Definition: vector_three_connectivity.hpp:34
bool is_parallel(size_t index) const
Definition: vector_three_connectivity.hpp:88
void enlarge_base(size_t amount=1)
Definition: vector_three_connectivity.hpp:138
bool is_zero(size_t index) const
Definition: vector_three_connectivity.hpp:93
vector_three_connectivity(const vector_three_connectivity< MatrixType > &other)
Definition: vector_three_connectivity.hpp:26
~vector_three_connectivity()
Definition: vector_three_connectivity.hpp:73
bool is_unit(size_t index) const
Definition: vector_three_connectivity.hpp:98
const unsigned char PARALLEL
Definition: vector_three_connectivity.hpp:17
vector_three_connectivity(const matrix_type &matrix, size_t dimension, size_t base)
Definition: vector_three_connectivity.hpp:20
void swap_vectors(size_t index1, size_t index2)
Definition: vector_three_connectivity.hpp:130
size_t base() const
Definition: vector_three_connectivity.hpp:78
void enlarge_dimension(size_t amount=1)
Definition: vector_three_connectivity.hpp:154
std::ostream & print(std::ostream &stream)
Definition: vector_three_connectivity.hpp:213
const unsigned char UNIT_VECTOR
Definition: vector_three_connectivity.hpp:16
bool is_other(size_t index) const
Definition: vector_three_connectivity.hpp:103
MatrixType matrix_type
Definition: vector_three_connectivity.hpp:12
size_t dimension() const
Definition: vector_three_connectivity.hpp:83
Definition: algorithm.hpp:14