Skip to content

cleanup support for Float32 and ComplexF32 #597

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

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/solvers/cholmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@
s = unsafe_load(ptr)
if s.xtype != xtyp(Tv)
free!(ptr)
throw(CHOLMODException("xtype=$(s.xtype) not supported"))
throw(CHOLMODException("xtype=$(xtyp(Tv)) not supported"))

Check warning on line 273 in src/solvers/cholmod.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/cholmod.jl#L273

Added line #L273 was not covered by tests
elseif s.dtype != dtyp(Tv)
free!(ptr)
throw(CHOLMODException("dtype=$(s.dtype) not supported"))
throw(CHOLMODException("dtype=$(dtyp(Tv)) not supported"))

Check warning on line 276 in src/solvers/cholmod.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/cholmod.jl#L276

Added line #L276 was not covered by tests
end
obj = new(ptr)
finalizer(free!, obj)
Expand All @@ -294,10 +294,10 @@
throw(CHOLMODException("Ti=$Ti does not match s.itype=$(s.itype)"))
elseif s.xtype != xtyp(Tv)
free!(ptr, Ti)
throw(CHOLMODException("xtype=$(s.xtype) not supported"))
throw(CHOLMODException("xtype=$(xtyp(Tv)) not supported"))

Check warning on line 297 in src/solvers/cholmod.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/cholmod.jl#L297

Added line #L297 was not covered by tests
elseif s.dtype != dtyp(Tv)
free!(ptr, Ti)
throw(CHOLMODException("dtype=$(s.dtype) not supported"))
throw(CHOLMODException("dtype=$(dtyp(Tv)) not supported"))

Check warning on line 300 in src/solvers/cholmod.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/cholmod.jl#L300

Added line #L300 was not covered by tests
end
A = new(ptr)
finalizer(free!, A)
Expand Down Expand Up @@ -337,10 +337,10 @@
throw(CHOLMODException("Ti=$Ti does not match s.itype=$(s.itype)"))
elseif s.xtype != xtyp(Tv) && s.xtype != CHOLMOD_PATTERN
free!(ptr, Ti)
throw(CHOLMODException("xtype=$(s.xtype) not supported"))
throw(CHOLMODException("xtype=$(xtyp(Tv)) not supported"))

Check warning on line 340 in src/solvers/cholmod.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/cholmod.jl#L340

Added line #L340 was not covered by tests
elseif s.dtype != dtyp(Tv)
free!(ptr, Ti)
throw(CHOLMODException("dtype=$(s.dtype) not supported"))
throw(CHOLMODException("dtype=$(dtyp(Tv)) not supported"))

Check warning on line 343 in src/solvers/cholmod.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/cholmod.jl#L343

Added line #L343 was not covered by tests
end
F = new(ptr)
if register_finalizer
Expand Down
8 changes: 4 additions & 4 deletions src/solvers/spqr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ function LinearAlgebra.qr(A::SparseMatrixCSC{Tv, Ti}; tol=_default_tol(A), order
nonzeros(R_)),
p, hpinv)
end
LinearAlgebra.qr(A::SparseMatrixCSC{<:Union{Float16,Float32}}; tol=_default_tol(A)) =
qr(convert(SparseMatrixCSC{Float64}, A); tol=tol)
LinearAlgebra.qr(A::SparseMatrixCSC{<:Union{ComplexF16,ComplexF32}}; tol=_default_tol(A)) =
qr(convert(SparseMatrixCSC{ComplexF64}, A); tol=tol)
LinearAlgebra.qr(A::SparseMatrixCSC{Float16}; tol=_default_tol(A)) =
qr(convert(SparseMatrixCSC{Float32}, A); tol=tol)
LinearAlgebra.qr(A::SparseMatrixCSC{ComplexF16}; tol=_default_tol(A)) =
qr(convert(SparseMatrixCSC{ComplexF32}, A); tol=tol)
LinearAlgebra.qr(A::Union{SparseMatrixCSC{T},SparseMatrixCSC{Complex{T}}};
tol=_default_tol(A)) where {T<:AbstractFloat} =
throw(ArgumentError(string("matrix type ", typeof(A), "not supported. ",
Expand Down
8 changes: 7 additions & 1 deletion test/spqr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,18 @@ end
@test (F.Q*F.R)::SparseMatrixCSC == A[F.prow,F.pcol]
end

@testset "Issue #585 for element type: $eltyA" for eltyA in (Float64, Float32)
@testset "Issue #585 for element type: $eltyA" for eltyA in (Float64, Float32, ComplexF64, ComplexF32)
A = sparse(eltyA[1 0; 0 1])
F = qr(A)
@test eltype(F.Q) == eltype(F.R) == eltyA
end

@testset "Complementing issue #585 for element type: $eltyA" for (eltyA, eltyB) in [(Float16, Float32), (ComplexF16, ComplexF32)]
A = sparse(eltyA[1 0; 0 1])
F = qr(A)
@test eltype(F.Q) == eltype(F.R) == eltyB
end

@testset "select ordering overdetermined" begin
A = sparse([1:n; rand(1:m, nn - n)], [1:n; rand(1:n, nn - n)], randn(nn), m, n)
b = randn(m)
Expand Down
Loading