Skip to content

Add LDLt factorization for HMatrix and use it in the local DDM solvers - #90

Merged
PierreMarchand20 merged 1 commit into
mainfrom
add_ldlt_factorization
Oct 6, 2026
Merged

PierreMarchand20 merged 1 commit into
mainfrom
add_ldlt_factorization

Conversation

@PierreMarchand20

Copy link
Copy Markdown
Member

Bunch-Kaufman LDLt for symmetric (real or complex) and Hermitian matrices, dense and hierarchical, selected by a symmetry of 'S' or 'H' (real 'H' falls back to the symmetric routines).

Dense (matrix/linalg/factorization.hpp):

  • ldlt_factorization/ldlt_solve wrapping sytrf/sytrs and hetrf/hetrs.
  • triangular_ldlt_matrix_matrix_solve: solve with the unit L/U, Bunch-Kaufman permutations included, transa in N/T/C like trsm.
  • apply_ldlt_diagonal: D or D^-1 on the left or right, the 2x2 inverse in sytrs/hetrs's scaled form. A full solve is L^-1, D^-1, L^-T.
  • Blas::geru/gerc (BLAS has no plain complex ger).

HMatrix:

  • Block-recursive ldlt_factorization storing the unit L in place and D at the dense diagonal leaves: W = A21 L11^-T, L21 = W D1^-1, A22 -= L21 W^T. UPLO='U' eliminates the last cluster first.
  • ldlt_solve, internal_triangular_ldlt_hmatrix_{hmatrix,matrix,lrmat}_solve and apply_ldlt_diagonal.hpp (keeps the compression of the blocks D is applied to, densifying with a warning only below the dense leaves).

Local DDM solvers:

  • is_positive_definite option (default false) in LocalHMatrixSolver, LocalHMatrixPlusOverlapSolver, make_DDM_solver_w_custom_local_solver and DDMSolverBuilder. Symmetric/Hermitian local HMatrices now use LDLt unless declared positive definite, since Cholesky silently gave a wrong factorization for indefinite matrices. Complex symmetric always uses LDLt.

Fixes:

  • HMatrix cholesky_factorization's symmetry check compared UPLO and could never trigger; LU/Cholesky checks now live in the public functions dispatching on the execution policy.
  • potrf and sytrf/hetrf failures (info > 0) are now reported.

Tests: dense and HMatrix LDLt factorization and triangular solves, including 2x2 pivots, and Test_local_hmatrix_solvers checking both local solvers against the assembled system.

@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.91857% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.30%. Comparing base (658d8f0) to head (990ccde).
⚠️ Report is 68 commits behind head on main.

Files with missing lines Patch % Lines
...x/linalg/triangular_ldlt_hmatrix_hmatrix_solve.hpp 99.04% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #90      +/-   ##
==========================================
+ Coverage   97.19%   98.30%   +1.10%     
==========================================
  Files          80      188     +108     
  Lines        5132    11194    +6062     
==========================================
+ Hits         4988    11004    +6016     
- Misses        144      190      +46     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PierreMarchand20
PierreMarchand20 force-pushed the add_ldlt_factorization branch 3 times, most recently from 76619a1 to 996cf95 Compare October 1, 2026 16:22
Bunch-Kaufman LDLt for symmetric (real or complex) and Hermitian
matrices, dense and hierarchical, selected by a symmetry of 'S' or 'H'
(real 'H' falls back to the symmetric routines).

Dense (matrix/linalg/factorization.hpp):
- ldlt_factorization/ldlt_solve wrapping sytrf/sytrs and hetrf/hetrs.
- triangular_ldlt_matrix_matrix_solve: solve with the unit L/U,
  Bunch-Kaufman permutations included, transa in N/T/C like trsm.
- apply_ldlt_diagonal: D^-1 on the left or right, the 2x2 inverse in
  sytrs/hetrs's scaled form. A full solve is L^-1, D^-1, L^-T.
- Blas::geru/gerc (BLAS has no plain complex ger).

HMatrix:
- Block-recursive ldlt_factorization storing the unit L in place and D
  at the dense diagonal leaves: W = A21 L11^-T, L21 = W D1^-1,
  A22 -= L21 W^T. UPLO='U' eliminates the last cluster first.
- ldlt_solve, internal_triangular_ldlt_hmatrix_{hmatrix,matrix,lrmat}_solve
  and apply_ldlt_diagonal.hpp (keeps the compression of the blocks D is
  applied to, densifying with a warning only below the dense leaves).

Local DDM solvers:
- is_positive_definite option (default false) in LocalHMatrixSolver,
  LocalHMatrixPlusOverlapSolver, make_DDM_solver_w_custom_local_solver
  and DDMSolverBuilder. Symmetric/Hermitian local HMatrices now use LDLt
  unless declared positive definite, since Cholesky silently gave a
  wrong factorization for indefinite matrices. Complex symmetric always
  uses LDLt.

Fixes:
- HMatrix cholesky_factorization's symmetry check compared UPLO and
  could never trigger; LU/Cholesky checks now live in the public
  functions dispatching on the execution policy.
- potrf and sytrf/hetrf failures (info > 0) are now reported.

Tests: dense and HMatrix LDLt factorization and triangular solves,
including 2x2 pivots, and Test_local_hmatrix_solvers checking both local
solvers against the assembled system.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PierreMarchand20
PierreMarchand20 merged commit 0ee4cac into main Oct 6, 2026
11 checks passed
@PierreMarchand20
PierreMarchand20 deleted the add_ldlt_factorization branch October 6, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant