Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
teseoch committed Oct 12, 2023
1 parent c9e0868 commit 99e7eef
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_linear_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> A;
const bool ok = loadMarket(A, path + "/A_2.mat");
REQUIRE(ok);

static std::shared_ptr<spdlog::logger> 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;
Expand Down Expand Up @@ -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: "<<x<<std::endl;
Expand Down

0 comments on commit 99e7eef

Please sign in to comment.