Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anigmetov committed Dec 12, 2024
1 parent cad05cb commit fce3e71
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 31 deletions.
17 changes: 0 additions & 17 deletions examples/oineus_v_opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#include <random>

#include <oineus/oineus.h>
#include <taskflow/taskflow.hpp>
#include <taskflow/core/flow_builder.hpp>
#include <taskflow/algorithm/for_each.hpp>
#include <opts/opts.h>

using namespace oineus;
Expand Down Expand Up @@ -119,20 +116,6 @@ int main(int argc, char** argv)
auto fil = grid.freudenthal_filtration(top_d, negate, params.n_threads);
VRUDecomposition<Int> rv { fil, false };

{
tf::Executor executor;
tf::Taskflow taskflow;
oineus::Filtration<oineus::Simplex<Int>, Real> fil1;
oineus::HelperFilCallable<oineus::Simplex<Int>, Real> aa(&fil1);
std::vector<Int> bb(10000);
tf::Task task1 = taskflow.for_each(bb.begin(), bb.end(), [] (auto& i) { i = 100; });
// tf::Task t1 = taskflow.for_each_index<Int, Int, Int, oineus::HelperFilCallable<oineus::Simplex<Int>, Real>> (Int(0), Int(0), Int(1), aa);
// tf::Task t2 = taskflow.for_each_index(Int(0), Int(0), Int(1), [](Int i) { std::cout << i << std::endl; });
executor.run(taskflow);
executor.wait_for_all();

}
//
spd::info("Matrix read");

fname_dgm = fname_in + "_t_" + std::to_string(params.n_threads) + "_c_" + std::to_string(params.chunk_size);
Expand Down
23 changes: 14 additions & 9 deletions include/oineus/decomposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ namespace oineus {
if (verbose) std::cerr << "V sorted" << std::endl;

// U is sorted
if (not are_matrix_columns_sorted(u_data_t)) {
if (has_matrix_u() and not are_matrix_columns_sorted(u_data_t)) {
std::cerr << "sanity_check: U not sorted!" << std::endl;
return false;
}
Expand Down Expand Up @@ -526,20 +526,25 @@ namespace oineus {
}
if (verbose) std::cerr << "V upper-triangular" << std::endl;

if (not uu.is_upper_triangular()) {
if (has_matrix_u() and not uu.is_upper_triangular()) {
std::cerr << "U not upper-triangular" << std::endl;
return false;
}
if (verbose) std::cerr << "U upper-triangular" << std::endl;

if (dv != rr) {
std::cerr << "R = " << rr << std::endl;
std::cerr << "D = " << dd << std::endl;
std::cerr << "V = " << vv << std::endl;
std::cerr << "U = " << uu << std::endl;
std::cerr << "R != DV" << std::endl;
return false;
dv.compute_cols();

for(size_t i = 0; i < rr.n_cols(); ++ i) {
if (not rr.is_col_zero(i) and rr.col(i) != dv.col(i)) {
std::cerr << "R = " << rr << std::endl;
std::cerr << "D = " << dd << std::endl;
std::cerr << "V = " << vv << std::endl;
std::cerr << "U = " << uu << std::endl;
std::cerr << "R != DV" << std::endl;
return false;
}
}

if (verbose) std::cerr << "R = DV" << std::endl;


Expand Down
2 changes: 2 additions & 0 deletions include/oineus/sparse_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <algorithm>
#include <atomic>

#include "profile.h"

namespace oineus {

template<class Int>
Expand Down
10 changes: 5 additions & 5 deletions include/oineus/vietoris_rips.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ namespace oineus {

// vertices are added manually to preserve order (id == index)
for(Int v = 0; v < static_cast<Int>(points.size()); ++v) {
auto [simplex, edge] = vr_simplex_with_edge<Int, Real>(points, {v});
auto [simplex, edge] = vr_simplex_with_edge<Int, Real, D>(points, {v});
simplices.emplace_back(simplex);
edges.emplace_back(edge);
}
Expand Down Expand Up @@ -392,7 +392,7 @@ namespace oineus {
std::vector<VREdge<Int>> edges;

for(size_t v_idx = 0; v_idx < points.size(); ++v_idx) {
std::vector<size_t> vertices {v_idx};
std::vector<Int> vertices {v_idx};
auto [simplex, edge] = vr_simplex_with_edge<Int, Real, D>(points, vertices);
simplices.emplace_back(simplex);
edges.emplace_back(edge);
Expand All @@ -401,7 +401,7 @@ namespace oineus {
if (max_dim >= 1)
for(size_t u_idx = 0; u_idx < points.size(); ++u_idx)
for(size_t v_idx = u_idx + 1; v_idx < points.size(); ++v_idx) {
auto [s, e] = vr_simplex_with_edge<Int, Real, D>(points, {u_idx, v_idx});
auto [s, e] = vr_simplex_with_edge<Int, Real, D>(points, {(Int)u_idx, (Int)v_idx});
if (s.get_value() <= max_diameter) {
simplices.emplace_back(s);
edges.emplace_back(e);
Expand All @@ -412,7 +412,7 @@ namespace oineus {
for(size_t u_idx = 0; u_idx < points.size(); ++u_idx)
for(size_t v_idx = u_idx + 1; v_idx < points.size(); ++v_idx)
for(size_t w_idx = v_idx + 1; w_idx < points.size(); ++w_idx) {
auto [s, e] = vr_simplex_with_edge<Int, Real, D>(points, {u_idx, v_idx, w_idx});
auto [s, e] = vr_simplex_with_edge<Int, Real, D>(points, {(Int)u_idx, (Int)v_idx, (Int)w_idx});
if (s.get_value() <= max_diameter) {
simplices.emplace_back(s);
edges.emplace_back(e);
Expand All @@ -424,7 +424,7 @@ namespace oineus {
for(size_t v_idx = u_idx + 1; v_idx < points.size(); ++v_idx)
for(size_t w_idx = v_idx + 1; w_idx < points.size(); ++w_idx)
for(size_t t_idx = w_idx + 1; t_idx < points.size(); ++t_idx) {
auto [s, e] = vr_simplex_with_edge<Int, Real, D>(points, {u_idx, v_idx, w_idx, t_idx});
auto [s, e] = vr_simplex_with_edge<Int, Real, D>(points, {(Int)u_idx, (Int)v_idx, (Int)w_idx, (Int)t_idx});
if (s.get_value() <= max_diameter) {
simplices.emplace_back(s);
edges.emplace_back(e);
Expand Down
1 change: 1 addition & 0 deletions tests/tests_reduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ decltype(auto) compute_diagrams_and_v_ls_freudenthal(const typename oineus::Grid
params.sort_dgms = false;
params.clearing_opt = false;
params.n_threads = n_threads;
params.compute_v = true;
if (n_threads == 1)
params.compute_u = true;

Expand Down

0 comments on commit fce3e71

Please sign in to comment.