JuliaSmoothOptimizers / JuliaSmoothOptimizers/LimitedLDLFactorizations.jl
Support for Unitful sparse arrays? [feature request]
- Dominant language
- Julia
- Stars
- 25
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
The current code for `lldl` fails for Unitful sparse (or dense) arrays. MWE:
```julia
using SparseArrays: spdiagm
using LimitedLDLFactorizations: lldl
using Unitful: s
A = spdiagm(Float32.(1:3)*s^2) # unitful sparse array
lldl(A) # fails
ERROR: MethodError: no method matching lldl(::SparseArrays.SparseMatrixCSC{Unitful.Quantity{Float64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}, Int64}, ::Type{Unitful.Quantity{Float64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}})
Closest candidates are:
lldl(::SparseArrays.SparseMatrixCSC{Tv, Ti}; kwargs...) where {Tv<:Number, Ti<:Integer} at ~/.julia/packages/LimitedLDLFactorizations/usbOW/src/LimitedLDLFactorizations.jl:493
lldl(::SparseArrays.SparseMatrixCSC{Tv, Ti}, ::Type{Tf}; P, memory, droptol, α, α_increase_factor, check_tril) where {Tv<:Number, Ti<:Integer, Tf<:Real} at ~/.julia/packages/LimitedLDLFactorizations/usbOW/src/LimitedLDLFactorizations.jl:471
```
Some of the `lldl` code uses `Number` which is general enough to include unitful values, such as here:
https://github.com/JuliaSmoothOptimizers/LimitedLDLFactorizations.jl/blob/51eec8dae729b9c14486ae3465edb700fb2130aa/src/LimitedLDLFactorizations.jl#L493
but then just a bit deeper into the code the types get restricted to `Real`, like here:
https://github.com/JuliaSmoothOptimizers/LimitedLDLFactorizations.jl/blob/51eec8dae729b9c14486ae3465edb700fb2130aa/src/LimitedLDLFactorizations.jl#L480
I realize that `Number` is general enough to include complex number types and perhaps you don't want to support those? (Though that could be useful too, right?) My Unitful values are `reinterpret`able as real numbers, but currently not when stored in a sparse matrix: https://github.com/JuliaSparse/SparseArrays.jl/issues/289
I figure it's a long shot, but I thought I'd ask to see if there is any possibility of supporting more general `Number` types, especially Unitful values and maybe eventually complex values too? Since you have a pure Julia version, it seems like it would be possible!
Contributor guide
Assessment
This issue has not been assessed yet.