From 8124731387cd7b7621367e665f133544a6956a96 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Tue, 26 Dec 2023 16:52:04 +0530 Subject: [PATCH] Restrict LinearAlgebra.onedefined to concrete number types --- stdlib/LinearAlgebra/src/LinearAlgebra.jl | 2 +- stdlib/LinearAlgebra/test/bidiag.jl | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/stdlib/LinearAlgebra/src/LinearAlgebra.jl b/stdlib/LinearAlgebra/src/LinearAlgebra.jl index 10cc9a2f3459a..6f6a69c603756 100644 --- a/stdlib/LinearAlgebra/src/LinearAlgebra.jl +++ b/stdlib/LinearAlgebra/src/LinearAlgebra.jl @@ -528,7 +528,7 @@ _droplast!(A) = deleteat!(A, lastindex(A)) # but we are actually asking for oneunit(T), that is, however, defined for generic T as # `T(one(T))`, so the question is equivalent for whether one(T) is defined onedefined(::Type) = false -onedefined(::Type{<:Number}) = true +onedefined(::Type{T}) where {T<:Number} = isconcretetype(T) # initialize return array for op(A, B) _init_eltype(::typeof(*), ::Type{TA}, ::Type{TB}) where {TA,TB} = diff --git a/stdlib/LinearAlgebra/test/bidiag.jl b/stdlib/LinearAlgebra/test/bidiag.jl index 1c50e1114967e..ca9aaf1300dae 100644 --- a/stdlib/LinearAlgebra/test/bidiag.jl +++ b/stdlib/LinearAlgebra/test/bidiag.jl @@ -861,4 +861,11 @@ end @test axes(B) === (ax, ax) end +@testset "abstract eltype" begin + A = Bidiagonal{Number}(ones(4), ones(3)*im, :U); + B = Bidiagonal{ComplexF64}(ones(4), ones(3)*im, :U); + v = ones(4) + @test A \ v == B \ v +end + end # module TestBidiagonal