PETLS
petls.hpp
Go to the documentation of this file.
1 #ifndef PLs_H
2 #define PLs_H
3 
4 #include "typedefs.hpp"
5 #include <string>
6 #include <vector>
7 #include <chrono>
8 
9 namespace petls {
10 
11  // https://stackoverflow.com/questions/54503795/rounding-numbers-below-a-certain-threshold-to-zero-in-eigen
12  void round_zeros(spectra_vec& inout, spectra_type threshold);
14  void print_full_matrix_precise(Eigen::MatrixXf m);
15 
16  void print_full_matrix_precise(Eigen::MatrixXi m);
17  // void print_full_matrix_precise(SparseMatrixInt m);
20  void print_vector_precise(Eigen::VectorXd v);
21  void print_vector_precise(Eigen::VectorXf v);
22  void print_spectra(std::vector<std::tuple<int, filtration_type, filtration_type, std::vector<spectra_type>>> spectra);
24  void reindex_boundaries(std::vector<std::vector<std::tuple<int,int,int>>> &boundaries_triples,std::vector<SparseMatrixInt> &reindexed_boundaries);
25  struct timer{
26  public:
27  int duration;
28  std::chrono::_V2::steady_clock::time_point start_t;
29  void start(){
30  start_t = std::chrono::steady_clock::now();
31  }
32  void stop(){
33  auto end_t = std::chrono::steady_clock::now();
34  duration = (std::chrono::duration_cast<std::chrono::milliseconds>(end_t - start_t)).count();
35  }
36  };
37 
38  struct Profile{
39  public:
40  std::vector<int> dims;
41  std::vector<filtration_type> filtration_a;
42  std::vector<filtration_type> filtration_b;
49  std::vector<int> durations_all;
50  std::vector<int> durations_eigs;
51  std::vector<int> durations_L;
52  std::vector<int> durations_L_up;
53  std::vector<int> durations_L_down;
54  std::vector<int> durations_sum_up_down;
55 
56  std::vector<int> L_rows;
57  std::vector<int> bettis;
58  std::vector<spectra_type> lambdas;
59  // std::vector<double> sparsity_L;
60  // std::vector<int> simplices_added;
61 
62  void to_csv(std::string filename);
63 
64  void start_all(){this->all.start();}
65  void start_eigs(){eigs.start();}
66  void start_L(){L.start();}
67  void start_L_up(){L_up.start();}
70 
71  void stop_all(){all.stop(); durations_all.push_back(all.duration);}
72  void stop_eigs(){eigs.stop(); durations_eigs.push_back(eigs.duration);}
73  void stop_L(){L.stop(); durations_L.push_back(L.duration);}
74  void stop_L_up(){L_up.stop(); durations_L_up.push_back(L_up.duration);}
77 
78  };
79 }
80 
81 #endif
Definition: Complex.cpp:26
void round_zeros(spectra_vec &inout, spectra_type threshold)
Definition: petls.cpp:14
void print_full_matrix_precise(SparseMatrixInt m)
Definition: petls.cpp:18
bool matrix_is_diagonal(DenseMatrix_PL &M)
Definition: petls.cpp:52
void reindex_boundaries(std::vector< std::vector< std::tuple< int, int, int >>> &boundaries_triples, std::vector< SparseMatrixInt > &reindexed_boundaries)
Definition: petls.cpp:80
void print_vector_precise(Eigen::VectorXd v)
Definition: petls.cpp:40
void print_spectra(std::vector< std::tuple< int, filtration_type, filtration_type, std::vector< spectra_type >>> spectra)
Definition: petls.cpp:65
Definition: petls.hpp:38
void stop_sum_up_down()
Definition: petls.hpp:76
void start_sum_up_down()
Definition: petls.hpp:69
std::vector< int > L_rows
Definition: petls.hpp:56
std::vector< int > durations_L
Definition: petls.hpp:51
std::vector< int > bettis
Definition: petls.hpp:57
void stop_all()
Definition: petls.hpp:71
void stop_L_up()
Definition: petls.hpp:74
void start_eigs()
Definition: petls.hpp:65
void start_L_down()
Definition: petls.hpp:68
std::vector< spectra_type > lambdas
Definition: petls.hpp:58
timer L
Definition: petls.hpp:45
std::vector< int > dims
Definition: petls.hpp:40
void stop_L()
Definition: petls.hpp:73
std::vector< filtration_type > filtration_b
Definition: petls.hpp:42
std::vector< int > durations_all
Definition: petls.hpp:49
timer L_up
Definition: petls.hpp:46
std::vector< int > durations_L_down
Definition: petls.hpp:53
void stop_eigs()
Definition: petls.hpp:72
timer all
Definition: petls.hpp:43
void start_L_up()
Definition: petls.hpp:67
void start_L()
Definition: petls.hpp:66
std::vector< int > durations_eigs
Definition: petls.hpp:50
void to_csv(std::string filename)
Definition: petls.cpp:136
std::vector< filtration_type > filtration_a
Definition: petls.hpp:41
std::vector< int > durations_L_up
Definition: petls.hpp:52
void stop_L_down()
Definition: petls.hpp:75
timer L_down
Definition: petls.hpp:47
void start_all()
Definition: petls.hpp:64
std::vector< int > durations_sum_up_down
Definition: petls.hpp:54
timer sum_up_down
Definition: petls.hpp:48
timer eigs
Definition: petls.hpp:44
Definition: petls.hpp:25
void stop()
Definition: petls.hpp:32
std::chrono::_V2::steady_clock::time_point start_t
Definition: petls.hpp:28
void start()
Definition: petls.hpp:29
int duration
Definition: petls.hpp:27
Eigen::Matrix< coefficient_type, Eigen::Dynamic, Eigen::Dynamic > DenseMatrix_PL
Definition: typedefs.hpp:14
Eigen::Matrix< spectra_type, Eigen::Dynamic, 1 > spectra_vec
Definition: typedefs.hpp:17
Eigen::SparseMatrix< coefficient_type, Eigen::ColMajor > SparseMatrix_PL
Definition: typedefs.hpp:13
float spectra_type
Definition: typedefs.hpp:11
Eigen::SparseMatrix< int, Eigen::ColMajor > SparseMatrixInt
Definition: typedefs.hpp:19
double filtration_type
Definition: typedefs.hpp:24