Skip to content

Only accept the types that libklu provides - #60

Open
ViralBShah wants to merge 1 commit into
mainfrom
klu-only-supported-types
Open

ViralBShah wants to merge 1 commit into
mainfrom
klu-only-supported-types

Conversation

@ViralBShah

@ViralBShah ViralBShah commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

libklu provides Float64 and ComplexF64 values with Int32 and Int64 indices. KLU.jl converted other values and right-hand sides, so what looked like support for a type was a hidden conversion. This allows only what the library provides. Because this is breaking, it sets the version to 0.7.0.

Breaking changes

Call Before Now
klu with Float16, Float32, BigFloat, ComplexF32, Complex{Int} or other converted values Converts to 64-bit MethodError
klu! with values of another type Converts to 64-bit MethodError
klu!(K, S) where S has another index type Works MethodError
klu or KLUFactorization with Int32 colptr and Int64 rowval Converts in the constructor, or MethodError from klu MethodError
ldiv!(K, B) with a real K and complex B Solves real and imaginary parts separately MethodError
K \ B where B has another element type, such as Float32, Int, or real with a complex K Converts, returns 64-bit ArgumentError
ldiv!(Y, K, B) where Y or B has another element type Converts ArgumentError

All of these apply to K' and transpose(K) as well. Callers convert first, for example klu(Float64.(A)) or K \ Float64.(b).

\ and the three-argument ldiv! throw ArgumentError rather than MethodError because LinearAlgebra's generic methods would otherwise accept and convert these, so KLU.jl needs its own methods to reject them.

K \ B still accepts any array of the right element type, such as a non-strided view, and copies it.

Testing

On Apple silicon macOS, the test suite passes on Julia 1.12.7 and 1.13.3, and Aqua and the docs build pass on 1.12.7. Linux and Windows are left to CI.

🤖 Generated with Claude Code

@ViralBShah
ViralBShah force-pushed the klu-owns-vectors-julia-1.12 branch from 575be64 to 260e88d Compare October 31, 2026 14:58
Base automatically changed from klu-owns-vectors-julia-1.12 to main October 31, 2026 19:15
@ViralBShah

ViralBShah commented Oct 31, 2026 •

Copy link
Copy Markdown
Member Author

@rayegun @luke-kiernan What are your thoughts on this direction? We can either convert for all the types or just provide support for only the types that are provided by KLU.

libklu provides Float64 and ComplexF64 values with Int32 and Int64 indices. KLU.jl converted other
values, and solved real and complex right-hand sides of any type by copying and splitting them,
so what looked like support for a type was a hidden conversion.

klu, klu!, and the KLUFactorization constructor now accept only those combinations, with the same
index type for colptr and rowval, and klu! a matrix with the same value and index types as the
factorization. Anything else is a MethodError.

Right-hand sides must have the same element type as the factorization. ldiv! and solve! had no
methods for most other types already, and now have none for a real factorization with complex
right-hand sides. The generic methods of \ and the three-argument ldiv! in LinearAlgebra convert
them, so these have methods which throw an ArgumentError.

This is breaking, so set the version to 0.7.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ViralBShah
ViralBShah force-pushed the klu-only-supported-types branch from 6211bc6 to 1344d8f Compare November 1, 2026 03:34
@codecov

codecov Bot commented Nov 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.19%. Comparing base (857e0e0) to head (1344d8f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #60      +/-   ##
==========================================
- Coverage   97.29%   97.19%   -0.11%     
==========================================
  Files           1        1              
  Lines         407      392      -15     
==========================================
- Hits          396      381      -15     
  Misses         11       11              

☔ 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.

This branch has not been deployed

No deployments
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