From 2215344309dc5fe41bddfba6c9f55104f60d582f Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 29 Oct 2023 07:39:04 -0400 Subject: [PATCH] Support and test complex instance types --- src/ArrayInterface.jl | 2 +- test/core.jl | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index cb1c91bb..5297a87e 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -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 """ diff --git a/test/core.jl b/test/core.jl index bd0cd6cf..bf9b0712 100644 --- a/test/core.jl +++ b/test/core.jl @@ -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