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

Restrict LinearAlgebra.onedefined to concrete number types #52632

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/LinearAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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} =
Expand Down
7 changes: 7 additions & 0 deletions stdlib/LinearAlgebra/test/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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