PETLS
Complex.hpp
Go to the documentation of this file.
1 #ifndef PL_H
2 #define PL_H
3 
4 #include <vector>
5 
6 #include "../typedefs.hpp"
7 #include "../petls.hpp"
8 // #include "up_algorithms.hpp"
9 // #include "../eigenvalues/eigs_algorithms.hpp"
11 
12 // #include <unsupported/Eigen/SparseExtra>
13 
14 
15 // #include <chrono>
16 // #include <numeric> //std::iota
17 // #include <map>
18 // #include <set>
19 
20 // #include <cassert>
21 
22 namespace petls{
29 // template <typename storage = int>
30 class Complex {
31  using storage = int;
32  public:
33  /********************/
34  /* Member variables */
35  /********************/
36 
37  int top_dim;
38  std::vector<FilteredBoundaryMatrix<storage>> filtered_boundaries;
39  bool verbose;
40  bool use_flipped;
43  std::function<std::pair<spectra_vec,DenseMatrix_PL>(DenseMatrix_PL&)> eigenpairs_algorithm_func;
44  // std::function<void(FilteredBoundaryMatrix<storage>*, filtration_type, filtration_type, DenseMatrix_PL&)> up_algorithm_func;
46  //may need to be void* instead of FilteredBoundaryMatrix*
47 
48  /****************/
49  /* Constructors */
50  /****************/
51 
55  Complex();
65  Complex(std::vector<Eigen::SparseMatrix<storage>> boundaries,
66  std::vector<std::vector<filtration_type>> filtrations);
67  /****************** */
68  /* Empty destructor */
69  /****************** */
70 
72 
73  /***********************/
74  /* Getters and setters */
75  /***********************/
76 
77  void set_eigs_algorithm_func(std::function<spectra_vec(DenseMatrix_PL&)> _eigs_algorithm_func);
78  void set_eigs_algorithm_func(std::string name);
79  void set_up_algorithm_func(std::function<void(FilteredBoundaryMatrix<int>*, filtration_type, filtration_type, DenseMatrix_PL&)> _up_algorithm_func);
80  void set_up_algorithm_func(std::string name);
81 
91  void set_boundaries_filtrations(std::vector<Eigen::SparseMatrix<storage>> boundaries,
92  std::vector<std::vector<filtration_type>> filtrations);
93 
98  void set_verbose(bool verbose){this->verbose = verbose;}
99 
104  void set_flipped(bool use_flipped){this->use_flipped = use_flipped;}
105 
106  /***********************************/
107  /* Primary Mathematical Operations */
108  /***********************************/
109 
110 
118  void get_L(int dim, filtration_type a, filtration_type b, DenseMatrix_PL &L);
147 
156  void get_up(int dim, filtration_type a, filtration_type b, DenseMatrix_PL &L_up);
157 
173  void get_down(int dim, filtration_type a, Eigen::SparseMatrix<storage> &L_down);
194  std::vector<spectra_type> nonzero_spectra(int dim, filtration_type a, filtration_type b, SparseMatrix_PL PH_basis, bool use_dummy_harmonic_basis);
195 
196  /**********************************************/
197  /* Driver functions to get PL and eigenvalues */
198  /**********************************************/
199 
207  std::vector<spectra_type> spectra(int dim, filtration_type a, filtration_type b);
208 
213  std::vector<std::tuple<int, filtration_type, filtration_type, std::vector<spectra_type>>> spectra();
214 
220  std::vector<std::tuple<int, filtration_type, filtration_type, std::vector<spectra_type>>> spectra(std::vector<std::tuple<int,filtration_type,filtration_type>> spectra_request_list);
221 
226  std::vector<std::tuple<int, filtration_type, filtration_type, std::vector<spectra_type>>> spectra_allpairs();
227 
228  /***************************************************************/
229  /* Driver functions to get PL and eigenvalues and eigenvectors */
230  /***************************************************************/
231 
232 
240  std::pair<std::vector<spectra_type>,DenseMatrix_PL> eigenpairs(int dim, filtration_type a, filtration_type b);
241 
246  std::vector<std::tuple<int, filtration_type, filtration_type, std::vector<spectra_type>,DenseMatrix_PL>> eigenpairs();
252  std::vector<std::tuple<int, filtration_type, filtration_type, std::vector<spectra_type>, DenseMatrix_PL>> eigenpairs(std::vector<std::tuple<int,filtration_type,filtration_type>> spectra_request_list);
253 
259  std::pair<int, spectra_type> eigenvalues_summarize(std::vector<spectra_type> eigenvalues);
260  /**********************************/
261  /* Helpful input/output functions */
262  /**********************************/
263 
264 
272  void store_L(int dim, filtration_type a, filtration_type b, std::string filename);
276  void print_boundaries();
287  void store_spectra(std::vector<std::tuple<int, filtration_type, filtration_type, std::vector<spectra_type>>> spectra, std::string out_prefix);
288 
296  void store_spectra_summary(std::vector<std::tuple<int, filtration_type, filtration_type, std::vector<spectra_type>>> spectra, std::string out_prefix);
297 
298 
303  void time_to_csv(std::string filename){profile.to_csv(filename);}
304 
311  std::vector<std::tuple<int, filtration_type, filtration_type>> filtration_list_to_spectra_request(std::vector<filtration_type> filtrations, std::vector<int> dims);
312 
319  std::vector<std::tuple<int, filtration_type, filtration_type>> filtration_list_to_spectra_request_allpairs(std::vector<filtration_type> filtrations, std::vector<int> dims);
320 
321 
325  std::vector<filtration_type> get_all_filtrations();
326  protected:
327 
329 };
330 
331 
332 }
333 #endif
Definition: Complex.hpp:30
std::function< void(FilteredBoundaryMatrix< storage > *, filtration_type, filtration_type, DenseMatrix_PL &)> up_algorithm_func
Definition: Complex.hpp:45
std::vector< std::tuple< int, filtration_type, filtration_type, std::vector< spectra_type > > > spectra_allpairs()
Definition: Complex.cpp:664
Profile profile
Profiler to track time usage of various steps.
Definition: Complex.hpp:41
std::vector< FilteredBoundaryMatrix< storage > > filtered_boundaries
Boundary matrix assuming real (or integer) coefficients.
Definition: Complex.hpp:38
void get_down(int dim, filtration_type a, Eigen::SparseMatrix< storage > &L_down)
Definition: Complex.cpp:327
std::vector< filtration_type > get_all_filtrations()
Definition: Complex.cpp:1090
void set_eigs_algorithm_func(std::function< spectra_vec(DenseMatrix_PL &)> _eigs_algorithm_func)
Definition: Complex.cpp:79
int top_dim
Top dimension of the complex.
Definition: Complex.hpp:37
void time_to_csv(std::string filename)
Definition: Complex.hpp:303
std::function< std::pair< spectra_vec, DenseMatrix_PL >DenseMatrix_PL &)> eigenpairs_algorithm_func
Definition: Complex.hpp:43
void set_up_algorithm_func(std::function< void(FilteredBoundaryMatrix< int > *, filtration_type, filtration_type, DenseMatrix_PL &)> _up_algorithm_func)
Definition: Complex.cpp:98
std::vector< spectra_type > nonzero_spectra(int dim, filtration_type a, filtration_type b, SparseMatrix_PL PH_basis, bool use_dummy_harmonic_basis)
Definition: Complex.cpp:362
void get_L(int dim, filtration_type a, filtration_type b, DenseMatrix_PL &L)
Definition: Complex.cpp:170
bool verbose
Print progress if spectra() is called.
Definition: Complex.hpp:39
void get_up(int dim, filtration_type a, filtration_type b, DenseMatrix_PL &L_up)
Definition: Complex.cpp:300
void set_verbose(bool verbose)
Definition: Complex.hpp:98
void store_L(int dim, filtration_type a, filtration_type b, std::string filename)
Definition: Complex.cpp:873
Complex()
Definition: Complex.cpp:43
void store_spectra(std::vector< std::tuple< int, filtration_type, filtration_type, std::vector< spectra_type >>> spectra, std::string out_prefix)
Definition: Complex.cpp:913
void print_boundaries()
Definition: Complex.cpp:890
std::vector< std::tuple< int, filtration_type, filtration_type > > filtration_list_to_spectra_request(std::vector< filtration_type > filtrations, std::vector< int > dims)
Definition: Complex.cpp:1021
~Complex()
Definition: Complex.hpp:71
void set_flipped(bool use_flipped)
Definition: Complex.hpp:104
void store_spectra_summary(std::vector< std::tuple< int, filtration_type, filtration_type, std::vector< spectra_type >>> spectra, std::string out_prefix)
Definition: Complex.cpp:944
std::vector< std::tuple< int, filtration_type, filtration_type, std::vector< spectra_type >, DenseMatrix_PL > > eigenpairs()
Definition: Complex.cpp:765
bool use_flipped
Compute the top-dimensional Laplacian's eigenvalues in spectra function via the eigenvalues of the sm...
Definition: Complex.hpp:40
void set_boundaries_filtrations(std::vector< Eigen::SparseMatrix< storage >> boundaries, std::vector< std::vector< filtration_type >> filtrations)
Definition: Complex.cpp:120
void get_L_top_dim_flipped(filtration_type a, SparseMatrix_PL &L)
Definition: Complex.cpp:268
std::pair< int, spectra_type > eigenvalues_summarize(std::vector< spectra_type > eigenvalues)
Definition: Complex.cpp:839
std::vector< std::tuple< int, filtration_type, filtration_type > > filtration_list_to_spectra_request_allpairs(std::vector< filtration_type > filtrations, std::vector< int > dims)
Definition: Complex.cpp:1056
std::vector< std::tuple< int, filtration_type, filtration_type, std::vector< spectra_type > > > spectra()
Definition: Complex.cpp:592
std::function< spectra_vec(DenseMatrix_PL &)> eigs_algorithm_func
Definition: Complex.hpp:42
petls::FilteredBoundaryMatrix< storage > dummy_d0()
Definition: Complex.cpp:1111
Definition: FilteredBoundaryMatrix.hpp:15
Definition: Complex.cpp:26
Definition: petls.hpp:38
void to_csv(std::string filename)
Definition: petls.cpp:136
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
double filtration_type
Definition: typedefs.hpp:24