4 #include "../typedefs.hpp"
15 template<
typename FBMcoeff =
int>
24 std::vector<filtration_type> domain_filtrations;
25 std::vector<filtration_type> range_filtrations;
26 Eigen::SparseMatrix<FBMcoeff, Eigen::ColMajor> matrix;
38 std::vector<filtration_type> _domain_filtrations,
39 std::vector<filtration_type> _range_filtrations){
41 domain_filtrations = _domain_filtrations;
42 range_filtrations = _range_filtrations;
43 num_rows = _range_filtrations.size();
44 num_cols = _domain_filtrations.size();
82 if (use_domain_filtrations){
83 filtration_size = domain_filtrations.size();
84 while (index < filtration_size && domain_filtrations[index] <= a){
88 filtration_size = range_filtrations.size();
89 while (index < filtration_size && range_filtrations[index] <= a){
100 matrix.makeCompressed();
101 for(SparseMatrix_PL::InnerIterator it(matrix,col_index); it; ++it){
102 assert(it.value() != 0);
103 low_index = it.index();
116 M = matrix.block(0,0,row_index+1,col_index+1);
120 std::tuple<SparseMatrix_PL,SparseMatrix_PL,std::vector<int>,
int>
reduce(
int a_row_index,
int b_row_index,
int b_col_index){
121 int lower_num_rows = b_row_index - a_row_index;
123 SparseMatrix_PL working_boundary = matrix.block(0,0,b_row_index+1,b_col_index+1).template cast<coefficient_type>();
126 SparseMatrix_PL lower_working_boundary = working_boundary.block(a_row_index+1,0,lower_num_rows,b_col_index+1);
130 augmented.setIdentity();
134 std::vector<int> lows(b_col_index+1);
135 std::vector<int> zero_cols;
136 if (lower_num_rows == 0){
137 return std::make_tuple(working_boundary, augmented,zero_cols,a_row_index);
139 assert(lower_num_rows > 0);
143 for (
unsigned long int col_index = 0; col_index <= (
unsigned long int) b_col_index; col_index++){
145 bool unique_pivot =
false;
147 while (!unique_pivot){
148 current_low =
get_low(lower_working_boundary,col_index);
149 if (current_low == -1){
150 lows[col_index] = current_low;
151 zero_cols.push_back(col_index);
156 coefficient_type pivot_val = lower_working_boundary.coeffRef(current_low,col_index);
158 for(
unsigned long int left_col_index = 0; left_col_index < col_index; left_col_index++){
159 if (lows[left_col_index] == current_low){
160 coefficient_type conflicting_pivot = lower_working_boundary.coeffRef(lows[left_col_index],left_col_index);
165 augmented.col(col_index) = (augmented.col(col_index) - scale_factor * augmented.col(left_col_index)).pruned(
PRUNE_CONSTANT);
167 lower_working_boundary.col(col_index) = (lower_working_boundary.col(col_index) - scale_factor * lower_working_boundary.col(left_col_index)).pruned(
PRUNE_CONSTANT);
168 unique_pivot =
false;
174 lows[col_index] = current_low;
176 return std::make_tuple(working_boundary, augmented,zero_cols,a_row_index);
190 for (
unsigned long int i = 0; i < range_filtrations.size(); i++){
191 std::cout << range_filtrations[i] <<
",";
201 for (
unsigned long int i = 0; i < domain_filtrations.size(); i++){
202 std::cout << domain_filtrations[i] <<
",";
210 Eigen::IOFormat HeavyFmt(Eigen::FullPrecision, 0,
", ",
";\n",
"[",
"]",
"[",
"]");
211 std::cout << Eigen::Matrix<FBMcoeff,Eigen::Dynamic, Eigen::Dynamic>(matrix).format(HeavyFmt) <<std::endl;
Definition: FilteredBoundaryMatrix.hpp:16
FilteredBoundaryMatrix(Eigen::SparseMatrix< FBMcoeff, Eigen::ColMajor > _matrix, std::vector< filtration_type > _domain_filtrations, std::vector< filtration_type > _range_filtrations)
Definition: FilteredBoundaryMatrix.hpp:37
void print()
Definition: FilteredBoundaryMatrix.hpp:209
FilteredBoundaryMatrix transpose()
Definition: FilteredBoundaryMatrix.hpp:68
void print_range_filtration()
Definition: FilteredBoundaryMatrix.hpp:188
void submatrix_at_filtration(filtration_type a, Eigen::SparseMatrix< FBMcoeff, Eigen::ColMajor > &M)
Definition: FilteredBoundaryMatrix.hpp:113
void print_domain_filtration()
Definition: FilteredBoundaryMatrix.hpp:199
int get_low(SparseMatrix_PL &matrix, int col_index)
Definition: FilteredBoundaryMatrix.hpp:97
std::vector< filtration_type > get_domain_filtrations()
Definition: FilteredBoundaryMatrix.hpp:54
std::vector< filtration_type > get_range_filtrations()
Definition: FilteredBoundaryMatrix.hpp:59
int index_of_filtration(bool use_domain_filtrations, filtration_type a)
Definition: FilteredBoundaryMatrix.hpp:79
std::tuple< SparseMatrix_PL, SparseMatrix_PL, std::vector< int >, int > reduce(int a_row_index, int b_row_index, int b_col_index)
Definition: FilteredBoundaryMatrix.hpp:120
Definition: PersistentLaplacians.cpp:7
float coefficient_type
Definition: typedefs.hpp:13
#define PRUNE_CONSTANT
Definition: typedefs.hpp:40
Eigen::SparseMatrix< coefficient_type, Eigen::ColMajor > SparseMatrix_PL
Definition: typedefs.hpp:23
double filtration_type
Definition: typedefs.hpp:34