Bitmap_cubical_complex_base.h
1 /* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
2  * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
3  * Author(s): Pawel Dlotko
4  *
5  * Copyright (C) 2015 Inria
6  *
7  * Modification(s):
8  * - YYYY/MM Author: Description of the modification
9  */
10 
11 #ifndef BITMAP_CUBICAL_COMPLEX_BASE_H_
12 #define BITMAP_CUBICAL_COMPLEX_BASE_H_
13 
14 #include <gudhi/Bitmap_cubical_complex/counter.h>
15 
16 #include <iostream>
17 #include <vector>
18 #include <string>
19 #include <fstream>
20 #include <algorithm>
21 #include <iterator>
22 #include <limits>
23 #include <utility>
24 #include <stdexcept>
25 #include <cstddef>
26 
27 namespace Gudhi {
28 
29 namespace cubical_complex {
30 
50 template <typename T>
52  public:
53  typedef T filtration_type;
54 
58  Bitmap_cubical_complex_base() : total_number_of_cells(0) {}
65  Bitmap_cubical_complex_base(const std::vector<unsigned>& sizes);
72  Bitmap_cubical_complex_base(const char* perseus_style_file);
77  Bitmap_cubical_complex_base(const std::vector<unsigned>& dimensions, const std::vector<T>& top_dimensional_cells);
78 
83 
95  virtual inline std::vector<std::size_t> get_boundary_of_a_cell(std::size_t cell) const;
110  virtual inline std::vector<std::size_t> get_coboundary_of_a_cell(std::size_t cell) const;
111 
131  virtual int compute_incidence_between_cells(std::size_t coface, std::size_t face) const {
132  // first get the counters for coface and face:
133  std::vector<unsigned> coface_counter = this->compute_counter_for_given_cell(coface);
134  std::vector<unsigned> face_counter = this->compute_counter_for_given_cell(face);
135 
136  // coface_counter and face_counter should agree at all positions except from one:
137  int number_of_position_in_which_counters_do_not_agree = -1;
138  std::size_t number_of_full_faces_that_comes_before = 0;
139  for (std::size_t i = 0; i != coface_counter.size(); ++i) {
140  if ((coface_counter[i] % 2 == 1) && (number_of_position_in_which_counters_do_not_agree == -1)) {
141  ++number_of_full_faces_that_comes_before;
142  }
143  if (coface_counter[i] != face_counter[i]) {
144  if (number_of_position_in_which_counters_do_not_agree != -1) {
145  std::cout << "Cells given to compute_incidence_between_cells procedure do not form a pair of coface-face.\n";
146  throw std::logic_error(
147  "Cells given to compute_incidence_between_cells procedure do not form a pair of coface-face.");
148  }
149  number_of_position_in_which_counters_do_not_agree = i;
150  }
151  }
152 
153  int incidence = 1;
154  if (number_of_full_faces_that_comes_before % 2) incidence = -1;
155  // if the face cell is on the right from coface cell:
156  if (coface_counter[number_of_position_in_which_counters_do_not_agree] + 1 ==
157  face_counter[number_of_position_in_which_counters_do_not_agree]) {
158  incidence *= -1;
159  }
160 
161  return incidence;
162  }
163 
172  inline unsigned get_dimension_of_a_cell(std::size_t cell) const;
173 
180  inline T& get_cell_data(std::size_t cell);
181 
190  void impose_lower_star_filtration(); // assume that top dimensional cells are already set.
191 
195  inline unsigned dimension() const { return sizes.size(); }
196 
200  inline unsigned size() const { return this->data.size(); }
201 
206  template <typename K>
207  friend std::ostream& operator<<(std::ostream& os, const Bitmap_cubical_complex_base<K>& b);
208 
217  void put_data_to_bins(std::size_t number_of_bins);
218 
229  void put_data_to_bins(T diameter_of_bin);
230 
234  std::pair<T, T> min_max_filtration();
235 
236  // ITERATORS
237 
242  class All_cells_iterator : std::iterator<std::input_iterator_tag, T> {
243  public:
244  All_cells_iterator() { this->counter = 0; }
245 
246  All_cells_iterator operator++() {
247  // first find first element of the counter that can be increased:
248  ++this->counter;
249  return *this;
250  }
251 
252  All_cells_iterator operator++(int) {
253  All_cells_iterator result = *this;
254  ++(*this);
255  return result;
256  }
257 
258  All_cells_iterator& operator=(const All_cells_iterator& rhs) {
259  this->counter = rhs.counter;
260  return *this;
261  }
262 
263  bool operator==(const All_cells_iterator& rhs) const {
264  if (this->counter != rhs.counter) return false;
265  return true;
266  }
267 
268  bool operator!=(const All_cells_iterator& rhs) const { return !(*this == rhs); }
269 
270  /*
271  * The operator * returns position of a cube in the structure of cubical complex. This position can be then used as
272  * an argument of the following functions:
273  * get_boundary_of_a_cell, get_coboundary_of_a_cell, get_dimension_of_a_cell to get information about the cell
274  * boundary and coboundary and dimension
275  * and in function get_cell_data to get a filtration of a cell.
276  */
277  std::size_t operator*() { return this->counter; }
278  friend class Bitmap_cubical_complex_base;
279 
280  protected:
281  std::size_t counter;
282  };
283 
289  return a;
290  }
291 
297  a.counter = this->data.size();
298  return a;
299  }
300 
305  public:
307 
308  All_cells_iterator begin() { return b->all_cells_iterator_begin(); }
309 
310  All_cells_iterator end() { return b->all_cells_iterator_end(); }
311 
312  private:
314  };
315 
316  All_cells_range all_cells_range() { return All_cells_range(this); }
317 
321  typedef typename std::vector<std::size_t>::const_iterator Boundary_iterator;
322  typedef typename std::vector<std::size_t> Boundary_range;
323 
328  Boundary_range boundary_range(std::size_t sh) { return this->get_boundary_of_a_cell(sh); }
329 
333  typedef typename std::vector<std::size_t>::const_iterator Coboundary_iterator;
334  typedef typename std::vector<std::size_t> Coboundary_range;
335 
340  Coboundary_range coboundary_range(std::size_t sh) { return this->get_coboundary_of_a_cell(sh); }
341 
346  class Top_dimensional_cells_iterator : std::iterator<std::input_iterator_tag, T> {
347  public:
349  this->counter = std::vector<std::size_t>(b.dimension());
350  // std::fill( this->counter.begin() , this->counter.end() , 0 );
351  }
352 
353  Top_dimensional_cells_iterator operator++() {
354  // first find first element of the counter that can be increased:
355  std::size_t dim = 0;
356  while ((dim != this->b.dimension()) && (this->counter[dim] == this->b.sizes[dim] - 1)) ++dim;
357 
358  if (dim != this->b.dimension()) {
359  ++this->counter[dim];
360  for (std::size_t i = 0; i != dim; ++i) {
361  this->counter[i] = 0;
362  }
363  } else {
364  ++this->counter[0];
365  }
366  return *this;
367  }
368 
369  Top_dimensional_cells_iterator operator++(int) {
370  Top_dimensional_cells_iterator result = *this;
371  ++(*this);
372  return result;
373  }
374 
376  this->counter = rhs.counter;
377  this->b = rhs.b;
378  return *this;
379  }
380 
381  bool operator==(const Top_dimensional_cells_iterator& rhs) const {
382  if (&this->b != &rhs.b) return false;
383  if (this->counter.size() != rhs.counter.size()) return false;
384  for (std::size_t i = 0; i != this->counter.size(); ++i) {
385  if (this->counter[i] != rhs.counter[i]) return false;
386  }
387  return true;
388  }
389 
390  bool operator!=(const Top_dimensional_cells_iterator& rhs) const { return !(*this == rhs); }
391 
392  /*
393  * The operator * returns position of a cube in the structure of cubical complex. This position can be then used as
394  * an argument of the following functions:
395  * get_boundary_of_a_cell, get_coboundary_of_a_cell, get_dimension_of_a_cell to get information about the cell
396  * boundary and coboundary and dimension
397  * and in function get_cell_data to get a filtration of a cell.
398  */
399  std::size_t operator*() { return this->compute_index_in_bitmap(); }
400 
401  std::size_t compute_index_in_bitmap() const {
402  std::size_t index = 0;
403  for (std::size_t i = 0; i != this->counter.size(); ++i) {
404  index += (2 * this->counter[i] + 1) * this->b.multipliers[i];
405  }
406  return index;
407  }
408 
409  void print_counter() const {
410  for (std::size_t i = 0; i != this->counter.size(); ++i) {
411  std::cout << this->counter[i] << " ";
412  }
413  }
414  friend class Bitmap_cubical_complex_base;
415 
416  protected:
417  std::vector<std::size_t> counter;
419  };
420 
426  return a;
427  }
428 
434  for (std::size_t i = 0; i != this->dimension(); ++i) {
435  a.counter[i] = this->sizes[i] - 1;
436  }
437  a.counter[0]++;
438  return a;
439  }
440 
445  public:
447 
449 
451 
452  private:
454  };
455 
456  Top_dimensional_cells_range top_dimensional_cells_range() { return Top_dimensional_cells_range(this); }
457 
458  //****************************************************************************************************************//
459  //****************************************************************************************************************//
460  //****************************************************************************************************************//
461  //****************************************************************************************************************//
462 
463  inline std::size_t number_cells() const { return this->total_number_of_cells; }
464 
465  //****************************************************************************************************************//
466  //****************************************************************************************************************//
467  //****************************************************************************************************************//
468  //****************************************************************************************************************//
469 
470  protected:
471  std::vector<unsigned> sizes;
472  std::vector<unsigned> multipliers;
473  std::vector<T> data;
474  std::size_t total_number_of_cells;
475 
476  void set_up_containers(const std::vector<unsigned>& sizes) {
477  unsigned multiplier = 1;
478  for (std::size_t i = 0; i != sizes.size(); ++i) {
479  this->sizes.push_back(sizes[i]);
480  this->multipliers.push_back(multiplier);
481  multiplier *= 2 * sizes[i] + 1;
482  }
483  this->data = std::vector<T>(multiplier, std::numeric_limits<T>::infinity());
484  this->total_number_of_cells = multiplier;
485  }
486 
487  std::size_t compute_position_in_bitmap(const std::vector<unsigned>& counter) {
488  std::size_t position = 0;
489  for (std::size_t i = 0; i != this->multipliers.size(); ++i) {
490  position += this->multipliers[i] * counter[i];
491  }
492  return position;
493  }
494 
495  std::vector<unsigned> compute_counter_for_given_cell(std::size_t cell) const {
496  std::vector<unsigned> counter;
497  counter.reserve(this->sizes.size());
498  for (std::size_t dim = this->sizes.size(); dim != 0; --dim) {
499  counter.push_back(cell / this->multipliers[dim - 1]);
500  cell = cell % this->multipliers[dim - 1];
501  }
502  std::reverse(counter.begin(), counter.end());
503  return counter;
504  }
505  void read_perseus_style_file(const char* perseus_style_file);
506  void setup_bitmap_based_on_top_dimensional_cells_list(const std::vector<unsigned>& sizes_in_following_directions,
507  const std::vector<T>& top_dimensional_cells);
508  Bitmap_cubical_complex_base(const char* perseus_style_file, std::vector<bool> directions);
509  Bitmap_cubical_complex_base(const std::vector<unsigned>& sizes, std::vector<bool> directions);
510  Bitmap_cubical_complex_base(const std::vector<unsigned>& dimensions, const std::vector<T>& top_dimensional_cells,
511  std::vector<bool> directions);
512 };
513 
514 template <typename T>
515 void Bitmap_cubical_complex_base<T>::put_data_to_bins(std::size_t number_of_bins) {
516  bool dbg = false;
517 
518  std::pair<T, T> min_max = this->min_max_filtration();
519  T dx = (min_max.second - min_max.first) / (T)number_of_bins;
520 
521  // now put the data into the appropriate bins:
522  for (std::size_t i = 0; i != this->data.size(); ++i) {
523  if (dbg) {
524  std::cerr << "Before binning : " << this->data[i] << std::endl;
525  }
526  this->data[i] = min_max.first + dx * (this->data[i] - min_max.first) / number_of_bins;
527  if (dbg) {
528  std::cerr << "After binning : " << this->data[i] << std::endl;
529  }
530  }
531 }
532 
533 template <typename T>
535  bool dbg = false;
536  std::pair<T, T> min_max = this->min_max_filtration();
537 
538  std::size_t number_of_bins = (min_max.second - min_max.first) / diameter_of_bin;
539  // now put the data into the appropriate bins:
540  for (std::size_t i = 0; i != this->data.size(); ++i) {
541  if (dbg) {
542  std::cerr << "Before binning : " << this->data[i] << std::endl;
543  }
544  this->data[i] = min_max.first + diameter_of_bin * (this->data[i] - min_max.first) / number_of_bins;
545  if (dbg) {
546  std::cerr << "After binning : " << this->data[i] << std::endl;
547  }
548  }
549 }
550 
551 template <typename T>
553  std::pair<T, T> min_max(std::numeric_limits<T>::infinity(), -std::numeric_limits<T>::infinity());
554  for (std::size_t i = 0; i != this->data.size(); ++i) {
555  if (this->data[i] < min_max.first) min_max.first = this->data[i];
556  if (this->data[i] > min_max.second) min_max.second = this->data[i];
557  }
558  return min_max;
559 }
560 
561 template <typename K>
562 std::ostream& operator<<(std::ostream& out, const Bitmap_cubical_complex_base<K>& b) {
563  for (typename Bitmap_cubical_complex_base<K>::all_cells_const_iterator it = b.all_cells_const_begin();
564  it != b.all_cells_const_end(); ++it) {
565  out << *it << " ";
566  }
567  return out;
568 }
569 
570 template <typename T>
572  this->set_up_containers(sizes);
573 }
574 
575 template <typename T>
577  const std::vector<unsigned>& sizes_in_following_directions, const std::vector<T>& top_dimensional_cells) {
578  this->set_up_containers(sizes_in_following_directions);
579 
580  std::size_t number_of_top_dimensional_elements = 1;
581  for (std::size_t i = 0; i != sizes_in_following_directions.size(); ++i) {
582  number_of_top_dimensional_elements *= sizes_in_following_directions[i];
583  }
584  if (number_of_top_dimensional_elements != top_dimensional_cells.size()) {
585  std::cerr << "Error in constructor Bitmap_cubical_complex_base ( std::vector<std::size_t> "
586  << "sizes_in_following_directions, std::vector<T> top_dimensional_cells ). Number of top dimensional "
587  << "elements that follow from sizes_in_following_directions vector is different than the size of "
588  << "top_dimensional_cells vector."
589  << std::endl;
590  throw(
591  "Error in constructor Bitmap_cubical_complex_base( std::vector<std::size_t> sizes_in_following_directions,"
592  "std::vector<T> top_dimensional_cells ). Number of top dimensional elements that follow from "
593  "sizes_in_following_directions vector is different than the size of top_dimensional_cells vector.");
594  }
595 
597  std::size_t index = 0;
598  for (it = this->top_dimensional_cells_iterator_begin(); it != this->top_dimensional_cells_iterator_end(); ++it) {
599  this->get_cell_data(*it) = top_dimensional_cells[index];
600  ++index;
601  }
603 }
604 
605 template <typename T>
606 Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base(const std::vector<unsigned>& sizes_in_following_directions,
607  const std::vector<T>& top_dimensional_cells) {
608  this->setup_bitmap_based_on_top_dimensional_cells_list(sizes_in_following_directions, top_dimensional_cells);
609 }
610 
611 template <typename T>
612 void Bitmap_cubical_complex_base<T>::read_perseus_style_file(const char* perseus_style_file) {
613  bool dbg = false;
614  std::ifstream inFiltration;
615  inFiltration.open(perseus_style_file);
616  unsigned dimensionOfData;
617  inFiltration >> dimensionOfData;
618 
619  if (dbg) {
620  std::cerr << "dimensionOfData : " << dimensionOfData << std::endl;
621  }
622 
623  std::vector<unsigned> sizes;
624  sizes.reserve(dimensionOfData);
625  // all dimensions multiplied
626  std::size_t dimensions = 1;
627  for (std::size_t i = 0; i != dimensionOfData; ++i) {
628  unsigned size_in_this_dimension;
629  inFiltration >> size_in_this_dimension;
630  sizes.push_back(size_in_this_dimension);
631  dimensions *= size_in_this_dimension;
632  if (dbg) {
633  std::cerr << "size_in_this_dimension : " << size_in_this_dimension << std::endl;
634  }
635  }
636  this->set_up_containers(sizes);
637 
640 
641  T filtrationLevel = 0.;
642  std::size_t filtration_counter = 0;
643  while (!inFiltration.eof()) {
644  std::string line;
645  getline(inFiltration, line);
646  if (line.length() != 0) {
647  int n = sscanf(line.c_str(), "%lf", &filtrationLevel);
648  if (n != 1) {
649  std::string perseus_error("Bad Perseus file format. This line is incorrect : " + line);
650  throw std::ios_base::failure(perseus_error.c_str());
651  }
652 
653  if (dbg) {
654  std::cerr << "Cell of an index : " << it.compute_index_in_bitmap()
655  << " and dimension: " << this->get_dimension_of_a_cell(it.compute_index_in_bitmap())
656  << " get the value : " << filtrationLevel << std::endl;
657  }
658  this->get_cell_data(*it) = filtrationLevel;
659  ++it;
660  ++filtration_counter;
661  }
662  }
663 
664  if (filtration_counter != dimensions) {
665  std::string perseus_error("Bad Perseus file format. Read " + std::to_string(filtration_counter) + " expected " + \
666  std::to_string(dimensions) + " values");
667  throw std::ios_base::failure(perseus_error.c_str());
668  }
669 
670  inFiltration.close();
672 }
673 
674 template <typename T>
676  std::vector<bool> directions) {
677  // this constructor is here just for compatibility with a class that creates cubical complexes with periodic boundary
678  // conditions.
679  // It ignores the last parameter of the function.
680  this->read_perseus_style_file(perseus_style_file);
681 }
682 
683 template <typename T>
684 Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base(const std::vector<unsigned>& sizes,
685  std::vector<bool> directions) {
686  // this constructor is here just for compatibility with a class that creates cubical complexes with periodic boundary
687  // conditions.
688  // It ignores the last parameter of the function.
689  this->set_up_containers(sizes);
690 }
691 
692 template <typename T>
693 Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base(const std::vector<unsigned>& dimensions,
694  const std::vector<T>& top_dimensional_cells,
695  std::vector<bool> directions) {
696  // this constructor is here just for compatibility with a class that creates cubical complexes with periodic boundary
697  // conditions.
698  // It ignores the last parameter of the function.
699  this->setup_bitmap_based_on_top_dimensional_cells_list(dimensions, top_dimensional_cells);
700 }
701 
702 template <typename T>
704  this->read_perseus_style_file(perseus_style_file);
705 }
706 
707 template <typename T>
708 std::vector<std::size_t> Bitmap_cubical_complex_base<T>::get_boundary_of_a_cell(std::size_t cell) const {
709  std::vector<std::size_t> boundary_elements;
710 
711  // Speed traded of for memory. Check if it is better in practice.
712  boundary_elements.reserve(this->dimension() * 2);
713 
714  std::size_t sum_of_dimensions = 0;
715  std::size_t cell1 = cell;
716  for (std::size_t i = this->multipliers.size(); i != 0; --i) {
717  unsigned position = cell1 / this->multipliers[i - 1];
718  if (position % 2 == 1) {
719  if (sum_of_dimensions % 2) {
720  boundary_elements.push_back(cell + this->multipliers[i - 1]);
721  boundary_elements.push_back(cell - this->multipliers[i - 1]);
722  } else {
723  boundary_elements.push_back(cell - this->multipliers[i - 1]);
724  boundary_elements.push_back(cell + this->multipliers[i - 1]);
725  }
726  ++sum_of_dimensions;
727  }
728  cell1 = cell1 % this->multipliers[i - 1];
729  }
730 
731  return boundary_elements;
732 }
733 
734 template <typename T>
735 std::vector<std::size_t> Bitmap_cubical_complex_base<T>::get_coboundary_of_a_cell(std::size_t cell) const {
736  std::vector<unsigned> counter = this->compute_counter_for_given_cell(cell);
737  std::vector<std::size_t> coboundary_elements;
738  std::size_t cell1 = cell;
739  for (std::size_t i = this->multipliers.size(); i != 0; --i) {
740  unsigned position = cell1 / this->multipliers[i - 1];
741  if (position % 2 == 0) {
742  if ((cell > this->multipliers[i - 1]) && (counter[i - 1] != 0)) {
743  coboundary_elements.push_back(cell - this->multipliers[i - 1]);
744  }
745  if ((cell + this->multipliers[i - 1] < this->data.size()) && (counter[i - 1] != 2 * this->sizes[i - 1])) {
746  coboundary_elements.push_back(cell + this->multipliers[i - 1]);
747  }
748  }
749  cell1 = cell1 % this->multipliers[i - 1];
750  }
751  return coboundary_elements;
752 }
753 
754 template <typename T>
756  bool dbg = false;
757  if (dbg) std::cerr << "\n\n\n Computing position o a cell of an index : " << cell << std::endl;
758  unsigned dimension = 0;
759  for (std::size_t i = this->multipliers.size(); i != 0; --i) {
760  unsigned position = cell / this->multipliers[i - 1];
761 
762  if (dbg) {
763  std::cerr << "i-1 :" << i - 1 << std::endl;
764  std::cerr << "cell : " << cell << std::endl;
765  std::cerr << "position : " << position << std::endl;
766  std::cerr << "multipliers[" << i - 1 << "] = " << this->multipliers[i - 1] << std::endl;
767  }
768 
769  if (position % 2 == 1) {
770  if (dbg) std::cerr << "Nonzero length in this direction \n";
771  dimension++;
772  }
773  cell = cell % this->multipliers[i - 1];
774  }
775  return dimension;
776 }
777 
778 template <typename T>
780  return this->data[cell];
781 }
782 
783 template <typename T>
785  bool dbg = false;
786 
787  // this vector will be used to check which elements have already been taken care of in imposing lower star filtration
788  std::vector<bool> is_this_cell_considered(this->data.size(), false);
789 
790  std::size_t size_to_reserve = 1;
791  for (std::size_t i = 0; i != this->multipliers.size(); ++i) {
792  size_to_reserve *= (std::size_t)((this->multipliers[i] - 1) / 2);
793  }
794 
795  std::vector<std::size_t> indices_to_consider;
796  indices_to_consider.reserve(size_to_reserve);
797  // we assume here that we already have a filtration on the top dimensional cells and
798  // we have to extend it to lower ones.
800  for (it = this->top_dimensional_cells_iterator_begin(); it != this->top_dimensional_cells_iterator_end(); ++it) {
801  indices_to_consider.push_back(it.compute_index_in_bitmap());
802  }
803 
804  while (indices_to_consider.size()) {
805  if (dbg) {
806  std::cerr << "indices_to_consider in this iteration \n";
807  for (std::size_t i = 0; i != indices_to_consider.size(); ++i) {
808  std::cout << indices_to_consider[i] << " ";
809  }
810  }
811  std::vector<std::size_t> new_indices_to_consider;
812  for (std::size_t i = 0; i != indices_to_consider.size(); ++i) {
813  std::vector<std::size_t> bd = this->get_boundary_of_a_cell(indices_to_consider[i]);
814  for (std::size_t boundaryIt = 0; boundaryIt != bd.size(); ++boundaryIt) {
815  if (dbg) {
816  std::cerr << "filtration of a cell : " << bd[boundaryIt] << " is : " << this->data[bd[boundaryIt]]
817  << " while of a cell: " << indices_to_consider[i] << " is: " << this->data[indices_to_consider[i]]
818  << std::endl;
819  }
820  if (this->data[bd[boundaryIt]] > this->data[indices_to_consider[i]]) {
821  this->data[bd[boundaryIt]] = this->data[indices_to_consider[i]];
822  if (dbg) {
823  std::cerr << "Setting the value of a cell : " << bd[boundaryIt]
824  << " to : " << this->data[indices_to_consider[i]] << std::endl;
825  }
826  }
827  if (is_this_cell_considered[bd[boundaryIt]] == false) {
828  new_indices_to_consider.push_back(bd[boundaryIt]);
829  is_this_cell_considered[bd[boundaryIt]] = true;
830  }
831  }
832  }
833  indices_to_consider.swap(new_indices_to_consider);
834  }
835 }
836 
837 template <typename T>
838 bool compareFirstElementsOfTuples(const std::pair<std::pair<T, std::size_t>, char>& first,
839  const std::pair<std::pair<T, std::size_t>, char>& second) {
840  if (first.first.first < second.first.first) {
841  return true;
842  } else {
843  if (first.first.first > second.first.first) {
844  return false;
845  }
846  // in this case first.first.first == second.first.first, so we need to compare dimensions
847  return first.second < second.second;
848  }
849 }
850 
851 } // namespace cubical_complex
852 
853 namespace Cubical_complex = cubical_complex;
854 
855 } // namespace Gudhi
856 
857 #endif // BITMAP_CUBICAL_COMPLEX_BASE_H_
void impose_lower_star_filtration()
Definition: Bitmap_cubical_complex_base.h:784
unsigned size() const
Definition: Bitmap_cubical_complex_base.h:200
unsigned dimension() const
Definition: Bitmap_cubical_complex_base.h:195
void put_data_to_bins(std::size_t number_of_bins)
Definition: Bitmap_cubical_complex_base.h:515
T & get_cell_data(std::size_t cell)
Definition: Bitmap_cubical_complex_base.h:779
Boundary_range boundary_range(std::size_t sh)
Definition: Bitmap_cubical_complex_base.h:328
Cubical complex represented as a bitmap, class with basic implementation.
Definition: Bitmap_cubical_complex_base.h:51
virtual ~Bitmap_cubical_complex_base()
Definition: Bitmap_cubical_complex_base.h:82
unsigned get_dimension_of_a_cell(std::size_t cell) const
Definition: Bitmap_cubical_complex_base.h:755
All_cells_iterator all_cells_iterator_begin()
Definition: Bitmap_cubical_complex_base.h:287
Definition: SimplicialComplexForAlpha.h:14
virtual int compute_incidence_between_cells(std::size_t coface, std::size_t face) const
Definition: Bitmap_cubical_complex_base.h:131
This is an implementation of a counter being a vector of integers.
Definition: counter.h:32
Bitmap_cubical_complex_base()
Definition: Bitmap_cubical_complex_base.h:58
Top_dimensional_cells_iterator top_dimensional_cells_iterator_end()
Definition: Bitmap_cubical_complex_base.h:432
Top_dimensional_cells_iterator top_dimensional_cells_iterator_begin()
Definition: Bitmap_cubical_complex_base.h:424
Top_dimensional_cells_iterator_range class provides ranges for Top_dimensional_cells_iterator_range.
Definition: Bitmap_cubical_complex_base.h:444
Coboundary_range coboundary_range(std::size_t sh)
Definition: Bitmap_cubical_complex_base.h:340
All_cells_iterator all_cells_iterator_end()
Definition: Bitmap_cubical_complex_base.h:295
std::vector< std::size_t >::const_iterator Coboundary_iterator
Definition: Bitmap_cubical_complex_base.h:333
Iterator through all cells in the complex (in order they appear in the structure – i...
Definition: Bitmap_cubical_complex_base.h:242
std::pair< T, T > min_max_filtration()
Definition: Bitmap_cubical_complex_base.h:552
All_cells_range class provides ranges for All_cells_iterator.
Definition: Bitmap_cubical_complex_base.h:304
std::vector< std::size_t >::const_iterator Boundary_iterator
Definition: Bitmap_cubical_complex_base.h:321
virtual std::vector< std::size_t > get_coboundary_of_a_cell(std::size_t cell) const
Definition: Bitmap_cubical_complex_base.h:735
Iterator through top dimensional cells of the complex. The cells appear in order they are stored in t...
Definition: Bitmap_cubical_complex_base.h:346
virtual std::vector< std::size_t > get_boundary_of_a_cell(std::size_t cell) const
Definition: Bitmap_cubical_complex_base.h:708
GUDHI  Version 3.1.1  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : MIT Generated on Fri Feb 7 2020 16:35:36 for GUDHI by Doxygen 1.8.13