Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing definition for (\)(::SuiteSparse.CHOLMOD.Factor{Float64}, StridedVector{<:Complex}) #120

Open
jondeuce opened this issue Apr 9, 2019 · 3 comments

Comments

@jondeuce
Copy link

jondeuce commented Apr 9, 2019

The following errors for cholesky factorizations:

julia> using LinearAlgebra, SparseArrays
julia> A = cholesky(sparse(Matrix(I,10,10))); # sparse cholesky factorization with real elements
julia> z = rand(ComplexF64, 10); # complex RHS vector
julia> A\@views(z[:])
ERROR: InexactError: Float64(0.868342583034311 + 0.07242770884885896im)
Stacktrace:
 [1] Type at ./complex.jl:37 [inlined]
 [2] convert at ./number.jl:7 [inlined]
 [3] unsafe_store! at ./pointer.jl:118 [inlined]
 [4] SuiteSparse.CHOLMOD.Dense{Float64}(::SubArray{Complex{Float64},1,Array{Complex{Float64},1},Tuple{Base.Slice{Base.OneTo{Int64}}},true}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/SuiteSparse/src/cholmod.jl:802
 [5] \(::SuiteSparse.CHOLMOD.Factor{Float64}, ::SubArray{Complex{Float64},1,Array{Complex{Float64},1},Tuple{Base.Slice{Base.OneTo{Int64}}},true}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/SuiteSparse/src/cholmod.jl:1682
 [6] top-level scope at none:0

while the same operation works without the view:

julia> isapprox(A\z, z)
true

I've chased the issue down to being a simple missing definition in SuiteSparse, where we have the following (in cholmod.jl):

(\)(L::Factor{T}, B::Vector{Complex{T}}) where {T<:Float64} = complex.(L\real(B), L\imag(B))
(\)(L::Factor{T}, B::Matrix{Complex{T}}) where {T<:Float64} = complex.(L\real(B), L\imag(B))
(\)(L::Factor{T}, b::StridedVector) where {T<:VTypes} = Vector(L\Dense{T}(b))
(\)(L::Factor{T}, B::StridedMatrix) where {T<:VTypes} = Matrix(L\Dense{T}(B))

So, the analogous definitions for complex StridedVectors and StridedMatrixs are missing. I can submit the PR to base myself, but I wanted to open an issue first in case there is a reason they aren't defined.

@jondeuce
Copy link
Author

jondeuce commented Apr 9, 2019

Also, this does seem to work for other factorizations, e.g. lu:

julia> B = lu(sparse(Matrix(I,10,10)));
julia> isapprox(B\@views(z[:]), z)
true

My julia version info is following, in case it's relevant:

julia> versioninfo()
Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: AMD Phenom(tm) II X6 1100T Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, amdfam10)
Environment:
  JULIA_NUM_THREADS = 24
  JULIA_EDITOR = code

@ViralBShah ViralBShah transferred this issue from JuliaLang/julia May 19, 2021
@rayegun rayegun transferred this issue from JuliaSparse/SuiteSparse.jl Jun 7, 2022
@ViralBShah
Copy link
Member

Nice to have a PR here.

@rayegun
Copy link
Member

rayegun commented Jan 11, 2024

I believe CHOLMOD can handle strides, I'll look

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

No branches or pull requests

3 participants