From 99e7eefd6221d3c6d3d0f87e274b306c063d7bf0 Mon Sep 17 00:00:00 2001 From: Teseo Schneider Date: Thu, 12 Oct 2023 11:29:47 -0700 Subject: [PATCH] more tests --- tests/test_linear_solver.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/test_linear_solver.cpp b/tests/test_linear_solver.cpp index 0495612..065f290 100644 --- a/tests/test_linear_solver.cpp +++ b/tests/test_linear_solver.cpp @@ -74,6 +74,32 @@ TEST_CASE("jse", "[solver]") REQUIRE(err < 1e-8); } +TEST_CASE("multi-solver", "[solver]") +{ + const std::string path = POLYFEM_DATA_DIR; + Eigen::SparseMatrix A; + const bool ok = loadMarket(A, path + "/A_2.mat"); + REQUIRE(ok); + + static std::shared_ptr logger = spdlog::stdout_color_mt("test_logger"); + logger->set_level(spdlog::level::warn); + + json input = {}; + input["solver"] = {"Hypre", "Eigen::SimplicialLDLT"}; + auto solver = Solver::create(input, *logger); + Eigen::VectorXd b(A.rows()); + b.setRandom(); + Eigen::VectorXd x(b.size()); + x.setZero(); + + solver->analyze_pattern(A, A.rows()); + solver->factorize(A); + solver->solve(b, x); + const double err = (A * x - b).norm(); + INFO("solver: " + solver->name()); + REQUIRE(err < 1e-8); +} + TEST_CASE("all", "[solver]") { const std::string path = POLYFEM_DATA_DIR; @@ -108,6 +134,8 @@ TEST_CASE("all", "[solver]") solver->factorize(A); solver->solve(b, x); + REQUIRE(solver->name() == s); + // solver->get_info(solver_info); // std::cout<<"Solver error: "<