23 #ifndef BITMAP_CUBICAL_COMPLEX_PERIODIC_BOUNDARY_CONDITIONS_BASE_H_ 24 #define BITMAP_CUBICAL_COMPLEX_PERIODIC_BOUNDARY_CONDITIONS_BASE_H_ 26 #include <gudhi/Bitmap_cubical_complex_base.h> 34 namespace cubical_complex {
65 const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed);
79 const std::vector<T>& topDimensionalCells,
80 const std::vector< bool >& directions_in_which_periodic_b_cond_are_to_be_imposed);
101 std::vector< bool > directions_in_which_periodic_b_cond_are_to_be_imposed;
103 void set_up_containers(
const std::vector<unsigned>& sizes) {
104 unsigned multiplier = 1;
105 for (
size_t i = 0; i != sizes.size(); ++i) {
106 this->sizes.push_back(sizes[i]);
107 this->multipliers.push_back(multiplier);
109 if (directions_in_which_periodic_b_cond_are_to_be_imposed[i]) {
110 multiplier *= 2 * sizes[i];
112 multiplier *= 2 * sizes[i] + 1;
116 this->data = std::vector<T>(multiplier, std::numeric_limits<T>::max());
117 this->total_number_of_cells = multiplier;
121 const std::vector<T>& topDimensionalCells);
122 void construct_complex_based_on_top_dimensional_cells(
const std::vector<unsigned>& dimensions,
123 const std::vector<T>& topDimensionalCells,
124 const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed);
127 template <
typename T>
129 const std::vector<T>& topDimensionalCells,
130 const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed) {
131 this->directions_in_which_periodic_b_cond_are_to_be_imposed = directions_in_which_periodic_b_cond_are_to_be_imposed;
132 this->set_up_containers(dimensions);
142 template <
typename T>
144 const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed) {
145 this->directions_in_which_periodic_b_cond_are_to_be_imposed(directions_in_which_periodic_b_cond_are_to_be_imposed);
146 this->set_up_containers(sizes);
149 template <
typename T>
154 std::ifstream inFiltration;
155 inFiltration.open(perseus_style_file);
156 unsigned dimensionOfData;
157 inFiltration >> dimensionOfData;
159 this->directions_in_which_periodic_b_cond_are_to_be_imposed = std::vector<bool>(dimensionOfData,
false);
161 std::vector<unsigned> sizes;
162 sizes.reserve(dimensionOfData);
163 for (
size_t i = 0; i != dimensionOfData; ++i) {
164 int size_in_this_dimension;
165 inFiltration >> size_in_this_dimension;
166 if (size_in_this_dimension < 0) {
167 this->directions_in_which_periodic_b_cond_are_to_be_imposed[i] =
true;
169 sizes.push_back(abs(size_in_this_dimension));
171 this->set_up_containers(sizes);
176 while (!inFiltration.eof()) {
177 double filtrationLevel;
178 inFiltration >> filtrationLevel;
179 if (inFiltration.eof())
break;
182 std::cerr <<
"Cell of an index : " 183 << it.compute_index_in_bitmap()
184 <<
" and dimension: " 186 <<
" get the value : " << filtrationLevel << std::endl;
191 inFiltration.close();
195 template <
typename T>
197 this->directions_in_which_periodic_b_cond_are_to_be_imposed = std::vector<bool>(sizes.size(),
false);
198 this->set_up_containers(sizes);
201 template <
typename T>
203 const std::vector<T>& topDimensionalCells) {
204 std::vector<bool> directions_in_which_periodic_b_cond_are_to_be_imposed = std::vector<bool>(dimensions.size(),
false);
205 this->construct_complex_based_on_top_dimensional_cells(dimensions, topDimensionalCells,
206 directions_in_which_periodic_b_cond_are_to_be_imposed);
209 template <
typename T>
212 const std::vector<T>& topDimensionalCells,
213 const std::vector<bool>& directions_in_which_periodic_b_cond_are_to_be_imposed) {
214 this->construct_complex_based_on_top_dimensional_cells(dimensions, topDimensionalCells,
215 directions_in_which_periodic_b_cond_are_to_be_imposed);
220 template <
typename T>
224 std::cerr <<
"Computations of boundary of a cell : " << cell << std::endl;
227 std::vector< size_t > boundary_elements;
229 for (
size_t i = this->multipliers.size(); i != 0; --i) {
230 unsigned position = cell1 / this->multipliers[i - 1];
233 if (position % 2 == 1) {
235 if (!directions_in_which_periodic_b_cond_are_to_be_imposed[i - 1]) {
237 boundary_elements.push_back(cell - this->multipliers[ i - 1 ]);
238 boundary_elements.push_back(cell + this->multipliers[ i - 1 ]);
240 std::cerr << cell - this->multipliers[ i - 1 ] <<
" " << cell + this->multipliers[ i - 1 ] <<
" ";
244 if (position != 2 * this->sizes[ i - 1 ] - 1) {
246 boundary_elements.push_back(cell - this->multipliers[ i - 1 ]);
247 boundary_elements.push_back(cell + this->multipliers[ i - 1 ]);
249 std::cerr << cell - this->multipliers[ i - 1 ] <<
" " << cell + this->multipliers[ i - 1 ] <<
" ";
253 boundary_elements.push_back(cell - this->multipliers[ i - 1 ]);
254 boundary_elements.push_back(cell - (2 * this->sizes[ i - 1 ] - 1) * this->multipliers[ i - 1 ]);
256 std::cerr << cell - this->multipliers[ i - 1 ] <<
" " <<
257 cell - (2 * this->sizes[ i - 1 ] - 1) * this->multipliers[ i - 1 ] <<
" ";
262 cell1 = cell1 % this->multipliers[i - 1];
264 return boundary_elements;
267 template <
typename T>
269 std::vector<unsigned>
counter = this->compute_counter_for_given_cell(cell);
270 std::vector< size_t > coboundary_elements;
272 for (
size_t i = this->multipliers.size(); i != 0; --i) {
273 unsigned position = cell1 / this->multipliers[i - 1];
275 if (position % 2 == 0) {
276 if (!this->directions_in_which_periodic_b_cond_are_to_be_imposed[i - 1]) {
278 if ((counter[i - 1] != 0) && (cell > this->multipliers[i - 1])) {
279 coboundary_elements.push_back(cell - this->multipliers[i - 1]);
281 if ((counter[i - 1] != 2 * this->sizes[i - 1]) && (cell + this->multipliers[i - 1] < this->data.size())) {
282 coboundary_elements.push_back(cell + this->multipliers[i - 1]);
286 if (counter[i - 1] != 0) {
287 coboundary_elements.push_back(cell - this->multipliers[i - 1]);
288 coboundary_elements.push_back(cell + this->multipliers[i - 1]);
291 coboundary_elements.push_back(cell + this->multipliers[i - 1]);
292 coboundary_elements.push_back(cell + (2 * this->sizes[ i - 1 ] - 1) * this->multipliers[i - 1]);
297 cell1 = cell1 % this->multipliers[i - 1];
299 return coboundary_elements;
304 namespace Cubical_complex = cubical_complex;
308 #endif // BITMAP_CUBICAL_COMPLEX_PERIODIC_BOUNDARY_CONDITIONS_BASE_H_ void impose_lower_star_filtration()
Definition: Bitmap_cubical_complex_base.h:741
Cubical complex with periodic boundary conditions represented as a bitmap.
Definition: Bitmap_cubical_complex_periodic_boundary_conditions_base.h:49
Cubical complex represented as a bitmap, class with basic implementation.
Definition: Bitmap_cubical_complex_base.h:61
Definition: SimplicialComplexForAlpha.h:26
This is an implementation of a counter being a vector of integers.
Definition: counter.h:43
Bitmap_cubical_complex_periodic_boundary_conditions_base()
Definition: Bitmap_cubical_complex_periodic_boundary_conditions_base.h:56
unsigned get_dimension_of_a_cell(size_t cell) const
Definition: Bitmap_cubical_complex_base.h:711
Top_dimensional_cells_iterator top_dimensional_cells_iterator_end()
Definition: Bitmap_cubical_complex_base.h:403
Top_dimensional_cells_iterator top_dimensional_cells_iterator_begin()
Definition: Bitmap_cubical_complex_base.h:395
virtual std::vector< size_t > get_coboundary_of_a_cell(size_t cell) const
Definition: Bitmap_cubical_complex_periodic_boundary_conditions_base.h:268
virtual ~Bitmap_cubical_complex_periodic_boundary_conditions_base()
Definition: Bitmap_cubical_complex_periodic_boundary_conditions_base.h:85
T & get_cell_data(size_t cell)
Definition: Bitmap_cubical_complex_base.h:736
virtual std::vector< size_t > get_boundary_of_a_cell(size_t cell) const
Definition: Bitmap_cubical_complex_periodic_boundary_conditions_base.h:221
Iterator through top dimensional cells of the complex. The cells appear in order they are stored in t...
Definition: Bitmap_cubical_complex_base.h:314