Skip to content

Commit

Permalink
Support and test complex instance types
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Oct 29, 2023
1 parent b3a3246 commit 2215344
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ArrayInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ Returns an instance of the SVD factorization object with the correct type
cheaply.
"""
function svd_instance(A::Matrix{T}) where {T}
LinearAlgebra.SVD(zeros(T,0,0),zeros(T,0),zeros(T,0,0))
LinearAlgebra.SVD(zeros(T,0,0),zeros(real(T),0),zeros(T,0,0))
end

"""
Expand Down
8 changes: 5 additions & 3 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,18 @@ end
end

@testset "linearalgebra instances" begin
for A in [rand(2,2), rand(Float32,2,2), rand(BigFloat,2,2)]
for A in [rand(2,2), rand(Float32,2,2), rand(BigFloat,2,2), rand(ComplexF32,2,2), rand(ComplexF64,2,2)]

@test ArrayInterface.lu_instance(A) isa typeof(lu(A))
@test ArrayInterface.qr_instance(A) isa typeof(qr(A))

if !(eltype(A) <: BigFloat)
@test ArrayInterface.bunchkaufman_instance(A' * A) isa typeof(bunchkaufman(A' * A))
@test ArrayInterface.cholesky_instance(A' * A) isa typeof(cholesky(A' * A))
@test ArrayInterface.ldlt_instance(SymTridiagonal(A' * A)) isa typeof(ldlt(SymTridiagonal(A' * A)))
@test ArrayInterface.svd_instance(A) isa typeof(svd(A))
if !(eltype(A) <: Union{ComplexF16,ComplexF32,ComplexF64})
@test ArrayInterface.bunchkaufman_instance(A' * A) isa typeof(bunchkaufman(A' * A))
@test ArrayInterface.ldlt_instance(SymTridiagonal(A' * A)) isa typeof(ldlt(SymTridiagonal(A' * A)))
end
end
end

Expand Down

0 comments on commit 2215344

Please sign in to comment.