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