summaryrefslogtreecommitdiff
path: root/src/Persistence_representations/include/gudhi/Persistence_landscape_on_grid.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Persistence_representations/include/gudhi/Persistence_landscape_on_grid.h')
-rw-r--r--src/Persistence_representations/include/gudhi/Persistence_landscape_on_grid.h122
1 files changed, 61 insertions, 61 deletions
diff --git a/src/Persistence_representations/include/gudhi/Persistence_landscape_on_grid.h b/src/Persistence_representations/include/gudhi/Persistence_landscape_on_grid.h
index 68bce336..537131da 100644
--- a/src/Persistence_representations/include/gudhi/Persistence_landscape_on_grid.h
+++ b/src/Persistence_representations/include/gudhi/Persistence_landscape_on_grid.h
@@ -155,9 +155,9 @@ class Persistence_landscape_on_grid {
double dx = (this->grid_max - this->grid_min) / static_cast<double>(this->values_of_landscapes.size() - 1);
if (dbg) {
- std::cerr << "this->grid_max : " << this->grid_max << std::endl;
- std::cerr << "this->grid_min : " << this->grid_min << std::endl;
- std::cerr << "this->values_of_landscapes.size() : " << this->values_of_landscapes.size() << std::endl;
+ std::clog << "this->grid_max : " << this->grid_max << std::endl;
+ std::clog << "this->grid_min : " << this->grid_min << std::endl;
+ std::clog << "this->values_of_landscapes.size() : " << this->values_of_landscapes.size() << std::endl;
getchar();
}
@@ -169,14 +169,14 @@ class Persistence_landscape_on_grid {
if (this->values_of_landscapes[i].size() > level) current_y = this->values_of_landscapes[i][level];
if (dbg) {
- std::cerr << "this->values_of_landscapes[i].size() : " << this->values_of_landscapes[i].size()
+ std::clog << "this->values_of_landscapes[i].size() : " << this->values_of_landscapes[i].size()
<< " , level : " << level << std::endl;
if (this->values_of_landscapes[i].size() > level)
- std::cerr << "this->values_of_landscapes[i][level] : " << this->values_of_landscapes[i][level] << std::endl;
- std::cerr << "previous_y : " << previous_y << std::endl;
- std::cerr << "current_y : " << current_y << std::endl;
- std::cerr << "dx : " << dx << std::endl;
- std::cerr << "0.5*dx*( previous_y + current_y ); " << 0.5 * dx * (previous_y + current_y) << std::endl;
+ std::clog << "this->values_of_landscapes[i][level] : " << this->values_of_landscapes[i][level] << std::endl;
+ std::clog << "previous_y : " << previous_y << std::endl;
+ std::clog << "current_y : " << current_y << std::endl;
+ std::clog << "dx : " << dx << std::endl;
+ std::clog << "0.5*dx*( previous_y + current_y ); " << 0.5 * dx * (previous_y + current_y) << std::endl;
}
result += 0.5 * dx * (previous_y + current_y);
@@ -213,10 +213,10 @@ class Persistence_landscape_on_grid {
if (this->values_of_landscapes[0].size() > level) previous_y = this->values_of_landscapes[0][level];
if (dbg) {
- std::cerr << "dx : " << dx << std::endl;
- std::cerr << "previous_x : " << previous_x << std::endl;
- std::cerr << "previous_y : " << previous_y << std::endl;
- std::cerr << "power : " << p << std::endl;
+ std::clog << "dx : " << dx << std::endl;
+ std::clog << "previous_x : " << previous_x << std::endl;
+ std::clog << "previous_y : " << previous_y << std::endl;
+ std::clog << "power : " << p << std::endl;
getchar();
}
@@ -225,7 +225,7 @@ class Persistence_landscape_on_grid {
double current_y = 0;
if (this->values_of_landscapes[i].size() > level) current_y = this->values_of_landscapes[i][level];
- if (dbg) std::cerr << "current_y : " << current_y << std::endl;
+ if (dbg) std::clog << "current_y : " << current_y << std::endl;
if (current_y == previous_y) continue;
@@ -235,7 +235,7 @@ class Persistence_landscape_on_grid {
double b = coef.second;
if (dbg) {
- std::cerr << "A line passing through points : (" << previous_x << "," << previous_y << ") and (" << current_x
+ std::clog << "A line passing through points : (" << previous_x << "," << previous_y << ") and (" << current_x
<< "," << current_y << ") is : " << a << "x+" << b << std::endl;
}
@@ -249,14 +249,14 @@ class Persistence_landscape_on_grid {
}
result += value_to_add;
if (dbg) {
- std::cerr << "Increasing result by : " << value_to_add << std::endl;
- std::cerr << "result : " << result << std::endl;
+ std::clog << "Increasing result by : " << value_to_add << std::endl;
+ std::clog << "result : " << result << std::endl;
getchar();
}
previous_x = current_x;
previous_y = current_y;
}
- if (dbg) std::cerr << "The total result is : " << result << std::endl;
+ if (dbg) std::clog << "The total result is : " << result << std::endl;
return result;
}
@@ -297,10 +297,10 @@ class Persistence_landscape_on_grid {
size_t position = size_t((x - this->grid_min) / dx);
if (dbg) {
- std::cerr << "This is a procedure compute_value_at_a_given_point \n";
- std::cerr << "level : " << level << std::endl;
- std::cerr << "x : " << x << std::endl;
- std::cerr << "position : " << position << std::endl;
+ std::clog << "This is a procedure compute_value_at_a_given_point \n";
+ std::clog << "level : " << level << std::endl;
+ std::clog << "x : " << x << std::endl;
+ std::clog << "position : " << position << std::endl;
}
// check if we are not exactly in the grid point:
if (almost_equal(position * dx + this->grid_min, x)) {
@@ -432,23 +432,23 @@ class Persistence_landscape_on_grid {
bool operator==(const Persistence_landscape_on_grid& rhs) const {
bool dbg = true;
if (this->values_of_landscapes.size() != rhs.values_of_landscapes.size()) {
- if (dbg) std::cerr << "values_of_landscapes of incompatible sizes\n";
+ if (dbg) std::clog << "values_of_landscapes of incompatible sizes\n";
return false;
}
if (!almost_equal(this->grid_min, rhs.grid_min)) {
- if (dbg) std::cerr << "grid_min not equal\n";
+ if (dbg) std::clog << "grid_min not equal\n";
return false;
}
if (!almost_equal(this->grid_max, rhs.grid_max)) {
- if (dbg) std::cerr << "grid_max not equal\n";
+ if (dbg) std::clog << "grid_max not equal\n";
return false;
}
for (size_t i = 0; i != this->values_of_landscapes.size(); ++i) {
for (size_t aa = 0; aa != this->values_of_landscapes[i].size(); ++aa) {
if (!almost_equal(this->values_of_landscapes[i][aa], rhs.values_of_landscapes[i][aa])) {
if (dbg) {
- std::cerr << "Problem in the position : " << i << " of values_of_landscapes. \n";
- std::cerr << this->values_of_landscapes[i][aa] << " " << rhs.values_of_landscapes[i][aa] << std::endl;
+ std::clog << "Problem in the position : " << i << " of values_of_landscapes. \n";
+ std::clog << this->values_of_landscapes[i][aa] << " " << rhs.values_of_landscapes[i][aa] << std::endl;
}
return false;
}
@@ -615,7 +615,7 @@ class Persistence_landscape_on_grid {
double previous_y_l1 = 0;
double previous_y_l2 = 0;
for (size_t i = 0; i != l1.values_of_landscapes.size(); ++i) {
- if (dbg) std::cerr << "i : " << i << std::endl;
+ if (dbg) std::clog << "i : " << i << std::endl;
double current_x = previous_x + dx;
double current_y_l1 = 0;
@@ -625,11 +625,11 @@ class Persistence_landscape_on_grid {
if (l2.values_of_landscapes[i].size() > level) current_y_l2 = l2.values_of_landscapes[i][level];
if (dbg) {
- std::cerr << "previous_x : " << previous_x << std::endl;
- std::cerr << "previous_y_l1 : " << previous_y_l1 << std::endl;
- std::cerr << "current_y_l1 : " << current_y_l1 << std::endl;
- std::cerr << "previous_y_l2 : " << previous_y_l2 << std::endl;
- std::cerr << "current_y_l2 : " << current_y_l2 << std::endl;
+ std::clog << "previous_x : " << previous_x << std::endl;
+ std::clog << "previous_y_l1 : " << previous_y_l1 << std::endl;
+ std::clog << "current_y_l1 : " << current_y_l1 << std::endl;
+ std::clog << "previous_y_l2 : " << previous_y_l2 << std::endl;
+ std::clog << "current_y_l2 : " << current_y_l2 << std::endl;
}
std::pair<double, double> l1_coords = compute_parameters_of_a_line(std::make_pair(previous_x, previous_y_l1),
@@ -646,11 +646,11 @@ class Persistence_landscape_on_grid {
double d = l2_coords.second;
if (dbg) {
- std::cerr << "Here are the formulas for a line: \n";
- std::cerr << "a : " << a << std::endl;
- std::cerr << "b : " << b << std::endl;
- std::cerr << "c : " << c << std::endl;
- std::cerr << "d : " << d << std::endl;
+ std::clog << "Here are the formulas for a line: \n";
+ std::clog << "a : " << a << std::endl;
+ std::clog << "b : " << b << std::endl;
+ std::clog << "c : " << c << std::endl;
+ std::clog << "d : " << d << std::endl;
}
// now, to compute the inner product in this interval we need to compute the integral of (ax+b)(cx+d) = acx^2 +
@@ -663,11 +663,11 @@ class Persistence_landscape_on_grid {
(a * d + b * c) / 2 * previous_x * previous_x + b * d * previous_x);
if (dbg) {
- std::cerr << "Value of the integral on the left end i.e. : " << previous_x << " is : "
+ std::clog << "Value of the integral on the left end i.e. : " << previous_x << " is : "
<< a * c / 3 * previous_x * previous_x * previous_x + (a * d + b * c) / 2 * previous_x * previous_x +
b * d * previous_x
<< std::endl;
- std::cerr << "Value of the integral on the right end i.e. : " << current_x << " is "
+ std::clog << "Value of the integral on the right end i.e. : " << current_x << " is "
<< a * c / 3 * current_x * current_x * current_x + (a * d + b * c) / 2 * current_x * current_x +
b * d * current_x
<< std::endl;
@@ -676,8 +676,8 @@ class Persistence_landscape_on_grid {
result += added_value;
if (dbg) {
- std::cerr << "added_value : " << added_value << std::endl;
- std::cerr << "result : " << result << std::endl;
+ std::clog << "added_value : " << added_value << std::endl;
+ std::clog << "result : " << result << std::endl;
getchar();
}
@@ -703,8 +703,8 @@ class Persistence_landscape_on_grid {
// time:
if (dbg) {
- std::cerr << "first : " << first << std::endl;
- std::cerr << "second : " << second << std::endl;
+ std::clog << "first : " << first << std::endl;
+ std::clog << "second : " << second << std::endl;
getchar();
}
@@ -712,14 +712,14 @@ class Persistence_landscape_on_grid {
Persistence_landscape_on_grid lan = first - second;
if (dbg) {
- std::cerr << "Difference : " << lan << std::endl;
+ std::clog << "Difference : " << lan << std::endl;
}
//| first-second |:
lan.abs();
if (dbg) {
- std::cerr << "Abs : " << lan << std::endl;
+ std::clog << "Abs : " << lan << std::endl;
}
if (p < std::numeric_limits<double>::max()) {
@@ -727,18 +727,18 @@ class Persistence_landscape_on_grid {
double result;
if (p != 1) {
if (dbg) {
- std::cerr << "p : " << p << std::endl;
+ std::clog << "p : " << p << std::endl;
getchar();
}
result = lan.compute_integral_of_landscape(p);
if (dbg) {
- std::cerr << "integral : " << result << std::endl;
+ std::clog << "integral : " << result << std::endl;
getchar();
}
} else {
result = lan.compute_integral_of_landscape();
if (dbg) {
- std::cerr << "integral, without power : " << result << std::endl;
+ std::clog << "integral, without power : " << result << std::endl;
getchar();
}
}
@@ -820,7 +820,7 @@ class Persistence_landscape_on_grid {
this->grid_max = (to_average[0])->grid_max;
if (dbg) {
- std::cerr << "Computations of average. The data from the current landscape have been cleared. We are ready to do "
+ std::clog << "Computations of average. The data from the current landscape have been cleared. We are ready to do "
"the computations. \n";
}
@@ -835,7 +835,7 @@ class Persistence_landscape_on_grid {
this->values_of_landscapes[grid_point] = std::vector<double>(maximal_size_of_vector);
if (dbg) {
- std::cerr << "We are considering the point : " << grid_point
+ std::clog << "We are considering the point : " << grid_point
<< " of the grid. In this point, there are at most : " << maximal_size_of_vector
<< " nonzero landscape functions \n";
}
@@ -931,12 +931,12 @@ void Persistence_landscape_on_grid::set_up_values_of_landscapes(const std::vecto
size_t number_of_points_, unsigned number_of_levels) {
bool dbg = false;
if (dbg) {
- std::cerr << "Here is the procedure : set_up_values_of_landscapes. The parameters are : grid_min_ : " << grid_min_
+ std::clog << "Here is the procedure : set_up_values_of_landscapes. The parameters are : grid_min_ : " << grid_min_
<< ", grid_max_ : " << grid_max_ << ", number_of_points_ : " << number_of_points_
<< ", number_of_levels: " << number_of_levels << std::endl;
- std::cerr << "Here are the intervals at our disposal : \n";
+ std::clog << "Here are the intervals at our disposal : \n";
for (size_t i = 0; i != p.size(); ++i) {
- std::cerr << p[i].first << " , " << p[i].second << std::endl;
+ std::clog << p[i].first << " , " << p[i].second << std::endl;
}
}
@@ -976,17 +976,17 @@ void Persistence_landscape_on_grid::set_up_values_of_landscapes(const std::vecto
size_t grid_interval_midpoint = (size_t)(0.5 * (grid_interval_begin + grid_interval_end));
if (dbg) {
- std::cerr << "Considering an interval : " << p[int_no].first << "," << p[int_no].second << std::endl;
+ std::clog << "Considering an interval : " << p[int_no].first << "," << p[int_no].second << std::endl;
- std::cerr << "grid_interval_begin : " << grid_interval_begin << std::endl;
- std::cerr << "grid_interval_end : " << grid_interval_end << std::endl;
- std::cerr << "grid_interval_midpoint : " << grid_interval_midpoint << std::endl;
+ std::clog << "grid_interval_begin : " << grid_interval_begin << std::endl;
+ std::clog << "grid_interval_end : " << grid_interval_end << std::endl;
+ std::clog << "grid_interval_midpoint : " << grid_interval_midpoint << std::endl;
}
double landscape_value = dx;
for (size_t i = grid_interval_begin + 1; i < grid_interval_midpoint; ++i) {
if (dbg) {
- std::cerr << "Adding landscape value (going up) for a point : " << i << " equal : " << landscape_value
+ std::clog << "Adding landscape value (going up) for a point : " << i << " equal : " << landscape_value
<< std::endl;
}
if (number_of_levels != std::numeric_limits<unsigned>::max()) {
@@ -1044,7 +1044,7 @@ void Persistence_landscape_on_grid::set_up_values_of_landscapes(const std::vecto
}
if (dbg) {
- std::cerr << "Adding landscape value (going down) for a point : " << i << " equal : " << landscape_value
+ std::clog << "Adding landscape value (going down) for a point : " << i << " equal : " << landscape_value
<< std::endl;
}
}
@@ -1246,7 +1246,7 @@ void Persistence_landscape_on_grid::plot(const char* filename, double min_x, dou
}
out << "EOF" << std::endl;
}
- std::cout << "To visualize, install gnuplot and type the command: gnuplot -persist -e \"load \'"
+ std::clog << "To visualize, install gnuplot and type the command: gnuplot -persist -e \"load \'"
<< gnuplot_script.str().c_str() << "\'\"" << std::endl;
}