Skip to content

[LINEAR SOLVERS] Add multi-RHS Solve(A, X, B) implementation and tests for Eigen-based direct linear solvers#14263

Open
juancamarotti wants to merge 2 commits intomasterfrom
linear-solvers/add_matrix_rhs_solve_eigen_direct_solver
Open

[LINEAR SOLVERS] Add multi-RHS Solve(A, X, B) implementation and tests for Eigen-based direct linear solvers#14263
juancamarotti wants to merge 2 commits intomasterfrom
linear-solvers/add_matrix_rhs_solve_eigen_direct_solver

Conversation

@juancamarotti
Copy link
Contributor

Description

This PR adds support for solving linear systems with multiple right-hand sides in the Eigen-based direct linear solvers by implementing the interface

Solve(A, X, B)

where B is a dense matrix containing several RHS vectors and X is the corresponding solution matrix.

Previously, the test suite only verified the vector version of the interface:

Solve(A, x, b)

while the matrix-RHS overload was not covered by tests. This PR implements the multi-RHS solve by looping over the columns of B, solving each system, and storing the corresponding solution in the columns of X.

In addition, new tests are introduced to verify the correct behavior of this interface. The tests reuse the existing MatrixMarket test matrix (A.mm) already used in the current solver tests.


Motivation

Some applications require solving linear systems with several RHS while the LHS does not change. This interface allows reusing the same solver infrastructure for such cases while keeping compatibility with the existing vector-based API.


Changes

  • Implemented the Solve(A, X, B) interface for Eigen-based linear solvers.
  • Added tests for the matrix RHS case.

Tests added

The following tests were added:

  • test_EigenSparseLU_MatrixRHS
  • test_EigenSparseQR_MatrixRHS
  • test_EigenPardisoLU_MatrixRHS
  • test_EigenPardisoLDLT_MatrixRHS

These tests solve a system with multiple RHS and verify the result by checking that A * X reproduces the original matrix B.

Tests for MKL-based solvers (Pardiso) are conditionally executed depending on whether Kratos was compiled with MKL support, following the existing pattern in the test suite.

@juancamarotti juancamarotti self-assigned this Mar 7, 2026
@juancamarotti juancamarotti requested review from a team as code owners March 7, 2026 10:23
@juancamarotti juancamarotti changed the title Linear solvers/add matrix rhs solve eigen direct solver [LINEAR SOLVERS] Add multi-RHS Solve(A, X, B) implementation and tests for Eigen-based direct linear solvers Mar 7, 2026
@AlejandroCornejo
Copy link
Member

@RiccardoRossi nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants