Clarify what sparse(F.LD) returns in the ldlt docstring - #774
Open
ViralBShah wants to merge 1 commit into
Open
Conversation
`F.LD` behaves as two different matrices depending on how it is used: as an operator `F.LD \ b` solves with the product `L*D`, matching the `PtL`/`UP` naming, but `sparse(F.LD)` returns CHOLMOD's packed LDL' factor -- `L` with its unit diagonal overwritten by `diag(D)`. So `F.LD \ b` and `sparse(F.LD) \ b` are different operations, and next to `F.PtL == P'*L` the name reads as the product. Document both meanings, and replace the vague "can be reconstructed from `sparse(F.LD)` and `F.p`" with the actual recipe for unpacking `L` and `D`. Fixes #725. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L8HenXTVrASo1sBZVGhpDQ
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #774 +/- ##
=======================================
Coverage 84.19% 84.19%
=======================================
Files 13 13
Lines 9403 9403
=======================================
Hits 7917 7917
Misses 1486 1486 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #725.
F.LDmeans two different matrices depending on how you use it:F.LD \ bL*D(cholmod_solvewithCHOLMOD_LD)sparse(F.LD)LDL'factor —Lwith its unit diagonal overwritten bydiag(D)so
F.LD \ bandsparse(F.LD) \ bare different operations:The docstring said only that "the
LDcomponent can be materialized as asparse matrix using
sparse(F.LD)", mentioning neither the packed layout northe divergence from
F.LD \ b. Sitting next toF.PtL=P'*LandF.UP=L'*P, which really are products,LDreads asL*D.The internals already rely on the packed convention:
sparse(::Factor)callsgetLd!onsparse(F.LD), which readsdoff the diagonal and writes1back into it to recover
L.This documents both meanings and replaces the vague "can be reconstructed from
sparse(F.LD)andF.pif needed" with the actual recipe. The snippet isverified on a 200×200 problem:
diag(LD) == diag(F),Lcomes back as aSparseMatrixCSC, andL*D*L' == A[F.p, F.p].Docstring change only — no behavior change. Two alternatives I did not take:
F.LDas an operator is consistentwith
PtL/UP; onlysparseexposes the packed form, and changing eitherwould break code.
sparse(F.LD)returnL*D. As the reporter notes,Lisunrecoverable from
L*DwhenDhas a zero diagonal entry, andsparse(::Factor)depends on the packed layout. The packed form is strictlymore informative — it just needed documenting.
🤖 Generated with Claude Code
https://claude.ai/code/session_01L8HenXTVrASo1sBZVGhpDQ