23 #ifndef COMMON_PERSISTENCE_REPRESENTATIONS_H_ 24 #define COMMON_PERSISTENCE_REPRESENTATIONS_H_ 31 namespace Persistence_representations {
35 double epsi = 0.000005;
42 inline bool almost_equal(
double a,
double b) {
43 if (std::fabs(a - b) < epsi)
return true;
51 double minus_length(std::pair<double, double> a) {
return a.first - a.second; }
52 double birth_plus_deaths(std::pair<double, double> a) {
return a.first + a.second; }
59 std::pair<double, double> compute_parameters_of_a_line(std::pair<double, double> p1, std::pair<double, double> p2) {
60 double a = (p2.second - p1.second) / (p2.first - p1.first);
61 double b = p1.second - a * p1.first;
62 return std::make_pair(a, b);
70 double find_zero_of_a_line_segment_between_those_two_points(std::pair<double, double> p1,
71 std::pair<double, double> p2) {
72 if (p1.first == p2.first)
return p1.first;
73 if (p1.second * p2.second > 0) {
74 std::ostringstream errMessage;
75 errMessage <<
"In function find_zero_of_a_line_segment_between_those_two_points the arguments are: (" << p1.first
76 <<
"," << p1.second <<
") and (" << p2.first <<
"," << p2.second
77 <<
"). There is no zero in line between those two points. Program terminated.";
78 std::string errMessageStr = errMessage.str();
79 const char* err = errMessageStr.c_str();
84 double a = (p2.second - p1.second) / (p2.first - p1.first);
85 double b = p1.second - a * p1.first;
95 bool compare_points_sorting(std::pair<double, double> f, std::pair<double, double> s) {
96 if (f.first < s.first) {
99 if (f.first > s.first) {
102 if (f.second > s.second) {
116 double function_value(std::pair<double, double> p1, std::pair<double, double> p2,
double x) {
119 double a = (p2.second - p1.second) / (p2.first - p1.first);
120 double b = p1.second - a * p1.first;
127 #endif // COMMON_PERSISTENCE_REPRESENTATIONS_H_ Definition: SimplicialComplexForAlpha.h:26