TTK
Loading...
Searching...
No Matches
RipsPersistenceDiagram.cpp
Go to the documentation of this file.
2
3static bool isPrime(int n) {
4 if(n <= 1)
5 return false;
6 for(int d = 2; d * d <= n; ++d) {
7 if(n % d == 0)
8 return false;
9 }
10 return true;
11}
12
14 // inherited from Debug: prefix will be printed at the beginning of every msg
15 this->setDebugMsgPrefix("RipsPersistenceDiagram");
16}
17
19 const rpd::PointCloud &points, rpd::MultidimensionalDiagram &ph) const {
20
21 bool forceRipser = false;
22
24#ifdef TTK_ENABLE_CGAL
25 if(points[0].size() == 2) {
26 rpd::FastRipsPersistenceDiagram2 FRPD(points);
27 FRPD.setDebugLevel(debugLevel_);
28 FRPD.computeRips0And1Persistence(ph, false, false);
29 } else {
30 printWrn("Geometric method only implemented for dim 2.");
31 printWrn("Ripser will be used instead.");
32 forceRipser = true;
33 }
34#else
35 printWrn("TTK was not compiled with CGAL.");
36 printWrn("Ripser will be used instead.");
37 forceRipser = true;
38#endif
39 }
40
41 if(BackEnd == BACKEND::RIPSER || forceRipser) {
42 if(isPrime(FieldOfCoefficients))
46 else {
47 printErr("The chosen p=" + std::to_string(FieldOfCoefficients)
48 + " is not prime");
49 return 1;
50 }
51 }
52
53 return 0;
54}
int debugLevel_
Definition Debug.h:379
int printWrn(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
Definition Debug.h:159
void setDebugMsgPrefix(const std::string &prefix)
Definition Debug.h:364
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
Definition Debug.h:149
int execute(const rpd::PointCloud &points, rpd::MultidimensionalDiagram &ph) const
Main entry point.
void ripser(std::vector< std::vector< value_t > > points, PersistenceType &ph, value_t threshold, index_t dim_max, bool distanceMatrix, bool criticalEdgesOnly=true, bool infinitePairs=true, coefficient_t modulus=2)
Definition ripser.cpp:1136
std::vector< std::vector< value_t > > PointCloud
std::vector< Diagram > MultidimensionalDiagram