Conversation
- pdmat.jl: `quad`/`invquad` were specialized on `PDMat{<:Real,<:Vector}`,
but the second type parameter of `PDMat` is the type of the wrapped matrix
(`<:AbstractMatrix`), so this signature is never satisfied and the
specializations were never used. The generic fallbacks ran instead,
materializing the full `chol_upper(a) * x` product. Use `<:Matrix`, restoring
the reduced-allocation implementation.
- pdsparsemat.jl: `\` and `/` unnecessarily required the operand element type to
match the matrix's. Relax to `AbstractVecOrMat{<:Real}` and promote the result.
- generics.jl: remove the self-recursive `*(a::AbstractPDMat, c::Real) = a * c`,
a stack-overflow trap for custom `AbstractPDMat` subtypes.
- scalmat.jl: define `Matrix{T}` (like the other types) instead of the untyped
`Matrix`; the untyped form is provided by Base.
- test/typeparams.jl: regression tests. test/chol.jl: bound the `broken`
allocation marker to `< v"1.12"` (passes on Apple silicon with Julia 1.12).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #236 +/- ##
==========================================
+ Coverage 93.37% 94.78% +1.40%
==========================================
Files 11 11
Lines 800 805 +5
==========================================
+ Hits 747 763 +16
+ Misses 53 42 -11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| T = promote_type(eltype(a), eltype(x)) | ||
| return convert(Array{T}, a.chol \ convert(Array{Float64}, x)) | ||
| end | ||
| function /(x::AbstractVecOrMat{<:Real}, a::PDSparseMat) |
Member
There was a problem hiding this comment.
Coverage suggests that this one is not hit
Member
Author
There was a problem hiding this comment.
AFAICT this method has never worked and is explicitly disabled in the tests.
Member
Author
There was a problem hiding this comment.
I added a workaround for the non-existing / in SparseArrays in c814d22
The `chol.jl` allocation bound is unreliable on Apple: it is met on some
machines but exceeded on CI for the same Julia version, so a `broken`
marker either fails CI (exceeded) or errors locally (unexpectedly
passing). Skip the check on Apple (Julia >= 1.11.5) instead.
`/(::AbstractVecOrMat{<:Real}, ::PDSparseMat)` could never run: CHOLMOD
has no right division, so `x / a.chol` threw a MethodError, and every
test skipped the path (leaving it uncovered). Since `a` is symmetric,
`x / a == (a \ xᵀ)ᵀ`, so route through the existing left-division method
and enable the previously-skipped right-division tests for PDSparseMat.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
andreasnoack
approved these changes
Jun 25, 2026
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.
I noticed these (unrelated) bugs while updating #188:
quad/invquadspecializations forPDMatwere dispatched onPDMat{<:Real, <:Vector}. But the second type parameter ofPDMatis the type of the wrapped matrix (<:AbstractMatrix), so this signature can never be satisfied and the specializations were never used — instead the generic fallbacks, which materializechol_upper(a) * x, were called. Changing it to<:Matrixrestores the intended implementation: for ann×nmatrix and ann×kinput the specialization reuses a single length-nbuffer, so it allocatesO(n + k)instead of theO(n*k)temporary of the fallback.\and/forPDSparseMatunnecessarily required the element types of the matrix and the right-hand side to match. Since CHOLMOD only supportsFloat64/ComplexF64anyway, this excluded e.g. integer orFloat32inputs that the other types accept. I relaxed the signatures toAbstractVecOrMat{<:Real}and promote the element type of the result./(::AbstractVecOrMat, ::PDSparseMat)was in fact dead: CHOLMOD provides no right division, sox / a.cholalways threw aMethodError, and every test skipped the sparse right-division path (so it was also uncovered). Sinceais symmetric,x / a == (a \ xᵀ)ᵀ, so I route through the (working, covered) left-division method and enable the previously-skipped right-division tests forPDSparseMat.*(a::AbstractPDMat, c::Real) = a * cingenerics.jl. It is shadowed by the concrete methods of the built-in types but leads to aStackOverflowErrorfor otherAbstractPDMatsubtypes.Matrix{T}(::ScalMat)instead ofMatrix(::ScalMat)(the untyped constructor is provided byBase).Regression tests are added in
test/typeparams.jl.The allocation test in
test/chol.jlwas marked broken on Apple since Julia 1.11.5. The bound turns out to be unreliable there in a machine-dependent way: it is met on my Apple silicon machine (Julia 1.12.6) but exceeded on the CI Apple runner for the same version, so neither value of thebrokenmarker works for both (it errors as "unexpectedly passing" where it passes, and fails where it doesn't). I thereforeskipthe allocation check on Apple (Julia >= 1.11.5) instead. The marker only ever applied to Apple, so other CI configurations are unaffected.🤖 Generated with Claude Code