diff options
Diffstat (limited to 'src/Persistence_representations')
48 files changed, 455 insertions, 439 deletions
diff --git a/src/Persistence_representations/example/persistence_heat_maps.cpp b/src/Persistence_representations/example/persistence_heat_maps.cpp index 1bf3a637..9fd6779a 100644 --- a/src/Persistence_representations/example/persistence_heat_maps.cpp +++ b/src/Persistence_representations/example/persistence_heat_maps.cpp @@ -65,7 +65,7 @@ int main(int argc, char** argv) { median.compute_median(vector_of_maps); // to compute L^1 distance between hm1 and hm2: - std::cout << "The L^1 distance is : " << hm1.distance(hm2, 1) << std::endl; + std::clog << "The L^1 distance is : " << hm1.distance(hm2, 1) << std::endl; // to average of hm1 and hm2: std::vector<Persistence_heat_maps*> to_average; @@ -75,15 +75,15 @@ int main(int argc, char** argv) { av.compute_average(to_average); // to compute scalar product of hm1 and hm2: - std::cout << "Scalar product is : " << hm1.compute_scalar_product(hm2) << std::endl; + std::clog << "Scalar product is : " << hm1.compute_scalar_product(hm2) << std::endl; Persistence_heat_maps hm1k(persistence1, Gaussian_function(1.0)); Persistence_heat_maps hm2k(persistence2, Gaussian_function(1.0)); Persistence_heat_maps hm1i(persistence1, Gaussian_function(1.0), 20, 20, 0, 11, 0, 11); Persistence_heat_maps hm2i(persistence2, Gaussian_function(1.0), 20, 20, 0, 11, 0, 11); - std::cout << "Scalar product computed with exact 2D kernel on grid is : " << hm1i.compute_scalar_product(hm2i) + std::clog << "Scalar product computed with exact 2D kernel on grid is : " << hm1i.compute_scalar_product(hm2i) << std::endl; - std::cout << "Scalar product computed with exact 2D kernel is : " << hm1k.compute_scalar_product(hm2k) << std::endl; + std::clog << "Scalar product computed with exact 2D kernel is : " << hm1k.compute_scalar_product(hm2k) << std::endl; return 0; } diff --git a/src/Persistence_representations/example/persistence_intervals.cpp b/src/Persistence_representations/example/persistence_intervals.cpp index c908581c..748b9ae4 100644 --- a/src/Persistence_representations/example/persistence_intervals.cpp +++ b/src/Persistence_representations/example/persistence_intervals.cpp @@ -18,59 +18,59 @@ using Persistence_intervals = Gudhi::Persistence_representations::Persistence_in int main(int argc, char** argv) { if (argc != 2) { - std::cout << "To run this program, please provide the name of a file with persistence diagram \n"; + std::clog << "To run this program, please provide the name of a file with persistence diagram \n"; return 1; } Persistence_intervals p(argv[1]); std::pair<double, double> min_max_ = p.get_x_range(); - std::cout << "Birth-death range : " << min_max_.first << " " << min_max_.second << std::endl; + std::clog << "Birth-death range : " << min_max_.first << " " << min_max_.second << std::endl; std::vector<double> dominant_ten_intervals_length = p.length_of_dominant_intervals(10); - std::cout << "Length of ten dominant intervals : " << std::endl; + std::clog << "Length of ten dominant intervals : " << std::endl; for (size_t i = 0; i != dominant_ten_intervals_length.size(); ++i) { - std::cout << dominant_ten_intervals_length[i] << std::endl; + std::clog << dominant_ten_intervals_length[i] << std::endl; } std::vector<std::pair<double, double> > ten_dominant_intervals = p.dominant_intervals(10); - std::cout << "Here are the dominant intervals : " << std::endl; + std::clog << "Here are the dominant intervals : " << std::endl; for (size_t i = 0; i != ten_dominant_intervals.size(); ++i) { - std::cout << "( " << ten_dominant_intervals[i].first << "," << ten_dominant_intervals[i].second << std::endl; + std::clog << "( " << ten_dominant_intervals[i].first << "," << ten_dominant_intervals[i].second << std::endl; } std::vector<size_t> histogram = p.histogram_of_lengths(10); - std::cout << "Here is the histogram of barcode's length : " << std::endl; + std::clog << "Here is the histogram of barcode's length : " << std::endl; for (size_t i = 0; i != histogram.size(); ++i) { - std::cout << histogram[i] << " "; + std::clog << histogram[i] << " "; } - std::cout << std::endl; + std::clog << std::endl; std::vector<size_t> cumulative_histogram = p.cumulative_histogram_of_lengths(10); - std::cout << "Cumulative histogram : " << std::endl; + std::clog << "Cumulative histogram : " << std::endl; for (size_t i = 0; i != cumulative_histogram.size(); ++i) { - std::cout << cumulative_histogram[i] << " "; + std::clog << cumulative_histogram[i] << " "; } - std::cout << std::endl; + std::clog << std::endl; std::vector<double> char_funct_diag = p.characteristic_function_of_diagram(min_max_.first, min_max_.second); - std::cout << "Characteristic function of diagram : " << std::endl; + std::clog << "Characteristic function of diagram : " << std::endl; for (size_t i = 0; i != char_funct_diag.size(); ++i) { - std::cout << char_funct_diag[i] << " "; + std::clog << char_funct_diag[i] << " "; } - std::cout << std::endl; + std::clog << std::endl; std::vector<double> cumul_char_funct_diag = p.cumulative_characteristic_function_of_diagram(min_max_.first, min_max_.second); - std::cout << "Cumulative characteristic function of diagram : " << std::endl; + std::clog << "Cumulative characteristic function of diagram : " << std::endl; for (size_t i = 0; i != cumul_char_funct_diag.size(); ++i) { - std::cout << cumul_char_funct_diag[i] << " "; + std::clog << cumul_char_funct_diag[i] << " "; } - std::cout << std::endl; + std::clog << std::endl; - std::cout << "Persistence Betti numbers \n"; + std::clog << "Persistence Betti numbers \n"; std::vector<std::pair<double, size_t> > pbns = p.compute_persistent_betti_numbers(); for (size_t i = 0; i != pbns.size(); ++i) { - std::cout << pbns[i].first << " " << pbns[i].second << std::endl; + std::clog << pbns[i].first << " " << pbns[i].second << std::endl; } return 0; diff --git a/src/Persistence_representations/example/persistence_landscape.cpp b/src/Persistence_representations/example/persistence_landscape.cpp index ff18d105..d39ae0b8 100644 --- a/src/Persistence_representations/example/persistence_landscape.cpp +++ b/src/Persistence_representations/example/persistence_landscape.cpp @@ -37,35 +37,35 @@ int main(int argc, char** argv) { Persistence_landscape l2(persistence2); // This is how to compute integral of landscapes: - std::cout << "Integral of the first landscape : " << l1.compute_integral_of_landscape() << std::endl; - std::cout << "Integral of the second landscape : " << l2.compute_integral_of_landscape() << std::endl; + std::clog << "Integral of the first landscape : " << l1.compute_integral_of_landscape() << std::endl; + std::clog << "Integral of the second landscape : " << l2.compute_integral_of_landscape() << std::endl; // And here how to write landscapes to stream: - std::cout << "l1 : " << l1 << std::endl; - std::cout << "l2 : " << l2 << std::endl; + std::clog << "l1 : " << l1 << std::endl; + std::clog << "l2 : " << l2 << std::endl; // Arithmetic operations on landscapes: Persistence_landscape sum = l1 + l2; - std::cout << "sum : " << sum << std::endl; + std::clog << "sum : " << sum << std::endl; // here are the maxima of the functions: - std::cout << "Maximum of l1 : " << l1.compute_maximum() << std::endl; - std::cout << "Maximum of l2 : " << l2.compute_maximum() << std::endl; + std::clog << "Maximum of l1 : " << l1.compute_maximum() << std::endl; + std::clog << "Maximum of l2 : " << l2.compute_maximum() << std::endl; // here are the norms of landscapes: - std::cout << "L^1 Norm of l1 : " << l1.compute_norm_of_landscape(1.) << std::endl; - std::cout << "L^1 Norm of l2 : " << l2.compute_norm_of_landscape(1.) << std::endl; + std::clog << "L^1 Norm of l1 : " << l1.compute_norm_of_landscape(1.) << std::endl; + std::clog << "L^1 Norm of l2 : " << l2.compute_norm_of_landscape(1.) << std::endl; // here is the average of landscapes: Persistence_landscape average; average.compute_average({&l1, &l2}); - std::cout << "average : " << average << std::endl; + std::clog << "average : " << average << std::endl; // here is the distance of landscapes: - std::cout << "Distance : " << l1.distance(l2) << std::endl; + std::clog << "Distance : " << l1.distance(l2) << std::endl; // here is the scalar product of landscapes: - std::cout << "Scalar product : " << l1.compute_scalar_product(l2) << std::endl; + std::clog << "Scalar product : " << l1.compute_scalar_product(l2) << std::endl; // here is how to create a file which is suitable for visualization via gnuplot: average.plot("average_landscape"); diff --git a/src/Persistence_representations/example/persistence_landscape_on_grid.cpp b/src/Persistence_representations/example/persistence_landscape_on_grid.cpp index 16a58e1d..6d58e167 100644 --- a/src/Persistence_representations/example/persistence_landscape_on_grid.cpp +++ b/src/Persistence_representations/example/persistence_landscape_on_grid.cpp @@ -37,31 +37,31 @@ int main(int argc, char** argv) { Persistence_landscape_on_grid l2(persistence2, 0, 11, 20); // This is how to compute integral of landscapes: - std::cout << "Integral of the first landscape : " << l1.compute_integral_of_landscape() << std::endl; - std::cout << "Integral of the second landscape : " << l2.compute_integral_of_landscape() << std::endl; + std::clog << "Integral of the first landscape : " << l1.compute_integral_of_landscape() << std::endl; + std::clog << "Integral of the second landscape : " << l2.compute_integral_of_landscape() << std::endl; // And here how to write landscapes to stream: - std::cout << "l1 : " << l1 << std::endl; - std::cout << "l2 : " << l2 << std::endl; + std::clog << "l1 : " << l1 << std::endl; + std::clog << "l2 : " << l2 << std::endl; // here are the maxima of the functions: - std::cout << "Maximum of l1 : " << l1.compute_maximum() << std::endl; - std::cout << "Maximum of l2 : " << l2.compute_maximum() << std::endl; + std::clog << "Maximum of l1 : " << l1.compute_maximum() << std::endl; + std::clog << "Maximum of l2 : " << l2.compute_maximum() << std::endl; // here are the norms of landscapes: - std::cout << "L^1 Norm of l1 : " << l1.compute_norm_of_landscape(1.) << std::endl; - std::cout << "L^1 Norm of l2 : " << l2.compute_norm_of_landscape(1.) << std::endl; + std::clog << "L^1 Norm of l1 : " << l1.compute_norm_of_landscape(1.) << std::endl; + std::clog << "L^1 Norm of l2 : " << l2.compute_norm_of_landscape(1.) << std::endl; // here is the average of landscapes: Persistence_landscape_on_grid average; average.compute_average({&l1, &l2}); - std::cout << "average : " << average << std::endl; + std::clog << "average : " << average << std::endl; // here is the distance of landscapes: - std::cout << "Distance : " << l1.distance(l2) << std::endl; + std::clog << "Distance : " << l1.distance(l2) << std::endl; // here is the scalar product of landscapes: - std::cout << "Scalar product : " << l1.compute_scalar_product(l2) << std::endl; + std::clog << "Scalar product : " << l1.compute_scalar_product(l2) << std::endl; // here is how to create a file which is suitable for visualization via gnuplot: average.plot("average_landscape"); diff --git a/src/Persistence_representations/example/persistence_vectors.cpp b/src/Persistence_representations/example/persistence_vectors.cpp index b27e52d2..89e2fb83 100644 --- a/src/Persistence_representations/example/persistence_vectors.cpp +++ b/src/Persistence_representations/example/persistence_vectors.cpp @@ -41,19 +41,19 @@ int main(int argc, char** argv) { Vector_distances_in_diagram v2(persistence2, std::numeric_limits<size_t>::max()); // writing to a stream: - std::cout << "v1 : " << v1 << std::endl; - std::cout << "v2 : " << v2 << std::endl; + std::clog << "v1 : " << v1 << std::endl; + std::clog << "v2 : " << v2 << std::endl; // averages: Vector_distances_in_diagram average; average.compute_average({&v1, &v2}); - std::cout << "Average : " << average << std::endl; + std::clog << "Average : " << average << std::endl; // computations of distances: - std::cout << "l^1 distance : " << v1.distance(v2) << std::endl; + std::clog << "l^1 distance : " << v1.distance(v2) << std::endl; // computations of scalar product: - std::cout << "Scalar product of l1 and l2 : " << v1.compute_scalar_product(v2) << std::endl; + std::clog << "Scalar product of l1 and l2 : " << v1.compute_scalar_product(v2) << std::endl; // create a file with a gnuplot script: v1.plot("plot_of_vector_representation"); diff --git a/src/Persistence_representations/example/sliced_wasserstein.cpp b/src/Persistence_representations/example/sliced_wasserstein.cpp index d5414d00..d4e31ebf 100644 --- a/src/Persistence_representations/example/sliced_wasserstein.cpp +++ b/src/Persistence_representations/example/sliced_wasserstein.cpp @@ -38,10 +38,10 @@ int main(int argc, char** argv) { SW swex1(persistence1, 1, -1); SW swex2(persistence2, 1, -1); - std::cout << "Approx SW kernel: " << sw1.compute_scalar_product(sw2) << std::endl; - std::cout << "Exact SW kernel: " << swex1.compute_scalar_product(swex2) << std::endl; - std::cout << "Distance induced by approx SW kernel: " << sw1.distance(sw2) << std::endl; - std::cout << "Distance induced by exact SW kernel: " << swex1.distance(swex2) << std::endl; + std::clog << "Approx SW kernel: " << sw1.compute_scalar_product(sw2) << std::endl; + std::clog << "Exact SW kernel: " << swex1.compute_scalar_product(swex2) << std::endl; + std::clog << "Distance induced by approx SW kernel: " << sw1.distance(sw2) << std::endl; + std::clog << "Distance induced by exact SW kernel: " << swex1.distance(swex2) << std::endl; return 0; } diff --git a/src/Persistence_representations/include/gudhi/Persistence_heat_maps.h b/src/Persistence_representations/include/gudhi/Persistence_heat_maps.h index b1af3503..fab88489 100644 --- a/src/Persistence_representations/include/gudhi/Persistence_heat_maps.h +++ b/src/Persistence_representations/include/gudhi/Persistence_heat_maps.h @@ -55,9 +55,9 @@ std::vector<std::vector<double> > create_Gaussian_filter(size_t pixel_radius, do } if (dbg) { - std::cerr << "Kernel initialize \n"; - std::cerr << "pixel_radius : " << pixel_radius << std::endl; - std::cerr << "kernel.size() : " << kernel.size() << std::endl; + std::clog << "Kernel initialize \n"; + std::clog << "pixel_radius : " << pixel_radius << std::endl; + std::clog << "kernel.size() : " << kernel.size() << std::endl; getchar(); } @@ -79,12 +79,12 @@ std::vector<std::vector<double> > create_Gaussian_filter(size_t pixel_radius, do } if (dbg) { - std::cerr << "Here is the kernel : \n"; + std::clog << "Here is the kernel : \n"; for (size_t i = 0; i != kernel.size(); ++i) { for (size_t j = 0; j != kernel[i].size(); ++j) { - std::cerr << kernel[i][j] << " "; + std::clog << kernel[i][j] << " "; } - std::cerr << std::endl; + std::clog << std::endl; } } return kernel; @@ -290,16 +290,16 @@ class Persistence_heat_maps { bool dbg = false; if (this->heat_map.size() != second.heat_map.size()) { if (dbg) - std::cerr << "this->heat_map.size() : " << this->heat_map.size() + std::clog << "this->heat_map.size() : " << this->heat_map.size() << " \n second.heat_map.size() : " << second.heat_map.size() << std::endl; return false; } if (this->min_ != second.min_) { - if (dbg) std::cerr << "this->min_ : " << this->min_ << ", second.min_ : " << second.min_ << std::endl; + if (dbg) std::clog << "this->min_ : " << this->min_ << ", second.min_ : " << second.min_ << std::endl; return false; } if (this->max_ != second.max_) { - if (dbg) std::cerr << "this->max_ : " << this->max_ << ", second.max_ : " << second.max_ << std::endl; + if (dbg) std::clog << "this->max_ : " << this->max_ << ", second.max_ : " << second.max_ << std::endl; return false; } // in the other case we may assume that the persistence images are defined on the same domain. @@ -322,15 +322,15 @@ class Persistence_heat_maps { bool operator==(const Persistence_heat_maps& rhs) const { bool dbg = false; if (!this->check_if_the_same(rhs)) { - if (dbg) std::cerr << "The domains are not the same \n"; + if (dbg) std::clog << "The domains are not the same \n"; return false; // in this case, the domains are not the same, so the maps cannot be the same. } for (size_t i = 0; i != this->heat_map.size(); ++i) { for (size_t j = 0; j != this->heat_map[i].size(); ++j) { if (!almost_equal(this->heat_map[i][j], rhs.heat_map[i][j])) { if (dbg) { - std::cerr << "this->heat_map[" << i << "][" << j << "] = " << this->heat_map[i][j] << std::endl; - std::cerr << "rhs.heat_map[" << i << "][" << j << "] = " << rhs.heat_map[i][j] << std::endl; + std::clog << "this->heat_map[" << i << "][" << j << "] = " << this->heat_map[i][j] << std::endl; + std::clog << "rhs.heat_map[" << i << "][" << j << "] = " << rhs.heat_map[i][j] << std::endl; } return false; } @@ -586,14 +586,14 @@ void Persistence_heat_maps<Scalling_of_kernels>::construct(const std::vector<std bool erase_below_diagonal, size_t number_of_pixels, double min_, double max_) { bool dbg = false; - if (dbg) std::cerr << "Entering construct procedure \n"; + if (dbg) std::clog << "Entering construct procedure \n"; Scalling_of_kernels f; this->f = f; - if (dbg) std::cerr << "min and max passed to construct() procedure: " << min_ << " " << max_ << std::endl; + if (dbg) std::clog << "min and max passed to construct() procedure: " << min_ << " " << max_ << std::endl; if (min_ == max_) { - if (dbg) std::cerr << "min and max parameters will be determined based on intervals \n"; + if (dbg) std::clog << "min and max parameters will be determined based on intervals \n"; // in this case, we want the program to set up the min_ and max_ values by itself. min_ = std::numeric_limits<int>::max(); max_ = -std::numeric_limits<int>::max(); @@ -611,9 +611,9 @@ void Persistence_heat_maps<Scalling_of_kernels>::construct(const std::vector<std } if (dbg) { - std::cerr << "min_ : " << min_ << std::endl; - std::cerr << "max_ : " << max_ << std::endl; - std::cerr << "number_of_pixels : " << number_of_pixels << std::endl; + std::clog << "min_ : " << min_ << std::endl; + std::clog << "max_ : " << max_ << std::endl; + std::clog << "number_of_pixels : " << number_of_pixels << std::endl; getchar(); } @@ -628,7 +628,7 @@ void Persistence_heat_maps<Scalling_of_kernels>::construct(const std::vector<std } this->heat_map = heat_map_; - if (dbg) std::cerr << "Done creating of the heat map, now we will fill in the structure \n"; + if (dbg) std::clog << "Done creating of the heat map, now we will fill in the structure \n"; for (size_t pt_nr = 0; pt_nr != intervals_.size(); ++pt_nr) { // compute the value of intervals_[pt_nr] in the grid: @@ -638,9 +638,9 @@ void Persistence_heat_maps<Scalling_of_kernels>::construct(const std::vector<std static_cast<int>((intervals_[pt_nr].second - this->min_) / (this->max_ - this->min_) * number_of_pixels); if (dbg) { - std::cerr << "point : " << intervals_[pt_nr].first << " , " << intervals_[pt_nr].second << std::endl; - std::cerr << "x_grid : " << x_grid << std::endl; - std::cerr << "y_grid : " << y_grid << std::endl; + std::clog << "point : " << intervals_[pt_nr].first << " , " << intervals_[pt_nr].second << std::endl; + std::clog << "x_grid : " << x_grid << std::endl; + std::clog << "y_grid : " << y_grid << std::endl; } // x_grid and y_grid gives a center of the kernel. We want to have its lower left corner. To get this, we need to @@ -650,9 +650,9 @@ void Persistence_heat_maps<Scalling_of_kernels>::construct(const std::vector<std // note that the numbers x_grid and y_grid may be negative. if (dbg) { - std::cerr << "After shift : \n"; - std::cerr << "x_grid : " << x_grid << std::endl; - std::cerr << "y_grid : " << y_grid << std::endl; + std::clog << "After shift : \n"; + std::clog << "x_grid : " << x_grid << std::endl; + std::clog << "y_grid : " << y_grid << std::endl; } double scaling_value = this->f(intervals_[pt_nr]); @@ -663,11 +663,11 @@ void Persistence_heat_maps<Scalling_of_kernels>::construct(const std::vector<std if (((x_grid + i) >= 0) && (x_grid + i < this->heat_map.size()) && ((y_grid + j) >= 0) && (y_grid + j < this->heat_map.size())) { if (dbg) { - std::cerr << y_grid + j << " " << x_grid + i << std::endl; + std::clog << y_grid + j << " " << x_grid + i << std::endl; } this->heat_map[y_grid + j][x_grid + i] += scaling_value * filter[i][j]; if (dbg) { - std::cerr << "Position : (" << x_grid + i << "," << y_grid + j + std::clog << "Position : (" << x_grid + i << "," << y_grid + j << ") got increased by the value : " << filter[i][j] << std::endl; } } @@ -805,7 +805,7 @@ void Persistence_heat_maps<Scalling_of_kernels>::plot(const char* filename) cons out << std::endl; } out.close(); - 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; } @@ -842,7 +842,7 @@ void Persistence_heat_maps<Scalling_of_kernels>::load_from_file(const char* file in >> this->min_ >> this->max_; if (dbg) { - std::cerr << "Reading the following values of min and max : " << this->min_ << " , " << this->max_ << std::endl; + std::clog << "Reading the following values of min and max : " << this->min_ << " , " << this->max_ << std::endl; } std::string temp; @@ -859,18 +859,18 @@ void Persistence_heat_maps<Scalling_of_kernels>::load_from_file(const char* file lineSS >> point; line_of_heat_map.push_back(point); if (dbg) { - std::cout << point << " "; + std::clog << point << " "; } } if (dbg) { - std::cout << std::endl; + std::clog << std::endl; getchar(); } if (in.good()) this->heat_map.push_back(line_of_heat_map); } in.close(); - if (dbg) std::cout << "Done \n"; + if (dbg) std::clog << "Done \n"; } // Concretizations of virtual methods: @@ -878,7 +878,7 @@ template <typename Scalling_of_kernels> std::vector<double> Persistence_heat_maps<Scalling_of_kernels>::vectorize(int number_of_function) const { std::vector<double> result; if (!discrete) { - std::cout << "No vectorize method in case of infinite dimensional vectorization" << std::endl; + std::cerr << "No vectorize method in case of infinite dimensional vectorization" << std::endl; return result; } diff --git a/src/Persistence_representations/include/gudhi/Persistence_intervals.h b/src/Persistence_representations/include/gudhi/Persistence_intervals.h index ea4220ea..a6c1d6f0 100644 --- a/src/Persistence_representations/include/gudhi/Persistence_intervals.h +++ b/src/Persistence_representations/include/gudhi/Persistence_intervals.h @@ -185,7 +185,7 @@ class Persistence_intervals { out.close(); - 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; } @@ -293,7 +293,7 @@ std::vector<std::pair<double, double> > Persistence_intervals::dominant_interval for (size_t i = 0; i != std::min(where_to_cut, position_length_vector.size()); ++i) { result.push_back(this->intervals[position_length_vector[i].first]); if (dbg) - std::cerr << "Position : " << position_length_vector[i].first << " length : " << position_length_vector[i].second + std::clog << "Position : " << position_length_vector[i].first << " length : " << position_length_vector[i].second << std::endl; } @@ -303,7 +303,7 @@ std::vector<std::pair<double, double> > Persistence_intervals::dominant_interval std::vector<size_t> Persistence_intervals::histogram_of_lengths(size_t number_of_bins) const { bool dbg = false; - if (dbg) std::cerr << "this->intervals.size() : " << this->intervals.size() << std::endl; + if (dbg) std::clog << "this->intervals.size() : " << this->intervals.size() << std::endl; // first find the length of the longest interval: double lengthOfLongest = 0; for (size_t i = 0; i != this->intervals.size(); ++i) { @@ -313,7 +313,7 @@ std::vector<size_t> Persistence_intervals::histogram_of_lengths(size_t number_of } if (dbg) { - std::cerr << "lengthOfLongest : " << lengthOfLongest << std::endl; + std::clog << "lengthOfLongest : " << lengthOfLongest << std::endl; } // this is a container we will use to store the resulting histogram @@ -330,10 +330,10 @@ std::vector<size_t> Persistence_intervals::histogram_of_lengths(size_t number_of ++result[position]; if (dbg) { - std::cerr << "i : " << i << std::endl; - std::cerr << "Interval : [" << this->intervals[i].first << " , " << this->intervals[i].second << " ] \n"; - std::cerr << "relative_length_of_this_interval : " << relative_length_of_this_interval << std::endl; - std::cerr << "position : " << position << std::endl; + std::clog << "i : " << i << std::endl; + std::clog << "Interval : [" << this->intervals[i].first << " , " << this->intervals[i].second << " ] \n"; + std::clog << "relative_length_of_this_interval : " << relative_length_of_this_interval << std::endl; + std::clog << "position : " << position << std::endl; getchar(); } } @@ -342,7 +342,7 @@ std::vector<size_t> Persistence_intervals::histogram_of_lengths(size_t number_of result.resize(number_of_bins); if (dbg) { - for (size_t i = 0; i != result.size(); ++i) std::cerr << result[i] << std::endl; + for (size_t i = 0; i != result.size(); ++i) std::clog << result[i] << std::endl; } return result; } @@ -368,7 +368,7 @@ std::vector<double> Persistence_intervals::characteristic_function_of_diagram(do for (size_t i = 0; i != this->intervals.size(); ++i) { if (dbg) { - std::cerr << "Interval : " << this->intervals[i].first << " , " << this->intervals[i].second << std::endl; + std::clog << "Interval : " << this->intervals[i].first << " , " << this->intervals[i].second << std::endl; } size_t beginIt = 0; @@ -390,8 +390,8 @@ std::vector<double> Persistence_intervals::characteristic_function_of_diagram(do } if (dbg) { - std::cerr << "beginIt : " << beginIt << std::endl; - std::cerr << "endIt : " << endIt << std::endl; + std::clog << "beginIt : " << beginIt << std::endl; + std::clog << "endIt : " << endIt << std::endl; } for (size_t pos = beginIt; pos != endIt; ++pos) { @@ -399,11 +399,11 @@ std::vector<double> Persistence_intervals::characteristic_function_of_diagram(do (this->intervals[i].second - this->intervals[i].first); } if (dbg) { - std::cerr << "Result at this stage \n"; + std::clog << "Result at this stage \n"; for (size_t aa = 0; aa != result.size(); ++aa) { - std::cerr << result[aa] << " "; + std::clog << result[aa] << " "; } - std::cerr << std::endl; + std::clog << std::endl; } } return result; @@ -455,9 +455,9 @@ inline double compute_euclidean_distance(const std::pair<double, double>& f, con std::vector<double> Persistence_intervals::k_n_n(size_t k, size_t where_to_cut) const { bool dbg = false; if (dbg) { - std::cerr << "Here are the intervals : \n"; + std::clog << "Here are the intervals : \n"; for (size_t i = 0; i != this->intervals.size(); ++i) { - std::cerr << "[ " << this->intervals[i].first << " , " << this->intervals[i].second << "] \n"; + std::clog << "[ " << this->intervals[i].first << " , " << this->intervals[i].second << "] \n"; } getchar(); } @@ -486,12 +486,12 @@ std::vector<double> Persistence_intervals::k_n_n(size_t k, size_t where_to_cut) distances_from_diagonal[i] = distanceToDiagonal; if (dbg) { - std::cerr << "Here are the distances form the point : [" << this->intervals[i].first << " , " + std::clog << "Here are the distances form the point : [" << this->intervals[i].first << " , " << this->intervals[i].second << "] in the diagram \n"; for (size_t aa = 0; aa != distancesFromI.size(); ++aa) { - std::cerr << "To : " << i + aa << " : " << distancesFromI[aa] << " "; + std::clog << "To : " << i + aa << " : " << distancesFromI[aa] << " "; } - std::cerr << std::endl; + std::clog << std::endl; getchar(); } @@ -502,18 +502,18 @@ std::vector<double> Persistence_intervals::k_n_n(size_t k, size_t where_to_cut) } } if (dbg) { - std::cerr << "Here is the distance matrix : \n"; + std::clog << "Here is the distance matrix : \n"; for (size_t i = 0; i != distances.size(); ++i) { for (size_t j = 0; j != distances.size(); ++j) { - std::cerr << distances[i][j] << " "; + std::clog << distances[i][j] << " "; } - std::cerr << std::endl; + std::clog << std::endl; } - std::cerr << std::endl << std::endl << "And here are the distances to the diagonal : " << std::endl; + std::clog << std::endl << std::endl << "And here are the distances to the diagonal : " << std::endl; for (size_t i = 0; i != distances_from_diagonal.size(); ++i) { - std::cerr << distances_from_diagonal[i] << " "; + std::clog << distances_from_diagonal[i] << " "; } - std::cerr << std::endl << std::endl; + std::clog << std::endl << std::endl; getchar(); } @@ -526,13 +526,13 @@ std::vector<double> Persistence_intervals::k_n_n(size_t k, size_t where_to_cut) if (k > distancesFromI.size()) { if (dbg) { - std::cerr << "There are not enough neighbors in your set. We set the result to plus infty \n"; + std::clog << "There are not enough neighbors in your set. We set the result to plus infty \n"; } result.push_back(std::numeric_limits<double>::max()); } else { if (distances_from_diagonal[i] > distancesFromI[k]) { if (dbg) { - std::cerr << "The k-th n.n. is on a diagonal. Therefore we set up a distance to diagonal \n"; + std::clog << "The k-th n.n. is on a diagonal. Therefore we set up a distance to diagonal \n"; } result.push_back(distances_from_diagonal[i]); } else { diff --git a/src/Persistence_representations/include/gudhi/Persistence_landscape.h b/src/Persistence_representations/include/gudhi/Persistence_landscape.h index b819ccb6..ce4065b8 100644 --- a/src/Persistence_representations/include/gudhi/Persistence_landscape.h +++ b/src/Persistence_representations/include/gudhi/Persistence_landscape.h @@ -343,7 +343,7 @@ class Persistence_landscape { bool dbg = false; if (dbg) { - std::cerr << "to_average.size() : " << to_average.size() << std::endl; + std::clog << "to_average.size() : " << to_average.size() << std::endl; } std::vector<Persistence_landscape*> nextLevelMerge(to_average.size()); @@ -357,13 +357,13 @@ class Persistence_landscape { while (nextLevelMerge.size() != 1) { if (dbg) { - std::cerr << "nextLevelMerge.size() : " << nextLevelMerge.size() << std::endl; + std::clog << "nextLevelMerge.size() : " << nextLevelMerge.size() << std::endl; } std::vector<Persistence_landscape*> nextNextLevelMerge; nextNextLevelMerge.reserve(to_average.size()); for (size_t i = 0; i < nextLevelMerge.size(); i = i + 2) { if (dbg) { - std::cerr << "i : " << i << std::endl; + std::clog << "i : " << i << std::endl; } Persistence_landscape* l = new Persistence_landscape; if (i + 1 != nextLevelMerge.size()) { @@ -374,7 +374,7 @@ class Persistence_landscape { nextNextLevelMerge.push_back(l); } if (dbg) { - std::cerr << "After this iteration \n"; + std::clog << "After this iteration \n"; getchar(); } @@ -471,25 +471,25 @@ Persistence_landscape::Persistence_landscape(const char* filename, size_t dimens bool operatorEqualDbg = false; bool Persistence_landscape::operator==(const Persistence_landscape& rhs) const { if (this->land.size() != rhs.land.size()) { - if (operatorEqualDbg) std::cerr << "1\n"; + if (operatorEqualDbg) std::clog << "1\n"; return false; } for (size_t level = 0; level != this->land.size(); ++level) { if (this->land[level].size() != rhs.land[level].size()) { - if (operatorEqualDbg) std::cerr << "this->land[level].size() : " << this->land[level].size() << "\n"; - if (operatorEqualDbg) std::cerr << "rhs.land[level].size() : " << rhs.land[level].size() << "\n"; - if (operatorEqualDbg) std::cerr << "2\n"; + if (operatorEqualDbg) std::clog << "this->land[level].size() : " << this->land[level].size() << "\n"; + if (operatorEqualDbg) std::clog << "rhs.land[level].size() : " << rhs.land[level].size() << "\n"; + if (operatorEqualDbg) std::clog << "2\n"; return false; } for (size_t i = 0; i != this->land[level].size(); ++i) { if (!(almost_equal(this->land[level][i].first, rhs.land[level][i].first) && almost_equal(this->land[level][i].second, rhs.land[level][i].second))) { if (operatorEqualDbg) - std::cerr << "this->land[level][i] : " << this->land[level][i].first << " " << this->land[level][i].second + std::clog << "this->land[level][i] : " << this->land[level][i].first << " " << this->land[level][i].second << "\n"; if (operatorEqualDbg) - std::cerr << "rhs.land[level][i] : " << rhs.land[level][i].first << " " << rhs.land[level][i].second << "\n"; - if (operatorEqualDbg) std::cerr << "3\n"; + std::clog << "rhs.land[level][i] : " << rhs.land[level][i].first << " " << rhs.land[level][i].second << "\n"; + if (operatorEqualDbg) std::clog << "3\n"; return false; } } @@ -507,7 +507,7 @@ void Persistence_landscape::construct_persistence_landscape_from_barcode( const std::vector<std::pair<double, double> >& p, size_t number_of_levels) { bool dbg = false; if (dbg) { - std::cerr << "Persistence_landscape::Persistence_landscape( const std::vector< std::pair< double , double > >& p )" + std::clog << "Persistence_landscape::Persistence_landscape( const std::vector< std::pair< double , double > >& p )" << std::endl; } @@ -517,9 +517,9 @@ void Persistence_landscape::construct_persistence_landscape_from_barcode( std::sort(bars.begin(), bars.end(), compare_points_sorting); if (dbg) { - std::cerr << "Bars : \n"; + std::clog << "Bars : \n"; for (size_t i = 0; i != bars.size(); ++i) { - std::cerr << bars[i].first << " " << bars[i].second << "\n"; + std::clog << bars[i].first << " " << bars[i].second << "\n"; } getchar(); } @@ -534,7 +534,7 @@ void Persistence_landscape::construct_persistence_landscape_from_barcode( while (!characteristicPoints.empty()) { if (dbg) { for (size_t i = 0; i != characteristicPoints.size(); ++i) { - std::cout << "(" << characteristicPoints[i].first << " " << characteristicPoints[i].second << ")\n"; + std::clog << "(" << characteristicPoints[i].first << " " << characteristicPoints[i].second << ")\n"; } std::cin.ignore(); } @@ -545,7 +545,7 @@ void Persistence_landscape::construct_persistence_landscape_from_barcode( lambda_n.push_back(characteristicPoints[0]); if (dbg) { - std::cerr << "1 Adding to lambda_n : (" << -std::numeric_limits<int>::max() << " " << 0 << ") , (" + std::clog << "1 Adding to lambda_n : (" << -std::numeric_limits<int>::max() << " " << 0 << ") , (" << minus_length(characteristicPoints[0]) << " " << 0 << ") , (" << characteristicPoints[0].first << " " << characteristicPoints[0].second << ") \n"; } @@ -562,13 +562,13 @@ void Persistence_landscape::construct_persistence_landscape_from_barcode( (birth_plus_deaths(lambda_n[lambda_n.size() - 1]) - minus_length(characteristicPoints[i])) / 2); lambda_n.push_back(point); if (dbg) { - std::cerr << "2 Adding to lambda_n : (" << point.first << " " << point.second << ")\n"; + std::clog << "2 Adding to lambda_n : (" << point.first << " " << point.second << ")\n"; } if (dbg) { - std::cerr << "characteristicPoints[i+p] : " << characteristicPoints[i + p].first << " " + std::clog << "characteristicPoints[i+p] : " << characteristicPoints[i + p].first << " " << characteristicPoints[i + p].second << "\n"; - std::cerr << "point : " << point.first << " " << point.second << "\n"; + std::clog << "point : " << point.first << " " << point.second << "\n"; getchar(); } @@ -577,7 +577,7 @@ void Persistence_landscape::construct_persistence_landscape_from_barcode( (birth_plus_deaths(point) <= birth_plus_deaths(characteristicPoints[i + p]))) { newCharacteristicPoints.push_back(characteristicPoints[i + p]); if (dbg) { - std::cerr << "3.5 Adding to newCharacteristicPoints : (" << characteristicPoints[i + p].first << " " + std::clog << "3.5 Adding to newCharacteristicPoints : (" << characteristicPoints[i + p].first << " " << characteristicPoints[i + p].second << ")\n"; getchar(); } @@ -586,7 +586,7 @@ void Persistence_landscape::construct_persistence_landscape_from_barcode( newCharacteristicPoints.push_back(point); if (dbg) { - std::cerr << "4 Adding to newCharacteristicPoints : (" << point.first << " " << point.second << ")\n"; + std::clog << "4 Adding to newCharacteristicPoints : (" << point.first << " " << point.second << ")\n"; } while ((i + p < characteristicPoints.size()) && @@ -594,15 +594,15 @@ void Persistence_landscape::construct_persistence_landscape_from_barcode( (birth_plus_deaths(point) >= birth_plus_deaths(characteristicPoints[i + p]))) { newCharacteristicPoints.push_back(characteristicPoints[i + p]); if (dbg) { - std::cerr << "characteristicPoints[i+p] : " << characteristicPoints[i + p].first << " " + std::clog << "characteristicPoints[i+p] : " << characteristicPoints[i + p].first << " " << characteristicPoints[i + p].second << "\n"; - std::cerr << "point : " << point.first << " " << point.second << "\n"; - std::cerr << "characteristicPoints[i+p] birth and death : " << minus_length(characteristicPoints[i + p]) + std::clog << "point : " << point.first << " " << point.second << "\n"; + std::clog << "characteristicPoints[i+p] birth and death : " << minus_length(characteristicPoints[i + p]) << " , " << birth_plus_deaths(characteristicPoints[i + p]) << "\n"; - std::cerr << "point birth and death : " << minus_length(point) << " , " << birth_plus_deaths(point) + std::clog << "point birth and death : " << minus_length(point) << " , " << birth_plus_deaths(point) << "\n"; - std::cerr << "3 Adding to newCharacteristicPoints : (" << characteristicPoints[i + p].first << " " + std::clog << "3 Adding to newCharacteristicPoints : (" << characteristicPoints[i + p].first << " " << characteristicPoints[i + p].second << ")\n"; getchar(); } @@ -613,20 +613,20 @@ void Persistence_landscape::construct_persistence_landscape_from_barcode( lambda_n.push_back(std::make_pair(birth_plus_deaths(lambda_n[lambda_n.size() - 1]), 0)); lambda_n.push_back(std::make_pair(minus_length(characteristicPoints[i]), 0)); if (dbg) { - std::cerr << "5 Adding to lambda_n : (" << birth_plus_deaths(lambda_n[lambda_n.size() - 1]) << " " << 0 + std::clog << "5 Adding to lambda_n : (" << birth_plus_deaths(lambda_n[lambda_n.size() - 1]) << " " << 0 << ")\n"; - std::cerr << "5 Adding to lambda_n : (" << minus_length(characteristicPoints[i]) << " " << 0 << ")\n"; + std::clog << "5 Adding to lambda_n : (" << minus_length(characteristicPoints[i]) << " " << 0 << ")\n"; } } lambda_n.push_back(characteristicPoints[i]); if (dbg) { - std::cerr << "6 Adding to lambda_n : (" << characteristicPoints[i].first << " " + std::clog << "6 Adding to lambda_n : (" << characteristicPoints[i].first << " " << characteristicPoints[i].second << ")\n"; } } else { newCharacteristicPoints.push_back(characteristicPoints[i]); if (dbg) { - std::cerr << "7 Adding to newCharacteristicPoints : (" << characteristicPoints[i].first << " " + std::clog << "7 Adding to newCharacteristicPoints : (" << characteristicPoints[i].first << " " << characteristicPoints[i].second << ")\n"; } } @@ -692,7 +692,7 @@ double Persistence_landscape::compute_integral_of_landscape(double p) const { double result = 0; for (size_t i = 0; i != this->land.size(); ++i) { for (size_t nr = 2; nr != this->land[i].size() - 1; ++nr) { - if (dbg) std::cout << "nr : " << nr << "\n"; + if (dbg) std::clog << "nr : " << nr << "\n"; // In this interval, the landscape has a form f(x) = ax+b. We want to compute integral of (ax+b)^p = 1/a * // (ax+b)^{p+1}/(p+1) std::pair<double, double> coef = compute_parameters_of_a_line(this->land[i][nr], this->land[i][nr - 1]); @@ -700,7 +700,7 @@ double Persistence_landscape::compute_integral_of_landscape(double p) const { double b = coef.second; if (dbg) - std::cout << "(" << this->land[i][nr].first << "," << this->land[i][nr].second << ") , " + std::clog << "(" << this->land[i][nr].first << "," << this->land[i][nr].second << ") , " << this->land[i][nr - 1].first << "," << this->land[i][nr].second << ")" << std::endl; if (this->land[i][nr].first == this->land[i][nr - 1].first) continue; if (a != 0) { @@ -710,8 +710,8 @@ double Persistence_landscape::compute_integral_of_landscape(double p) const { result += (this->land[i][nr].first - this->land[i][nr - 1].first) * (pow(this->land[i][nr].second, p)); } if (dbg) { - std::cout << "a : " << a << " , b : " << b << std::endl; - std::cout << "result : " << result << std::endl; + std::clog << "a : " << a << " , b : " << b << std::endl; + std::clog << "result : " << result << std::endl; } } } @@ -730,31 +730,31 @@ double Persistence_landscape::compute_value_at_a_given_point(unsigned level, dou unsigned coordEnd = this->land[level].size() - 2; if (compute_value_at_a_given_pointDbg) { - std::cerr << "Here \n"; - std::cerr << "x : " << x << "\n"; - std::cerr << "this->land[level][coordBegin].first : " << this->land[level][coordBegin].first << "\n"; - std::cerr << "this->land[level][coordEnd].first : " << this->land[level][coordEnd].first << "\n"; + std::clog << "Here \n"; + std::clog << "x : " << x << "\n"; + std::clog << "this->land[level][coordBegin].first : " << this->land[level][coordBegin].first << "\n"; + std::clog << "this->land[level][coordEnd].first : " << this->land[level][coordEnd].first << "\n"; } // in this case x is outside the support of the landscape, therefore the value of the landscape is 0. if (x <= this->land[level][coordBegin].first) return 0; if (x >= this->land[level][coordEnd].first) return 0; - if (compute_value_at_a_given_pointDbg) std::cerr << "Entering to the while loop \n"; + if (compute_value_at_a_given_pointDbg) std::clog << "Entering to the while loop \n"; while (coordBegin + 1 != coordEnd) { if (compute_value_at_a_given_pointDbg) { - std::cerr << "coordBegin : " << coordBegin << "\n"; - std::cerr << "coordEnd : " << coordEnd << "\n"; - std::cerr << "this->land[level][coordBegin].first : " << this->land[level][coordBegin].first << "\n"; - std::cerr << "this->land[level][coordEnd].first : " << this->land[level][coordEnd].first << "\n"; + std::clog << "coordBegin : " << coordBegin << "\n"; + std::clog << "coordEnd : " << coordEnd << "\n"; + std::clog << "this->land[level][coordBegin].first : " << this->land[level][coordBegin].first << "\n"; + std::clog << "this->land[level][coordEnd].first : " << this->land[level][coordEnd].first << "\n"; } unsigned newCord = (unsigned)floor((coordEnd + coordBegin) / 2.0); if (compute_value_at_a_given_pointDbg) { - std::cerr << "newCord : " << newCord << "\n"; - std::cerr << "this->land[level][newCord].first : " << this->land[level][newCord].first << "\n"; + std::clog << "newCord : " << newCord << "\n"; + std::clog << "this->land[level][newCord].first : " << this->land[level][newCord].first << "\n"; std::cin.ignore(); } @@ -767,12 +767,12 @@ double Persistence_landscape::compute_value_at_a_given_point(unsigned level, dou } if (compute_value_at_a_given_pointDbg) { - std::cout << "x : " << x << " is between : " << this->land[level][coordBegin].first << " a " + std::clog << "x : " << x << " is between : " << this->land[level][coordBegin].first << " a " << this->land[level][coordEnd].first << "\n"; - std::cout << "the y coords are : " << this->land[level][coordBegin].second << " a " + std::clog << "the y coords are : " << this->land[level][coordBegin].second << " a " << this->land[level][coordEnd].second << "\n"; - std::cerr << "coordBegin : " << coordBegin << "\n"; - std::cerr << "coordEnd : " << coordEnd << "\n"; + std::clog << "coordBegin : " << coordBegin << "\n"; + std::clog << "coordEnd : " << coordEnd << "\n"; std::cin.ignore(); } return function_value(this->land[level][coordBegin], this->land[level][coordEnd], x); @@ -810,13 +810,13 @@ Persistence_landscape Persistence_landscape::abs() { Persistence_landscape result; for (size_t level = 0; level != this->land.size(); ++level) { if (AbsDbg) { - std::cout << "level: " << level << std::endl; + std::clog << "level: " << level << std::endl; } std::vector<std::pair<double, double> > lambda_n; lambda_n.push_back(std::make_pair(-std::numeric_limits<int>::max(), 0)); for (size_t i = 1; i != this->land[level].size(); ++i) { if (AbsDbg) { - std::cout << "this->land[" << level << "][" << i << "] : " << this->land[level][i].first << " " + std::clog << "this->land[" << level << "][" << i << "] : " << this->land[level][i].first << " " << this->land[level][i].second << std::endl; } // if a line segment between this->land[level][i-1] and this->land[level][i] crosses the x-axis, then we have to @@ -828,15 +828,15 @@ Persistence_landscape Persistence_landscape::abs() { lambda_n.push_back(std::make_pair(zero, 0)); lambda_n.push_back(std::make_pair(this->land[level][i].first, fabs(this->land[level][i].second))); if (AbsDbg) { - std::cout << "Adding pair : (" << zero << ",0)" << std::endl; - std::cout << "In the same step adding pair : (" << this->land[level][i].first << "," + std::clog << "Adding pair : (" << zero << ",0)" << std::endl; + std::clog << "In the same step adding pair : (" << this->land[level][i].first << "," << fabs(this->land[level][i].second) << ") " << std::endl; std::cin.ignore(); } } else { lambda_n.push_back(std::make_pair(this->land[level][i].first, fabs(this->land[level][i].second))); if (AbsDbg) { - std::cout << "Adding pair : (" << this->land[level][i].first << "," << fabs(this->land[level][i].second) + std::clog << "Adding pair : (" << this->land[level][i].first << "," << fabs(this->land[level][i].second) << ") " << std::endl; std::cin.ignore(); } @@ -851,13 +851,13 @@ Persistence_landscape* Persistence_landscape::new_abs() { Persistence_landscape* result = new Persistence_landscape(*this); for (size_t level = 0; level != this->land.size(); ++level) { if (AbsDbg) { - std::cout << "level: " << level << std::endl; + std::clog << "level: " << level << std::endl; } std::vector<std::pair<double, double> > lambda_n; lambda_n.push_back(std::make_pair(-std::numeric_limits<int>::max(), 0)); for (size_t i = 1; i != this->land[level].size(); ++i) { if (AbsDbg) { - std::cout << "this->land[" << level << "][" << i << "] : " << this->land[level][i].first << " " + std::clog << "this->land[" << level << "][" << i << "] : " << this->land[level][i].first << " " << this->land[level][i].second << std::endl; } // if a line segment between this->land[level][i-1] and this->land[level][i] crosses the x-axis, then we have to @@ -869,15 +869,15 @@ Persistence_landscape* Persistence_landscape::new_abs() { lambda_n.push_back(std::make_pair(zero, 0)); lambda_n.push_back(std::make_pair(this->land[level][i].first, fabs(this->land[level][i].second))); if (AbsDbg) { - std::cout << "Adding pair : (" << zero << ",0)" << std::endl; - std::cout << "In the same step adding pair : (" << this->land[level][i].first << "," + std::clog << "Adding pair : (" << zero << ",0)" << std::endl; + std::clog << "In the same step adding pair : (" << this->land[level][i].first << "," << fabs(this->land[level][i].second) << ") " << std::endl; std::cin.ignore(); } } else { lambda_n.push_back(std::make_pair(this->land[level][i].first, fabs(this->land[level][i].second))); if (AbsDbg) { - std::cout << "Adding pair : (" << this->land[level][i].first << "," << fabs(this->land[level][i].second) + std::clog << "Adding pair : (" << this->land[level][i].first << "," << fabs(this->land[level][i].second) << ") " << std::endl; std::cin.ignore(); } @@ -943,11 +943,11 @@ void Persistence_landscape::load_landscape_from_file(const char* filename) { lineSS >> endd; landscapeAtThisLevel.push_back(std::make_pair(beginn, endd)); if (dbg) { - std::cerr << "Reading a point : " << beginn << " , " << endd << std::endl; + std::clog << "Reading a point : " << beginn << " , " << endd << std::endl; } } else { if (dbg) { - std::cout << "IGNORE LINE\n"; + std::clog << "IGNORE LINE\n"; getchar(); } if (!isThisAFirsLine) { @@ -975,7 +975,7 @@ Persistence_landscape operation_on_pair_of_landscapes(const Persistence_landscap const Persistence_landscape& land2) { bool operation_on_pair_of_landscapesDBG = false; if (operation_on_pair_of_landscapesDBG) { - std::cout << "operation_on_pair_of_landscapes\n"; + std::clog << "operation_on_pair_of_landscapes\n"; std::cin.ignore(); } Persistence_landscape result; @@ -985,8 +985,8 @@ Persistence_landscape operation_on_pair_of_landscapes(const Persistence_landscap if (operation_on_pair_of_landscapesDBG) { for (size_t i = 0; i != std::min(land1.land.size(), land2.land.size()); ++i) { - std::cerr << "land1.land[" << i << "].size() : " << land1.land[i].size() << std::endl; - std::cerr << "land2.land[" << i << "].size() : " << land2.land[i].size() << std::endl; + std::clog << "land1.land[" << i << "].size() : " << land1.land[i].size() << std::endl; + std::clog << "land2.land[" << i << "].size() : " << land2.land[i].size() << std::endl; } getchar(); } @@ -997,20 +997,20 @@ Persistence_landscape operation_on_pair_of_landscapes(const Persistence_landscap size_t q = 0; while ((p + 1 < land1.land[i].size()) && (q + 1 < land2.land[i].size())) { if (operation_on_pair_of_landscapesDBG) { - std::cerr << "p : " << p << "\n"; - std::cerr << "q : " << q << "\n"; - std::cerr << "land1.land.size() : " << land1.land.size() << std::endl; - std::cerr << "land2.land.size() : " << land2.land.size() << std::endl; - std::cerr << "land1.land[" << i << "].size() : " << land1.land[i].size() << std::endl; - std::cerr << "land2.land[" << i << "].size() : " << land2.land[i].size() << std::endl; - std::cout << "land1.land[i][p].first : " << land1.land[i][p].first << "\n"; - std::cout << "land2.land[i][q].first : " << land2.land[i][q].first << "\n"; + std::clog << "p : " << p << "\n"; + std::clog << "q : " << q << "\n"; + std::clog << "land1.land.size() : " << land1.land.size() << std::endl; + std::clog << "land2.land.size() : " << land2.land.size() << std::endl; + std::clog << "land1.land[" << i << "].size() : " << land1.land[i].size() << std::endl; + std::clog << "land2.land[" << i << "].size() : " << land2.land[i].size() << std::endl; + std::clog << "land1.land[i][p].first : " << land1.land[i][p].first << "\n"; + std::clog << "land2.land[i][q].first : " << land2.land[i][q].first << "\n"; } if (land1.land[i][p].first < land2.land[i][q].first) { if (operation_on_pair_of_landscapesDBG) { - std::cout << "first \n"; - std::cout << " function_value(land2.land[i][q-1],land2.land[i][q],land1.land[i][p].first) : " + std::clog << "first \n"; + std::clog << " function_value(land2.land[i][q-1],land2.land[i][q],land1.land[i][p].first) : " << function_value(land2.land[i][q - 1], land2.land[i][q], land1.land[i][p].first) << "\n"; } lambda_n.push_back( @@ -1022,12 +1022,12 @@ Persistence_landscape operation_on_pair_of_landscapes(const Persistence_landscap } if (land1.land[i][p].first > land2.land[i][q].first) { if (operation_on_pair_of_landscapesDBG) { - std::cout << "Second \n"; - std::cout << "function_value(" << land1.land[i][p - 1].first << " " << land1.land[i][p - 1].second << " ," + std::clog << "Second \n"; + std::clog << "function_value(" << land1.land[i][p - 1].first << " " << land1.land[i][p - 1].second << " ," << land1.land[i][p].first << " " << land1.land[i][p].second << ", " << land2.land[i][q].first << " ) : " << function_value(land1.land[i][p - 1], land1.land[i][p - 1], land2.land[i][q].first) << "\n"; - std::cout << "oper( " << function_value(land1.land[i][p], land1.land[i][p - 1], land2.land[i][q].first) << "," + std::clog << "oper( " << function_value(land1.land[i][p], land1.land[i][p - 1], land2.land[i][q].first) << "," << land2.land[i][q].second << " : " << oper(land2.land[i][q].second, function_value(land1.land[i][p], land1.land[i][p - 1], land2.land[i][q].first)) @@ -1040,19 +1040,19 @@ Persistence_landscape operation_on_pair_of_landscapes(const Persistence_landscap continue; } if (land1.land[i][p].first == land2.land[i][q].first) { - if (operation_on_pair_of_landscapesDBG) std::cout << "Third \n"; + if (operation_on_pair_of_landscapesDBG) std::clog << "Third \n"; lambda_n.push_back( std::make_pair(land2.land[i][q].first, oper(land1.land[i][p].second, land2.land[i][q].second))); ++p; ++q; } if (operation_on_pair_of_landscapesDBG) { - std::cout << "Next iteration \n"; + std::clog << "Next iteration \n"; } } while ((p + 1 < land1.land[i].size()) && (q + 1 >= land2.land[i].size())) { if (operation_on_pair_of_landscapesDBG) { - std::cout << "New point : " << land1.land[i][p].first + std::clog << "New point : " << land1.land[i][p].first << " oper(land1.land[i][p].second,0) : " << oper(land1.land[i][p].second, 0) << std::endl; } lambda_n.push_back(std::make_pair(land1.land[i][p].first, oper(land1.land[i][p].second, 0))); @@ -1060,7 +1060,7 @@ Persistence_landscape operation_on_pair_of_landscapes(const Persistence_landscap } while ((p + 1 >= land1.land[i].size()) && (q + 1 < land2.land[i].size())) { if (operation_on_pair_of_landscapesDBG) { - std::cout << "New point : " << land2.land[i][q].first + std::clog << "New point : " << land2.land[i][q].first << " oper(0,land2.land[i][q].second) : " << oper(0, land2.land[i][q].second) << std::endl; } lambda_n.push_back(std::make_pair(land2.land[i][q].first, oper(0, land2.land[i][q].second))); @@ -1073,7 +1073,7 @@ Persistence_landscape operation_on_pair_of_landscapes(const Persistence_landscap } if (land1.land.size() > std::min(land1.land.size(), land2.land.size())) { if (operation_on_pair_of_landscapesDBG) { - std::cout << "land1.land.size() > std::min( land1.land.size() , land2.land.size() )" << std::endl; + std::clog << "land1.land.size() > std::min( land1.land.size() , land2.land.size() )" << std::endl; } for (size_t i = std::min(land1.land.size(), land2.land.size()); i != std::max(land1.land.size(), land2.land.size()); ++i) { @@ -1088,7 +1088,7 @@ Persistence_landscape operation_on_pair_of_landscapes(const Persistence_landscap } if (land2.land.size() > std::min(land1.land.size(), land2.land.size())) { if (operation_on_pair_of_landscapesDBG) { - std::cout << "( land2.land.size() > std::min( land1.land.size() , land2.land.size() ) ) " << std::endl; + std::clog << "( land2.land.size() > std::min( land1.land.size() , land2.land.size() ) ) " << std::endl; } for (size_t i = std::min(land1.land.size(), land2.land.size()); i != std::max(land1.land.size(), land2.land.size()); ++i) { @@ -1102,7 +1102,7 @@ Persistence_landscape operation_on_pair_of_landscapes(const Persistence_landscap } } if (operation_on_pair_of_landscapesDBG) { - std::cout << "operation_on_pair_of_landscapes END\n"; + std::clog << "operation_on_pair_of_landscapes END\n"; std::cin.ignore(); } return result; @@ -1110,20 +1110,20 @@ Persistence_landscape operation_on_pair_of_landscapes(const Persistence_landscap double compute_maximal_distance_non_symmetric(const Persistence_landscape& pl1, const Persistence_landscape& pl2) { bool dbg = false; - if (dbg) std::cerr << " compute_maximal_distance_non_symmetric \n"; + if (dbg) std::clog << " compute_maximal_distance_non_symmetric \n"; // this distance is not symmetric. It compute ONLY distance between inflection points of pl1 and pl2. double maxDist = 0; size_t minimalNumberOfLevels = std::min(pl1.land.size(), pl2.land.size()); for (size_t level = 0; level != minimalNumberOfLevels; ++level) { if (dbg) { - std::cerr << "Level : " << level << std::endl; - std::cerr << "PL1 : \n"; + std::clog << "Level : " << level << std::endl; + std::clog << "PL1 : \n"; for (size_t i = 0; i != pl1.land[level].size(); ++i) { - std::cerr << "(" << pl1.land[level][i].first << "," << pl1.land[level][i].second << ") \n"; + std::clog << "(" << pl1.land[level][i].first << "," << pl1.land[level][i].second << ") \n"; } - std::cerr << "PL2 : \n"; + std::clog << "PL2 : \n"; for (size_t i = 0; i != pl2.land[level].size(); ++i) { - std::cerr << "(" << pl2.land[level][i].first << "," << pl2.land[level][i].second << ") \n"; + std::clog << "(" << pl2.land[level][i].first << "," << pl2.land[level][i].second << ") \n"; } std::cin.ignore(); } @@ -1143,24 +1143,24 @@ double compute_maximal_distance_non_symmetric(const Persistence_landscape& pl1, if (maxDist <= val) maxDist = val; if (dbg) { - std::cerr << pl1.land[level][i].first << "in [" << pl2.land[level][p2Count].first << "," + std::clog << pl1.land[level][i].first << "in [" << pl2.land[level][p2Count].first << "," << pl2.land[level][p2Count + 1].first << "] \n"; - std::cerr << "pl1[level][i].second : " << pl1.land[level][i].second << std::endl; - std::cerr << "function_value( pl2[level][p2Count] , pl2[level][p2Count+1] , pl1[level][i].first ) : " + std::clog << "pl1[level][i].second : " << pl1.land[level][i].second << std::endl; + std::clog << "function_value( pl2[level][p2Count] , pl2[level][p2Count+1] , pl1[level][i].first ) : " << function_value(pl2.land[level][p2Count], pl2.land[level][p2Count + 1], pl1.land[level][i].first) << std::endl; - std::cerr << "val : " << val << std::endl; + std::clog << "val : " << val << std::endl; std::cin.ignore(); } } } - if (dbg) std::cerr << "minimalNumberOfLevels : " << minimalNumberOfLevels << std::endl; + if (dbg) std::clog << "minimalNumberOfLevels : " << minimalNumberOfLevels << std::endl; if (minimalNumberOfLevels < pl1.land.size()) { for (size_t level = minimalNumberOfLevels; level != pl1.land.size(); ++level) { for (size_t i = 0; i != pl1.land[level].size(); ++i) { - if (dbg) std::cerr << "pl1[level][i].second : " << pl1.land[level][i].second << std::endl; + if (dbg) std::clog << "pl1[level][i].second : " << pl1.land[level][i].second << std::endl; if (maxDist < pl1.land[level][i].second) maxDist = pl1.land[level][i].second; } } @@ -1181,7 +1181,7 @@ double compute_distance_of_landscapes(const Persistence_landscape& first, const lan = lan.abs(); if (dbg) { - std::cerr << "Abs of difference ; " << lan << std::endl; + std::clog << "Abs of difference ; " << lan << std::endl; getchar(); } @@ -1189,17 +1189,17 @@ double compute_distance_of_landscapes(const Persistence_landscape& first, const // \int_{- \infty}^{+\infty}| first-second |^p double result; if (p != 1) { - if (dbg) std::cerr << "Power != 1, compute integral to the power p\n"; + if (dbg) std::clog << "Power != 1, compute integral to the power p\n"; result = lan.compute_integral_of_landscape(p); } else { - if (dbg) std::cerr << "Power = 1, compute integral \n"; + if (dbg) std::clog << "Power = 1, compute integral \n"; result = lan.compute_integral_of_landscape(); } // (\int_{- \infty}^{+\infty}| first-second |^p)^(1/p) return pow(result, 1.0 / p); } else { // p == infty - if (dbg) std::cerr << "Power = infty, compute maximum \n"; + if (dbg) std::clog << "Power = infty, compute maximum \n"; return lan.compute_maximum(); } } @@ -1220,7 +1220,7 @@ double compute_inner_product(const Persistence_landscape& l1, const Persistence_ for (size_t level = 0; level != std::min(l1.size(), l2.size()); ++level) { if (dbg) { - std::cerr << "Computing inner product for a level : " << level << std::endl; + std::clog << "Computing inner product for a level : " << level << std::endl; getchar(); } auto&& l1_land_level = l1.land[level]; @@ -1267,14 +1267,14 @@ double compute_inner_product(const Persistence_landscape& l1, const Persistence_ result += contributionFromThisPart; if (dbg) { - std::cerr << "[l1_land_level[l1It].first,l1_land_level[l1It+1].first] : " << l1_land_level[l1It].first + std::clog << "[l1_land_level[l1It].first,l1_land_level[l1It+1].first] : " << l1_land_level[l1It].first << " , " << l1_land_level[l1It + 1].first << std::endl; - std::cerr << "[l2_land_level[l2It].first,l2_land_level[l2It+1].first] : " << l2_land_level[l2It].first + std::clog << "[l2_land_level[l2It].first,l2_land_level[l2It+1].first] : " << l2_land_level[l2It].first << " , " << l2_land_level[l2It + 1].first << std::endl; - std::cerr << "a : " << a << ", b : " << b << " , c: " << c << ", d : " << d << std::endl; - std::cerr << "x1 : " << x1 << " , x2 : " << x2 << std::endl; - std::cerr << "contributionFromThisPart : " << contributionFromThisPart << std::endl; - std::cerr << "result : " << result << std::endl; + std::clog << "a : " << a << ", b : " << b << " , c: " << c << ", d : " << d << std::endl; + std::clog << "x1 : " << x1 << " , x2 : " << x2 << std::endl; + std::clog << "contributionFromThisPart : " << contributionFromThisPart << std::endl; + std::clog << "result : " << result << std::endl; getchar(); } @@ -1290,11 +1290,11 @@ double compute_inner_product(const Persistence_landscape& l1, const Persistence_ // in this case, we increment both: ++l2It; if (dbg) { - std::cerr << "Incrementing both \n"; + std::clog << "Incrementing both \n"; } } else { if (dbg) { - std::cerr << "Incrementing first \n"; + std::clog << "Incrementing first \n"; } } ++l1It; @@ -1302,7 +1302,7 @@ double compute_inner_product(const Persistence_landscape& l1, const Persistence_ // in this case we increment l2It ++l2It; if (dbg) { - std::cerr << "Incrementing second \n"; + std::clog << "Incrementing second \n"; } } @@ -1361,7 +1361,7 @@ void Persistence_landscape::plot(const char* filename, double xRangeBegin, doubl } 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; } 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; } diff --git a/src/Persistence_representations/include/gudhi/Persistence_vectors.h b/src/Persistence_representations/include/gudhi/Persistence_vectors.h index 6776f4a3..fab96900 100644 --- a/src/Persistence_representations/include/gudhi/Persistence_vectors.h +++ b/src/Persistence_representations/include/gudhi/Persistence_vectors.h @@ -189,7 +189,7 @@ class Vector_distances_in_diagram { } out << std::endl; out.close(); - 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; } @@ -360,9 +360,9 @@ template <typename F> void Vector_distances_in_diagram<F>::compute_sorted_vector_of_distances_via_heap(size_t where_to_cut) { bool dbg = false; if (dbg) { - std::cerr << "Here are the intervals : \n"; + std::clog << "Here are the intervals : \n"; for (size_t i = 0; i != this->intervals.size(); ++i) { - std::cerr << this->intervals[i].first << " , " << this->intervals[i].second << std::endl; + std::clog << this->intervals[i].first << " , " << this->intervals[i].second << std::endl; } } where_to_cut = std::min( @@ -385,14 +385,14 @@ void Vector_distances_in_diagram<F>::compute_sorted_vector_of_distances_via_heap 0.5 * (this->intervals[j].first + this->intervals[j].second))))); if (dbg) { - std::cerr << "Value : " << value << std::endl; - std::cerr << "heap.front() : " << heap.front() << std::endl; + std::clog << "Value : " << value << std::endl; + std::clog << "heap.front() : " << heap.front() << std::endl; getchar(); } if (-value < heap.front()) { if (dbg) { - std::cerr << "Replacing : " << heap.front() << " with : " << -value << std::endl; + std::clog << "Replacing : " << heap.front() << " with : " << -value << std::endl; getchar(); } // remove the first element from the heap @@ -431,11 +431,11 @@ void Vector_distances_in_diagram<F>::compute_sorted_vector_of_distances_via_heap } if (dbg) { - std::cerr << "This is the heap after all the operations :\n"; + std::clog << "This is the heap after all the operations :\n"; for (size_t i = 0; i != heap.size(); ++i) { - std::cout << heap[i] << " "; + std::clog << heap[i] << " "; } - std::cout << std::endl; + std::clog << std::endl; } this->sorted_vector_of_distances = heap; @@ -519,11 +519,11 @@ double Vector_distances_in_diagram<F>::distance(const Vector_distances_in_diagra bool dbg = false; if (dbg) { - std::cerr << "Entering double Vector_distances_in_diagram<F>::distance( const Abs_Topological_data_with_distances* " + std::clog << "Entering double Vector_distances_in_diagram<F>::distance( const Abs_Topological_data_with_distances* " "second , double power ) procedure \n"; - std::cerr << "Power : " << power << std::endl; - std::cerr << "This : " << *this << std::endl; - std::cerr << "second : " << second_ << std::endl; + std::clog << "Power : " << power << std::endl; + std::clog << "This : " << *this << std::endl; + std::clog << "second : " << second_ << std::endl; } double result = 0; @@ -531,7 +531,7 @@ double Vector_distances_in_diagram<F>::distance(const Vector_distances_in_diagra ++i) { if (power == 1) { if (dbg) { - std::cerr << "|" << this->sorted_vector_of_distances[i] << " - " << second_.sorted_vector_of_distances[i] + std::clog << "|" << this->sorted_vector_of_distances[i] << " - " << second_.sorted_vector_of_distances[i] << " | : " << fabs(this->sorted_vector_of_distances[i] - second_.sorted_vector_of_distances[i]) << std::endl; } @@ -545,7 +545,7 @@ double Vector_distances_in_diagram<F>::distance(const Vector_distances_in_diagra result = fabs(this->sorted_vector_of_distances[i] - second_.sorted_vector_of_distances[i]); } if (dbg) { - std::cerr << "| " << this->sorted_vector_of_distances[i] << " - " << second_.sorted_vector_of_distances[i] + std::clog << "| " << this->sorted_vector_of_distances[i] << " - " << second_.sorted_vector_of_distances[i] << " : " << fabs(this->sorted_vector_of_distances[i] - second_.sorted_vector_of_distances[i]) << std::endl; } diff --git a/src/Persistence_representations/include/gudhi/read_persistence_from_file.h b/src/Persistence_representations/include/gudhi/read_persistence_from_file.h index 5c2d2038..a5bc1bca 100644 --- a/src/Persistence_representations/include/gudhi/read_persistence_from_file.h +++ b/src/Persistence_representations/include/gudhi/read_persistence_from_file.h @@ -50,28 +50,28 @@ std::vector<std::pair<double, double> > read_persistence_intervals_in_one_dimens final_barcode.reserve(barcode_initial.size()); if (dbg) { - std::cerr << "Here are the intervals that we read from the file : \n"; + std::clog << "Here are the intervals that we read from the file : \n"; for (size_t i = 0; i != barcode_initial.size(); ++i) { - std::cout << barcode_initial[i].first << " " << barcode_initial[i].second << std::endl; + std::clog << barcode_initial[i].first << " " << barcode_initial[i].second << std::endl; } getchar(); } for (size_t i = 0; i != barcode_initial.size(); ++i) { if (dbg) { - std::cout << "COnsidering interval : " << barcode_initial[i].first << " " << barcode_initial[i].second + std::clog << "Considering interval : " << barcode_initial[i].first << " " << barcode_initial[i].second << std::endl; } if (barcode_initial[i].first > barcode_initial[i].second) { // note that in this case barcode_initial[i].second != std::numeric_limits<double>::infinity() - if (dbg) std::cout << "Swap and enter \n"; + if (dbg) std::clog << "Swap and enter \n"; // swap them to make sure that birth < death final_barcode.push_back(std::pair<double, double>(barcode_initial[i].second, barcode_initial[i].first)); continue; } else { if (barcode_initial[i].second != std::numeric_limits<double>::infinity()) { - if (dbg) std::cout << "Simply enters\n"; + if (dbg) std::clog << "Simply enters\n"; // in this case, due to the previous conditions we know that barcode_initial[i].first < // barcode_initial[i].second, so we put them as they are final_barcode.push_back(std::pair<double, double>(barcode_initial[i].first, barcode_initial[i].second)); @@ -91,11 +91,11 @@ std::vector<std::pair<double, double> > read_persistence_intervals_in_one_dimens } if (dbg) { - std::cerr << "Here are the final bars that we are sending further : \n"; + std::clog << "Here are the final bars that we are sending further : \n"; for (size_t i = 0; i != final_barcode.size(); ++i) { - std::cout << final_barcode[i].first << " " << final_barcode[i].second << std::endl; + std::clog << final_barcode[i].first << " " << final_barcode[i].second << std::endl; } - std::cerr << "final_barcode.size() : " << final_barcode.size() << std::endl; + std::clog << "final_barcode.size() : " << final_barcode.size() << std::endl; getchar(); } diff --git a/src/Persistence_representations/utilities/CMakeLists.txt b/src/Persistence_representations/utilities/CMakeLists.txt index fc51b1d6..85633b7b 100644 --- a/src/Persistence_representations/utilities/CMakeLists.txt +++ b/src/Persistence_representations/utilities/CMakeLists.txt @@ -14,7 +14,7 @@ function(add_persistence_representation_creation_utility creation_utility) install(TARGETS ${creation_utility} DESTINATION bin) endfunction(add_persistence_representation_creation_utility) -function(add_persistence_representation_plot_utility plot_utility tool_extension) +function(add_persistence_representation_plot_utility creation_utility plot_utility tool_extension) add_executable ( ${plot_utility} ${plot_utility}.cpp ) # as the function is called in a subdirectory level, need to '../' to find persistence heat maps files @@ -22,17 +22,21 @@ function(add_persistence_representation_plot_utility plot_utility tool_extension "${CMAKE_CURRENT_BINARY_DIR}/../first.pers${tool_extension}") #add_test(NAME Persistence_representation_utilities_${plot_utility}_second COMMAND $<TARGET_FILE:${plot_utility}> # "${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}") + set_tests_properties(Persistence_representation_utilities_${plot_utility}_first PROPERTIES DEPENDS + Persistence_representation_utilities_${creation_utility}) if(GNUPLOT_PATH) add_test(NAME Persistence_representation_utilities_${plot_utility}_first_gnuplot COMMAND ${GNUPLOT_PATH} "-e" "load '${CMAKE_CURRENT_BINARY_DIR}/../first.pers${tool_extension}_GnuplotScript'") #add_test(NAME Persistence_representation_utilities_${plot_utility}_second_gnuplot COMMAND ${GNUPLOT_PATH} # "-e" "load '${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}_GnuplotScript'") + set_tests_properties(Persistence_representation_utilities_${plot_utility}_first_gnuplot PROPERTIES DEPENDS + Persistence_representation_utilities_${plot_utility}_first) endif() install(TARGETS ${plot_utility} DESTINATION bin) endfunction(add_persistence_representation_plot_utility) -function(add_persistence_representation_function_utility function_utility tool_extension) +function(add_persistence_representation_function_utility creation_utility function_utility tool_extension) add_executable ( ${function_utility} ${function_utility}.cpp ) # ARGV2 is an optional argument @@ -48,6 +52,8 @@ function(add_persistence_representation_function_utility function_utility tool_e "${CMAKE_CURRENT_BINARY_DIR}/../first.pers${tool_extension}" "${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}") endif() + set_tests_properties(Persistence_representation_utilities_${function_utility} PROPERTIES DEPENDS + Persistence_representation_utilities_${creation_utility}) install(TARGETS ${function_utility} DESTINATION bin) endfunction(add_persistence_representation_function_utility) diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_heat_maps/CMakeLists.txt index 89ef232f..e4c471c2 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_heat_maps/CMakeLists.txt @@ -2,13 +2,24 @@ project(Persistence_representations_heat_maps_utilities) add_persistence_representation_creation_utility(create_pssk "10" "-1" "-1" "4" "-1") add_persistence_representation_creation_utility(create_p_h_m_weighted_by_arctan_of_their_persistence "10" "-1" "-1" "4" "-1") + add_persistence_representation_creation_utility(create_p_h_m_weighted_by_distance_from_diagonal "10" "-1" "-1" "4" "-1") +# Tests output the same file +set_tests_properties(Persistence_representation_utilities_create_p_h_m_weighted_by_distance_from_diagonal PROPERTIES DEPENDS + Persistence_representation_utilities_create_p_h_m_weighted_by_arctan_of_their_persistence) + add_persistence_representation_creation_utility(create_p_h_m_weighted_by_squared_diag_distance "10" "-1" "-1" "4" "-1") +# Tests output the same file +set_tests_properties(Persistence_representation_utilities_create_p_h_m_weighted_by_squared_diag_distance PROPERTIES DEPENDS + Persistence_representation_utilities_create_p_h_m_weighted_by_distance_from_diagonal) + # Need to set grid min and max for further average, distance and scalar_product add_persistence_representation_creation_utility(create_persistence_heat_maps "10" "0" "35" "10" "-1") +set_tests_properties(Persistence_representation_utilities_create_persistence_heat_maps PROPERTIES DEPENDS + Persistence_representation_utilities_create_p_h_m_weighted_by_squared_diag_distance) -add_persistence_representation_plot_utility(plot_persistence_heat_map ".mps") +add_persistence_representation_plot_utility(create_persistence_heat_maps plot_persistence_heat_map ".mps") -add_persistence_representation_function_utility(average_persistence_heat_maps ".mps") -add_persistence_representation_function_utility(compute_distance_of_persistence_heat_maps ".mps" "1") -add_persistence_representation_function_utility(compute_scalar_product_of_persistence_heat_maps ".mps") +add_persistence_representation_function_utility(create_persistence_heat_maps average_persistence_heat_maps ".mps") +add_persistence_representation_function_utility(create_persistence_heat_maps compute_distance_of_persistence_heat_maps ".mps" "1") +add_persistence_representation_function_utility(create_persistence_heat_maps compute_scalar_product_of_persistence_heat_maps ".mps") diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp index 3d088b58..54b1f77d 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp @@ -17,12 +17,12 @@ using constant_scaling_function = Gudhi::Persistence_representations::constant_s using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps<constant_scaling_function>; int main(int argc, char** argv) { - std::cout << "This program computes average of persistence heat maps stored in files (the files needs to be " + std::clog << "This program computes average of persistence heat maps stored in files (the files needs to be " << "created beforehand).\n" << "The parameters of this programs are names of files with persistence heat maps.\n"; if (argc < 3) { - std::cout << "Wrong number of parameters, the program will now terminate \n"; + std::clog << "Wrong number of parameters, the program will now terminate \n"; return 1; } @@ -46,6 +46,6 @@ int main(int argc, char** argv) { delete maps[i]; } - std::cout << "Average can be found in 'average.mps' file\n"; + std::clog << "Average can be found in 'average.mps' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp index 48000bb1..757a97fc 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp @@ -19,14 +19,14 @@ using constant_scaling_function = Gudhi::Persistence_representations::constant_s using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps<constant_scaling_function>; int main(int argc, char** argv) { - std::cout << "This program computes distance of persistence heat maps stored in files (the files needs to be " + std::clog << "This program computes distance of persistence heat maps stored in files (the files needs to be " << "created beforehand).\n" << "The first parameter of a program is an integer p. The program compute L^p distance of the two heat " << "maps. For L^infty distance choose p = -1. \n" << "The remaining parameters of this program are names of files with persistence heat maps.\n"; if (argc < 3) { - std::cout << "Wrong number of parameters, the program will now terminate \n"; + std::clog << "Wrong number of parameters, the program will now terminate \n"; return 1; } @@ -69,14 +69,14 @@ int main(int argc, char** argv) { out.open("distance.mps"); for (size_t i = 0; i != distance.size(); ++i) { for (size_t j = 0; j != distance.size(); ++j) { - std::cout << distance[i][j] << " "; + std::clog << distance[i][j] << " "; out << distance[i][j] << " "; } - std::cout << std::endl; + std::clog << std::endl; out << std::endl; } out.close(); - std::cout << "Distance can be found in 'distance.mps' file\n"; + std::clog << "Distance can be found in 'distance.mps' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp index 8a96f1b0..e7f18ce1 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp @@ -18,12 +18,12 @@ using constant_scaling_function = Gudhi::Persistence_representations::constant_s using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps<constant_scaling_function>; int main(int argc, char** argv) { - std::cout << "This program computes scalar product of persistence heat maps stored in a file (the file needs to be " + std::clog << "This program computes scalar product of persistence heat maps stored in a file (the file needs to be " << "created beforehand). \n" << "The parameters of this programs are names of files with persistence heat maps.\n"; if (argc < 3) { - std::cout << "Wrong number of parameters, the program will now terminate \n"; + std::clog << "Wrong number of parameters, the program will now terminate \n"; return 1; } @@ -60,14 +60,14 @@ int main(int argc, char** argv) { out.open("scalar_product.mps"); for (size_t i = 0; i != scalar_product.size(); ++i) { for (size_t j = 0; j != scalar_product.size(); ++j) { - std::cout << scalar_product[i][j] << " "; + std::clog << scalar_product[i][j] << " "; out << scalar_product[i][j] << " "; } - std::cout << std::endl; + std::clog << std::endl; out << std::endl; } out.close(); - std::cout << "Distance can be found in 'scalar_product.mps' file\n"; + std::clog << "Distance can be found in 'scalar_product.mps' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_arctan_of_their_persistence.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_arctan_of_their_persistence.cpp index f82a39b0..6b38b930 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_arctan_of_their_persistence.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_arctan_of_their_persistence.cpp @@ -20,7 +20,7 @@ using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps<arc_tan_of_persistence_of_point>; int main(int argc, char** argv) { - std::cout << "This program creates persistence heat map files (*.mps) of persistence diagrams files (*.pers) " + std::clog << "This program creates persistence heat map files (*.mps) of persistence diagrams files (*.pers) " << "provided as an input.The Gaussian kernels are weighted by the arc tangential of their persistence.\n" << "The first parameter of a program is an integer, a size of a grid.\n" << "The second and third parameters are min and max of the grid. If you want those numbers to be computed " @@ -36,7 +36,7 @@ int main(int argc, char** argv) { << "The remaining parameters are the names of files with persistence diagrams. \n"; if (argc < 7) { - std::cout << "Wrong parameter list, the program will now terminate \n"; + std::clog << "Wrong parameter list, the program will now terminate \n"; return 1; } @@ -58,7 +58,7 @@ int main(int argc, char** argv) { std::vector<std::vector<double> > filter = Gudhi::Persistence_representations::create_Gaussian_filter(stdiv, 1); for (size_t i = 0; i != filenames.size(); ++i) { - std::cout << "Creating a heat map based on a file : " << filenames[i] << std::endl; + std::clog << "Creating a heat map based on a file : " << filenames[i] << std::endl; Persistence_heat_maps l(filenames[i], filter, false, size_of_grid, min_, max_, dimension); std::stringstream ss; diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_distance_from_diagonal.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_distance_from_diagonal.cpp index 5a657b13..fece2e36 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_distance_from_diagonal.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_distance_from_diagonal.cpp @@ -19,7 +19,7 @@ using distance_from_diagonal_scaling = Gudhi::Persistence_representations::dista using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps<distance_from_diagonal_scaling>; int main(int argc, char** argv) { - std::cout << "This program creates persistence heat map files (*.mps) of persistence diagrams files (*.pers) " + std::clog << "This program creates persistence heat map files (*.mps) of persistence diagrams files (*.pers) " << "provided as an input.The Gaussian kernels are weighted by the distance of a center from the " << "diagonal.\n" << "The first parameter of a program is an integer, a size of a grid.\n" @@ -36,7 +36,7 @@ int main(int argc, char** argv) { << "The remaining parameters are the names of files with persistence diagrams. \n"; if (argc < 7) { - std::cout << "Wrong parameter list, the program will now terminate \n"; + std::clog << "Wrong parameter list, the program will now terminate \n"; return 1; } @@ -58,7 +58,7 @@ int main(int argc, char** argv) { std::vector<std::vector<double> > filter = Gudhi::Persistence_representations::create_Gaussian_filter(stdiv, 1); for (size_t i = 0; i != filenames.size(); ++i) { - std::cout << "Creating a heat map based on a file : " << filenames[i] << std::endl; + std::clog << "Creating a heat map based on a file : " << filenames[i] << std::endl; Persistence_heat_maps l(filenames[i], filter, false, size_of_grid, min_, max_, dimension); std::stringstream ss; diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_squared_diag_distance.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_squared_diag_distance.cpp index 8d67a54d..86e6fc19 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_squared_diag_distance.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_squared_diag_distance.cpp @@ -21,7 +21,7 @@ using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps<squared_distance_from_diagonal_scaling>; int main(int argc, char** argv) { - std::cout << "This program creates persistence heat map files (*.mps) of persistence diagrams files (*.pers) " + std::clog << "This program creates persistence heat map files (*.mps) of persistence diagrams files (*.pers) " << "provided as an input.The Gaussian kernels are weighted by the square of distance of a center from the " << "diagonal.\n" << "The first parameter of a program is an integer, a size of a grid.\n" @@ -38,7 +38,7 @@ int main(int argc, char** argv) { << "The remaining parameters are the names of files with persistence diagrams. \n"; if (argc < 7) { - std::cout << "Wrong parameter list, the program will now terminate \n"; + std::clog << "Wrong parameter list, the program will now terminate \n"; return 1; } @@ -60,7 +60,7 @@ int main(int argc, char** argv) { std::vector<std::vector<double> > filter = Gudhi::Persistence_representations::create_Gaussian_filter(stdiv, 1); for (size_t i = 0; i != filenames.size(); ++i) { - std::cout << "Creating a heat map based on a file : " << filenames[i] << std::endl; + std::clog << "Creating a heat map based on a file : " << filenames[i] << std::endl; Persistence_heat_maps l(filenames[i], filter, false, size_of_grid, min_, max_, dimension); std::stringstream ss; diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp index 29170c32..ca27f8e3 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp @@ -19,7 +19,7 @@ using constant_scaling_function = Gudhi::Persistence_representations::constant_s using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps<constant_scaling_function>; int main(int argc, char** argv) { - std::cout << "This program creates persistence heat map files (*.mps) of persistence diagrams files (*.pers) " + std::clog << "This program creates persistence heat map files (*.mps) of persistence diagrams files (*.pers) " << "provided as an input.\n" << "The first parameter of a program is an integer, a size of a grid.\n" << "The second and third parameters are min and max of the grid. If you want those numbers to be computed " @@ -35,7 +35,7 @@ int main(int argc, char** argv) { << "The remaining parameters are the names of files with persistence diagrams. \n"; if (argc < 7) { - std::cout << "Wrong parameter list, the program will now terminate \n"; + std::clog << "Wrong parameter list, the program will now terminate \n"; return 1; } size_t size_of_grid = (size_t)atoi(argv[1]); @@ -55,7 +55,7 @@ int main(int argc, char** argv) { std::vector<std::vector<double> > filter = Gudhi::Persistence_representations::create_Gaussian_filter(stdiv, 1); for (size_t i = 0; i != filenames.size(); ++i) { - std::cout << "Creating a heat map based on file : " << filenames[i] << std::endl; + std::clog << "Creating a heat map based on file : " << filenames[i] << std::endl; Persistence_heat_maps l(filenames[i], filter, false, size_of_grid, min_, max_, dimension); std::stringstream ss; diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/create_pssk.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/create_pssk.cpp index 995771b9..d2ebcc7e 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/create_pssk.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/create_pssk.cpp @@ -18,7 +18,7 @@ using PSSK = Gudhi::Persistence_representations::PSSK; int main(int argc, char** argv) { - std::cout << "This program creates PSSK files (*.pssk) of persistence diagrams files (*.pers) " + std::clog << "This program creates PSSK files (*.pssk) of persistence diagrams files (*.pers) " << "provided as an input.\n" << "The first parameter of a program is an integer, a size of a grid.\n" << "The second and third parameters are min and max of the grid. If you want those numbers to be computed " @@ -34,7 +34,7 @@ int main(int argc, char** argv) { << "The remaining parameters are the names of files with persistence diagrams. \n"; if (argc < 7) { - std::cout << "Wrong parameter list, the program will now terminate \n"; + std::clog << "Wrong parameter list, the program will now terminate \n"; return 1; } @@ -56,7 +56,7 @@ int main(int argc, char** argv) { std::vector<std::vector<double> > filter = Gudhi::Persistence_representations::create_Gaussian_filter(stdiv, 1); for (size_t i = 0; i != filenames.size(); ++i) { - std::cout << "Creating a PSSK based on a file : " << filenames[i] << std::endl; + std::clog << "Creating a PSSK based on a file : " << filenames[i] << std::endl; PSSK l(filenames[i], filter, size_of_grid, min_, max_, dimension); std::stringstream ss; diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp index cf6e07cb..87cc97d1 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp @@ -17,10 +17,10 @@ using constant_scaling_function = Gudhi::Persistence_representations::constant_s using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps<constant_scaling_function>; int main(int argc, char** argv) { - std::cout << "This program creates a gnuplot script from a persistence heat maps stored in a file (the file needs " + std::clog << "This program creates a gnuplot script from a persistence heat maps stored in a file (the file needs " << "to be created beforehand). Please call the code with the name of a single heat maps file \n"; if (argc != 2) { - std::cout << "Wrong parameter list, the program will now terminate \n"; + std::clog << "Wrong parameter list, the program will now terminate \n"; return 1; } Persistence_heat_maps l; diff --git a/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt index a025183e..118c1e9b 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt @@ -3,17 +3,16 @@ project(Persistence_representations_intervals_utilities) add_executable ( plot_histogram_of_intervals_lengths plot_histogram_of_intervals_lengths.cpp ) -add_test(NAME plot_histogram_of_intervals_lengths COMMAND $<TARGET_FILE:plot_histogram_of_intervals_lengths> +add_test(NAME Persistence_representation_utilities_plot_histogram_of_intervals_lengths COMMAND $<TARGET_FILE:plot_histogram_of_intervals_lengths> "${CMAKE_CURRENT_BINARY_DIR}/../first.pers" "-1") install(TARGETS plot_histogram_of_intervals_lengths DESTINATION bin) -add_persistence_representation_plot_utility(plot_persistence_intervals "") -add_persistence_representation_plot_utility(plot_persistence_Betti_numbers "") +add_persistence_representation_plot_utility(plot_histogram_of_intervals_lengths plot_persistence_intervals "") +add_persistence_representation_plot_utility(plot_histogram_of_intervals_lengths plot_persistence_Betti_numbers "") add_persistence_representation_creation_utility(compute_birth_death_range_in_persistence_diagram "-1") - add_executable ( compute_number_of_dominant_intervals compute_number_of_dominant_intervals.cpp ) add_test(NAME Persistence_representation_utilities_compute_number_of_dominant_intervals COMMAND $<TARGET_FILE:compute_number_of_dominant_intervals> diff --git a/src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp b/src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp index 519cc47d..72325cad 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp +++ b/src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp @@ -18,7 +18,7 @@ using Persistence_intervals = Gudhi::Persistence_representations::Persistence_intervals; int main(int argc, char** argv) { - std::cout << "This program computes the range of birth and death times of persistence pairs in diagrams provided as " + std::clog << "This program computes the range of birth and death times of persistence pairs in diagrams provided as " << "an input.\n" << "The first parameter is the dimension of persistence to be used to create persistence intervals. " << "If your file contains the information about dimension of persistence pairs, please provide here the " @@ -27,7 +27,7 @@ int main(int argc, char** argv) { << "The remaining parameters of the program are the names of files with persistence diagrams.\n"; if (argc < 3) { - std::cout << "Wrong parameter list, the program will now terminate \n"; + std::clog << "Wrong parameter list, the program will now terminate \n"; return 1; } @@ -45,12 +45,12 @@ int main(int argc, char** argv) { double max_ = -std::numeric_limits<double>::max(); for (size_t file_no = 0; file_no != filenames.size(); ++file_no) { - std::cout << "Creating diagram based on a file : " << filenames[file_no] << std::endl; + std::clog << "Creating diagram based on a file : " << filenames[file_no] << std::endl; Persistence_intervals p(filenames[file_no], dimension); std::pair<double, double> min_max_ = p.get_x_range(); if (min_max_.first < min_) min_ = min_max_.first; if (min_max_.second > max_) max_ = min_max_.second; } - std::cout << "Birth-death range : min: " << min_ << ", max: " << max_ << std::endl; + std::clog << "Birth-death range : min: " << min_ << ", max: " << max_ << std::endl; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp b/src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp index 6155727a..465bf72e 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp +++ b/src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp @@ -18,7 +18,7 @@ using Persistence_intervals_with_distances = Gudhi::Persistence_representations::Persistence_intervals_with_distances; int main(int argc, char** argv) { - std::cout << "This program computes the bottleneck distance of persistence pairs in diagrams provided as " + std::clog << "This program computes the bottleneck distance of persistence pairs in diagrams provided as " << "an input.\n" << "The first parameter is the dimension of persistence to be used to create persistence intervals. " << "If your file contains the information about dimension of persistence pairs, please provide here the " @@ -27,7 +27,7 @@ int main(int argc, char** argv) { << "The remaining parameters of the program are the names of files with persistence diagrams.\n"; if (argc < 3) { - std::cout << "Wrong number of parameters, the program will now terminate \n"; + std::clog << "Wrong number of parameters, the program will now terminate \n"; return 1; } @@ -70,14 +70,14 @@ int main(int argc, char** argv) { out.open("distance.itv"); for (size_t i = 0; i != distance.size(); ++i) { for (size_t j = 0; j != distance.size(); ++j) { - std::cout << distance[i][j] << " "; + std::clog << distance[i][j] << " "; out << distance[i][j] << " "; } - std::cout << std::endl; + std::clog << std::endl; out << std::endl; } out.close(); - std::cout << "Distance can be found in 'distance.itv' file\n"; + std::clog << "Distance can be found in 'distance.itv' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp b/src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp index dd6e1a5b..ea1fe717 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp +++ b/src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp @@ -18,10 +18,10 @@ using Persistence_intervals = Gudhi::Persistence_representations::Persistence_intervals; int main(int argc, char** argv) { - std::cout << "This program compute the dominant intervals. A number of intervals to be displayed is a parameter of " + std::clog << "This program compute the dominant intervals. A number of intervals to be displayed is a parameter of " "this program. \n"; if (argc != 4) { - std::cout << "To run this program, please provide the name of a file with persistence diagram, dimension of " + std::clog << "To run this program, please provide the name of a file with persistence diagram, dimension of " "intervals that should be taken into account (if your file contains only persistence pairs in a " "single dimension, set it up to -1) and number of dominant intervals you would like to get \n"; return 1; @@ -33,9 +33,9 @@ int main(int argc, char** argv) { } Persistence_intervals p(argv[1], dimension); std::vector<std::pair<double, double> > dominant_intervals = p.dominant_intervals(atoi(argv[3])); - std::cout << "Here are the dominant intervals : " << std::endl; + std::clog << "Here are the dominant intervals : " << std::endl; for (size_t i = 0; i != dominant_intervals.size(); ++i) { - std::cout << " " << dominant_intervals[i].first << "," << dominant_intervals[i].second << " " << std::endl; + std::clog << " " << dominant_intervals[i].first << "," << dominant_intervals[i].second << " " << std::endl; } return 0; diff --git a/src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp b/src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp index 13d2133f..e5eec3f5 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp +++ b/src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp @@ -18,10 +18,10 @@ using Persistence_intervals = Gudhi::Persistence_representations::Persistence_intervals; int main(int argc, char** argv) { - std::cout << "This program computes a histogram of barcode's length. A number of bins in the histogram is a " + std::clog << "This program computes a histogram of barcode's length. A number of bins in the histogram is a " << "parameter of this program. \n"; if ((argc != 3) && (argc != 4)) { - std::cout << "To run this program, please provide the name of a file with persistence diagram and number of " + std::clog << "To run this program, please provide the name of a file with persistence diagram and number of " << "dominant intervals you would like to get. Set a negative number dominant intervals value " << "If your file contains only birth-death pairs.\n" << "The third parameter is the dimension of the persistence that is to be used. If your " @@ -59,7 +59,7 @@ int main(int argc, char** argv) { out << std::endl; out.close(); - 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; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp b/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp index 451be77f..27c69e07 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp +++ b/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp @@ -19,7 +19,7 @@ using Persistence_intervals = Gudhi::Persistence_representations::Persistence_in int main(int argc, char** argv) { if ((argc != 3) && (argc != 2)) { - std::cout << "This program creates a gnuplot script of Betti numbers from a single persistence diagram file" + std::clog << "This program creates a gnuplot script of Betti numbers from a single persistence diagram file" << "(*.pers).\n" << "To run this program, please provide the name of a file with persistence diagram.\n" << "The second optional parameter of a program is the dimension of the persistence that is to be used. " @@ -68,7 +68,7 @@ int main(int argc, char** argv) { out << std::endl; out.close(); - 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; return 0; diff --git a/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp b/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp index 09a56869..199a3266 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp +++ b/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp @@ -19,7 +19,7 @@ using Persistence_intervals = Gudhi::Persistence_representations::Persistence_in int main(int argc, char** argv) { if ((argc != 3) && (argc != 2)) { - std::cout << "This program creates a gnuplot script from a single persistence diagram file (*.pers).\n" + std::clog << "This program creates a gnuplot script from a single persistence diagram file (*.pers).\n" << "To run this program, please provide the name of a file with persistence diagram.\n" << "The second optional parameter of a program is the dimension of the persistence that is to be used. " << "If your file contains only birth-death pairs, you can skip this parameter.\n"; diff --git a/src/Persistence_representations/utilities/persistence_landscapes/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_landscapes/CMakeLists.txt index 6b24d032..4df84d36 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_landscapes/CMakeLists.txt @@ -2,8 +2,8 @@ project(Persistence_representations_landscapes_utilities) add_persistence_representation_creation_utility(create_landscapes "-1") -add_persistence_representation_plot_utility(plot_landscapes ".land") +add_persistence_representation_plot_utility(create_landscapes plot_landscapes ".land") -add_persistence_representation_function_utility(average_landscapes ".land") -add_persistence_representation_function_utility(compute_distance_of_landscapes ".land" "1") -add_persistence_representation_function_utility(compute_scalar_product_of_landscapes ".land") +add_persistence_representation_function_utility(create_landscapes average_landscapes ".land") +add_persistence_representation_function_utility(create_landscapes compute_distance_of_landscapes ".land" "1") +add_persistence_representation_function_utility(create_landscapes compute_scalar_product_of_landscapes ".land") diff --git a/src/Persistence_representations/utilities/persistence_landscapes/average_landscapes.cpp b/src/Persistence_representations/utilities/persistence_landscapes/average_landscapes.cpp index 04a0ada4..612e9700 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes/average_landscapes.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes/average_landscapes.cpp @@ -16,13 +16,13 @@ using Persistence_landscape = Gudhi::Persistence_representations::Persistence_landscape; int main(int argc, char** argv) { - std::cout << "This program computes average of persistence landscapes stored in files (the files needs to be " + std::clog << "This program computes average of persistence landscapes stored in files (the files needs to be " << "created beforehand).\n" << "The parameters of this programs are names of files with persistence landscapes.\n"; std::vector<const char*> filenames; if (argc < 3) { - std::cout << "Wrong number of parameters, the program will now terminate \n"; + std::clog << "Wrong number of parameters, the program will now terminate \n"; return 1; } @@ -46,6 +46,6 @@ int main(int argc, char** argv) { delete lands[i]; } - std::cout << "Average can be found in 'average.land' file\n"; + std::clog << "Average can be found in 'average.land' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_landscapes/compute_distance_of_landscapes.cpp b/src/Persistence_representations/utilities/persistence_landscapes/compute_distance_of_landscapes.cpp index 1093c1aa..2246a37d 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes/compute_distance_of_landscapes.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes/compute_distance_of_landscapes.cpp @@ -18,14 +18,14 @@ using Persistence_landscape = Gudhi::Persistence_representations::Persistence_landscape; int main(int argc, char** argv) { - std::cout << "This program computes distance of persistence landscapes stored in files (the files needs to be " + std::clog << "This program computes distance of persistence landscapes stored in files (the files needs to be " << "created beforehand).\n" << "The first parameter of a program is an integer p. The program compute L^p distance of the two heat " << "maps. For L^infty distance choose p = -1. \n" << "The remaining parameters of this program are names of files with persistence landscapes.\n"; if (argc < 3) { - std::cout << "Wrong number of parameters, the program will now terminate \n"; + std::clog << "Wrong number of parameters, the program will now terminate \n"; return 1; } @@ -68,14 +68,14 @@ int main(int argc, char** argv) { out.open("distance.land"); for (size_t i = 0; i != distance.size(); ++i) { for (size_t j = 0; j != distance.size(); ++j) { - std::cout << distance[i][j] << " "; + std::clog << distance[i][j] << " "; out << distance[i][j] << " "; } - std::cout << std::endl; + std::clog << std::endl; out << std::endl; } out.close(); - std::cout << "Distance can be found in 'distance.land' file\n"; + std::clog << "Distance can be found in 'distance.land' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_landscapes/compute_scalar_product_of_landscapes.cpp b/src/Persistence_representations/utilities/persistence_landscapes/compute_scalar_product_of_landscapes.cpp index 16b76497..44f50543 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes/compute_scalar_product_of_landscapes.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes/compute_scalar_product_of_landscapes.cpp @@ -17,12 +17,12 @@ using Persistence_landscape = Gudhi::Persistence_representations::Persistence_landscape; int main(int argc, char** argv) { - std::cout << "This program computes scalar product of persistence landscapes stored in a file (the file needs to be " + std::clog << "This program computes scalar product of persistence landscapes stored in a file (the file needs to be " << "created beforehand). \n" << "The parameters of this programs are names of files with persistence landscapes.\n"; if (argc < 3) { - std::cout << "Wrong number of parameters, the program will now terminate \n"; + std::clog << "Wrong number of parameters, the program will now terminate \n"; return 1; } @@ -59,14 +59,14 @@ int main(int argc, char** argv) { out.open("scalar_product.land"); for (size_t i = 0; i != scalar_product.size(); ++i) { for (size_t j = 0; j != scalar_product.size(); ++j) { - std::cout << scalar_product[i][j] << " "; + std::clog << scalar_product[i][j] << " "; out << scalar_product[i][j] << " "; } - std::cout << std::endl; + std::clog << std::endl; out << std::endl; } out.close(); - std::cout << "Distance can be found in 'scalar_product.land' file\n"; + std::clog << "Distance can be found in 'scalar_product.land' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_landscapes/create_landscapes.cpp b/src/Persistence_representations/utilities/persistence_landscapes/create_landscapes.cpp index 4d772086..fab5c75f 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes/create_landscapes.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes/create_landscapes.cpp @@ -18,7 +18,7 @@ using Persistence_landscape = Gudhi::Persistence_representations::Persistence_landscape; int main(int argc, char** argv) { - std::cout << "This program creates persistence landscapes files (*.land) of persistence diagrams files (*.pers) " + std::clog << "This program creates persistence landscapes files (*.land) of persistence diagrams files (*.pers) " << "provided as an input.\n" << "The first parameter of this program is a dimension of persistence that will be used in creation of " << "the persistence heat maps." @@ -29,7 +29,7 @@ int main(int argc, char** argv) { << "The remaining parameters are the names of files with persistence diagrams. \n"; if (argc < 3) { - std::cout << "Wrong parameter list, the program will now terminate \n"; + std::clog << "Wrong parameter list, the program will now terminate \n"; return 1; } std::vector<const char*> filenames; @@ -43,7 +43,7 @@ int main(int argc, char** argv) { } for (size_t i = 0; i != filenames.size(); ++i) { - std::cout << "Creating a landscape based on file : " << filenames[i] << std::endl; + std::clog << "Creating a landscape based on file : " << filenames[i] << std::endl; Persistence_landscape l(filenames[i], dimension); std::stringstream ss; ss << filenames[i] << ".land"; diff --git a/src/Persistence_representations/utilities/persistence_landscapes/plot_landscapes.cpp b/src/Persistence_representations/utilities/persistence_landscapes/plot_landscapes.cpp index 1fe03640..da9b9bba 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes/plot_landscapes.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes/plot_landscapes.cpp @@ -16,10 +16,10 @@ using Persistence_landscape = Gudhi::Persistence_representations::Persistence_landscape; int main(int argc, char** argv) { - std::cout << "This program creates a gnuplot script from a persistence landscape stored in a file (the file needs " + std::clog << "This program creates a gnuplot script from a persistence landscape stored in a file (the file needs " << "to be created beforehand). Please call the code with the name of a single landscape file.\n"; if (argc != 2) { - std::cout << "Wrong parameter list, the program will now terminate \n"; + std::clog << "Wrong parameter list, the program will now terminate \n"; return 1; } diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/CMakeLists.txt index 36f3196b..8cd965f1 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/CMakeLists.txt @@ -3,8 +3,8 @@ project(Persistence_representations_lanscapes_on_grid_utilities) # Need to set grid min and max for further average, distance and scalar_product add_persistence_representation_creation_utility(create_landscapes_on_grid "100" "0" "35" "-1") -add_persistence_representation_plot_utility(plot_landscapes_on_grid ".g_land") +add_persistence_representation_plot_utility(create_landscapes_on_grid plot_landscapes_on_grid ".g_land") -add_persistence_representation_function_utility(average_landscapes_on_grid ".g_land") -add_persistence_representation_function_utility(compute_distance_of_landscapes_on_grid ".g_land" "1") -add_persistence_representation_function_utility(compute_scalar_product_of_landscapes_on_grid ".g_land") +add_persistence_representation_function_utility(create_landscapes_on_grid average_landscapes_on_grid ".g_land") +add_persistence_representation_function_utility(create_landscapes_on_grid compute_distance_of_landscapes_on_grid ".g_land" "1") +add_persistence_representation_function_utility(create_landscapes_on_grid compute_scalar_product_of_landscapes_on_grid ".g_land") diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp index f92cde72..39f7a67f 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp @@ -16,12 +16,12 @@ using Persistence_landscape_on_grid = Gudhi::Persistence_representations::Persistence_landscape_on_grid; int main(int argc, char** argv) { - std::cout << "This program computes average of persistence landscapes on grid stored in files (the files needs to " + std::clog << "This program computes average of persistence landscapes on grid stored in files (the files needs to " << "be created beforehand).\n" << "The parameters of this programs are names of files with persistence landscapes on grid.\n"; if (argc < 3) { - std::cout << "Wrong number of parameters, the program will now terminate \n"; + std::clog << "Wrong number of parameters, the program will now terminate \n"; return 1; } @@ -46,6 +46,6 @@ int main(int argc, char** argv) { delete lands[i]; } - std::cout << "Average can be found in 'average.g_land' file\n"; + std::clog << "Average can be found in 'average.g_land' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp index baec6aeb..01fd09d8 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp @@ -18,14 +18,14 @@ using Persistence_landscape_on_grid = Gudhi::Persistence_representations::Persistence_landscape_on_grid; int main(int argc, char** argv) { - std::cout << "This program computes distance of persistence landscapes on grid stored in files (the files needs to " + std::clog << "This program computes distance of persistence landscapes on grid stored in files (the files needs to " << "be created beforehand).\n" << "The first parameter of a program is an integer p. The program compute L^p distance of the two heat " << "maps. For L^infty distance choose p = -1. \n" << "The remaining parameters of this program are names of files with persistence landscapes on grid.\n"; if (argc < 3) { - std::cout << "Wrong number of parameters, the program will now terminate \n"; + std::clog << "Wrong number of parameters, the program will now terminate \n"; return 1; } @@ -68,14 +68,14 @@ int main(int argc, char** argv) { out.open("distance.g_land"); for (size_t i = 0; i != distance.size(); ++i) { for (size_t j = 0; j != distance.size(); ++j) { - std::cout << distance[i][j] << " "; + std::clog << distance[i][j] << " "; out << distance[i][j] << " "; } - std::cout << std::endl; + std::clog << std::endl; out << std::endl; } out.close(); - std::cout << "Distance can be found in 'distance.g_land' file\n"; + std::clog << "Distance can be found in 'distance.g_land' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp index e94dacdb..71c2f419 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp @@ -17,13 +17,13 @@ using Persistence_landscape_on_grid = Gudhi::Persistence_representations::Persistence_landscape_on_grid; int main(int argc, char** argv) { - std::cout + std::clog << "This program computes scalar product of persistence landscapes on grid stored in a file (the file needs to " << "be created beforehand). \n" << "The parameters of this programs are names of files with persistence landscapes on grid.\n"; if (argc < 3) { - std::cout << "Wrong number of parameters, the program will now terminate \n"; + std::clog << "Wrong number of parameters, the program will now terminate \n"; return 1; } @@ -60,14 +60,14 @@ int main(int argc, char** argv) { out.open("scalar_product.g_land"); for (size_t i = 0; i != scalar_product.size(); ++i) { for (size_t j = 0; j != scalar_product.size(); ++j) { - std::cout << scalar_product[i][j] << " "; + std::clog << scalar_product[i][j] << " "; out << scalar_product[i][j] << " "; } - std::cout << std::endl; + std::clog << std::endl; out << std::endl; } out.close(); - std::cout << "Distance can be found in 'scalar_product.g_land' file\n"; + std::clog << "Distance can be found in 'scalar_product.g_land' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp index d510c3df..788313c4 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp @@ -18,7 +18,7 @@ using Persistence_landscape_on_grid = Gudhi::Persistence_representations::Persistence_landscape_on_grid; int main(int argc, char** argv) { - std::cout << "This program creates persistence landscapes on grid files (*.g_land) of persistence diagrams files " + std::clog << "This program creates persistence landscapes on grid files (*.g_land) of persistence diagrams files " << "(*.pers) provided as an input.\n" << "The first parameter of a program is an integer, a size of a grid.\n" << "The second and third parameters are min and max of the grid. If you want those numbers to be computed " @@ -32,7 +32,7 @@ int main(int argc, char** argv) { << "The remaining parameters are the names of files with persistence diagrams. \n"; if (argc < 6) { - std::cout << "Wrong parameter list, the program will now terminate \n"; + std::clog << "Wrong parameter list, the program will now terminate \n"; return 1; } @@ -51,7 +51,7 @@ int main(int argc, char** argv) { } for (size_t i = 0; i != filenames.size(); ++i) { - std::cout << "Creating persistence landscape on a grid based on a file : " << filenames[i] << std::endl; + std::clog << "Creating persistence landscape on a grid based on a file : " << filenames[i] << std::endl; Persistence_landscape_on_grid l; if ((min_ != -1) || (max_ != -1)) { l = Persistence_landscape_on_grid(filenames[i], min_, max_, size_of_grid, dimension); diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp index 4e20f37f..ec6112b5 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp @@ -16,11 +16,11 @@ using Persistence_landscape_on_grid = Gudhi::Persistence_representations::Persistence_landscape_on_grid; int main(int argc, char** argv) { - std::cout << "This program creates a gnuplot script from a persistence landscape on grid stored in a file (the file " + std::clog << "This program creates a gnuplot script from a persistence landscape on grid stored in a file (the file " << "needs to be created beforehand). Please call the code with the name of a single landscape on grid file" << ".\n"; if (argc != 2) { - std::cout << "Wrong parameter list, the program will now terminate \n"; + std::clog << "Wrong parameter list, the program will now terminate \n"; return 1; } diff --git a/src/Persistence_representations/utilities/persistence_vectors/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_vectors/CMakeLists.txt index bc982094..5b22ca84 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_vectors/CMakeLists.txt @@ -2,8 +2,8 @@ project(Persistence_vectors_utilities) add_persistence_representation_creation_utility(create_persistence_vectors "-1") -add_persistence_representation_plot_utility(plot_persistence_vectors ".vect") +add_persistence_representation_plot_utility(create_persistence_vectors plot_persistence_vectors ".vect") -add_persistence_representation_function_utility(average_persistence_vectors ".vect") -add_persistence_representation_function_utility(compute_distance_of_persistence_vectors ".vect" "1") -add_persistence_representation_function_utility(compute_scalar_product_of_persistence_vectors ".vect") +add_persistence_representation_function_utility(create_persistence_vectors average_persistence_vectors ".vect") +add_persistence_representation_function_utility(create_persistence_vectors compute_distance_of_persistence_vectors ".vect" "1") +add_persistence_representation_function_utility(create_persistence_vectors compute_scalar_product_of_persistence_vectors ".vect") diff --git a/src/Persistence_representations/utilities/persistence_vectors/average_persistence_vectors.cpp b/src/Persistence_representations/utilities/persistence_vectors/average_persistence_vectors.cpp index 89e42f0f..4eb32eb3 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/average_persistence_vectors.cpp +++ b/src/Persistence_representations/utilities/persistence_vectors/average_persistence_vectors.cpp @@ -17,12 +17,12 @@ using Euclidean_distance = Gudhi::Euclidean_distance; using Vector_distances_in_diagram = Gudhi::Persistence_representations::Vector_distances_in_diagram<Euclidean_distance>; int main(int argc, char** argv) { - std::cout << "This program computes average of persistence vectors stored in files (the files needs to " + std::clog << "This program computes average of persistence vectors stored in files (the files needs to " << "be created beforehand).\n" << "The parameters of this programs are names of files with persistence vectors.\n"; if (argc < 3) { - std::cout << "Wrong number of parameters, the program will now terminate \n"; + std::clog << "Wrong number of parameters, the program will now terminate \n"; return 1; } @@ -47,7 +47,7 @@ int main(int argc, char** argv) { delete lands[i]; } - std::cout << "Done \n"; + std::clog << "Done \n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp b/src/Persistence_representations/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp index 541dd25f..236981a3 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp +++ b/src/Persistence_representations/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp @@ -19,14 +19,14 @@ using Euclidean_distance = Gudhi::Euclidean_distance; using Vector_distances_in_diagram = Gudhi::Persistence_representations::Vector_distances_in_diagram<Euclidean_distance>; int main(int argc, char** argv) { - std::cout << "This program compute distance of persistence vectors stored in a file (the file needs to be created " + std::clog << "This program compute distance of persistence vectors stored in a file (the file needs to be created " "beforehand). \n"; - std::cout << "The first parameter of a program is an integer p. The program compute l^p distance of the vectors. For " + std::clog << "The first parameter of a program is an integer p. The program compute l^p distance of the vectors. For " "l^infty distance choose p = -1. \n"; - std::cout << "The remaining parameters of this programs are names of files with persistence vectors.\n"; + std::clog << "The remaining parameters of this programs are names of files with persistence vectors.\n"; if (argc < 3) { - std::cout << "Wrong number of parameters, the program will now terminate \n"; + std::clog << "Wrong number of parameters, the program will now terminate \n"; return 1; } @@ -69,14 +69,14 @@ int main(int argc, char** argv) { out.open("distance.vect"); for (size_t i = 0; i != distance.size(); ++i) { for (size_t j = 0; j != distance.size(); ++j) { - std::cout << distance[i][j] << " "; + std::clog << distance[i][j] << " "; out << distance[i][j] << " "; } - std::cout << std::endl; + std::clog << std::endl; out << std::endl; } out.close(); - std::cout << "Distance can be found in 'distance.vect' file\n"; + std::clog << "Distance can be found in 'distance.vect' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp b/src/Persistence_representations/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp index bbc50c98..c6ea0e1c 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp +++ b/src/Persistence_representations/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp @@ -19,12 +19,12 @@ using Euclidean_distance = Gudhi::Euclidean_distance; using Vector_distances_in_diagram = Gudhi::Persistence_representations::Vector_distances_in_diagram<Euclidean_distance>; int main(int argc, char** argv) { - std::cout << "This program computes scalar product of persistence vectors stored in a file (the file needs to " + std::clog << "This program computes scalar product of persistence vectors stored in a file (the file needs to " << "be created beforehand). \n" << "The parameters of this programs are names of files with persistence vectors.\n"; if (argc < 3) { - std::cout << "Wrong number of parameters, the program will now terminate \n"; + std::clog << "Wrong number of parameters, the program will now terminate \n"; return 1; } @@ -61,14 +61,14 @@ int main(int argc, char** argv) { out.open("scalar_product.vect"); for (size_t i = 0; i != scalar_product.size(); ++i) { for (size_t j = 0; j != scalar_product.size(); ++j) { - std::cout << scalar_product[i][j] << " "; + std::clog << scalar_product[i][j] << " "; out << scalar_product[i][j] << " "; } - std::cout << std::endl; + std::clog << std::endl; out << std::endl; } out.close(); - std::cout << "Distance can be found in 'scalar_product.vect' file\n"; + std::clog << "Distance can be found in 'scalar_product.vect' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_vectors/create_persistence_vectors.cpp b/src/Persistence_representations/utilities/persistence_vectors/create_persistence_vectors.cpp index f974c3d3..608e04e5 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/create_persistence_vectors.cpp +++ b/src/Persistence_representations/utilities/persistence_vectors/create_persistence_vectors.cpp @@ -19,7 +19,7 @@ using Euclidean_distance = Gudhi::Euclidean_distance; using Vector_distances_in_diagram = Gudhi::Persistence_representations::Vector_distances_in_diagram<Euclidean_distance>; int main(int argc, char** argv) { - std::cout << "This program creates persistence vectors files (*.vect) of persistence diagrams files (*.pers) " + std::clog << "This program creates persistence vectors files (*.vect) of persistence diagrams files (*.pers) " << "provided as an input.\n" << "The first parameter of this program is a dimension of persistence that will be used in creation of " << "the persistence heat maps." @@ -30,11 +30,11 @@ int main(int argc, char** argv) { << "The remaining parameters are the names of files with persistence diagrams. \n"; if (argc < 3) { - std::cout << "Wrong parameter list, the program will now terminate \n"; + std::clog << "Wrong parameter list, the program will now terminate \n"; return 1; } - std::cout << "The remaining parameters are the names of files with persistence diagrams. \n"; + std::clog << "The remaining parameters are the names of files with persistence diagrams. \n"; int dim = atoi(argv[1]); unsigned dimension = std::numeric_limits<unsigned>::max(); if (dim >= 0) { diff --git a/src/Persistence_representations/utilities/persistence_vectors/plot_persistence_vectors.cpp b/src/Persistence_representations/utilities/persistence_vectors/plot_persistence_vectors.cpp index de08fcfe..2decb134 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/plot_persistence_vectors.cpp +++ b/src/Persistence_representations/utilities/persistence_vectors/plot_persistence_vectors.cpp @@ -17,10 +17,10 @@ using Euclidean_distance = Gudhi::Euclidean_distance; using Vector_distances_in_diagram = Gudhi::Persistence_representations::Vector_distances_in_diagram<Euclidean_distance>; int main(int argc, char** argv) { - std::cout << "This program create a Gnuplot script to plot persistence vector. Please call this program with the " + std::clog << "This program create a Gnuplot script to plot persistence vector. Please call this program with the " "name of file with persistence vector. \n"; if (argc != 2) { - std::cout << "Wrong number of parameters, the program will now terminate. \n"; + std::clog << "Wrong number of parameters, the program will now terminate. \n"; return 1; } Vector_distances_in_diagram l; |