Skip to content
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
2 changes: 1 addition & 1 deletion src/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ function dot(x::AbstractVector, B::Bidiagonal, y::AbstractVector)
nx, ny = length(x), length(y)
(nx == size(B, 1) == ny) || throw(DimensionMismatch())
if nx ≤ 1
nx == 0 && return dot(zero(eltype(x)), zero(eltype(B)), zero(eltype(y)))
nx == 0 && return zero(dot(zero(eltype(x)), zero(eltype(B)), zero(eltype(y))))
return dot(x[1], B.dv[1], y[1])
end
ev, dv = B.ev, B.dv
Expand Down
2 changes: 2 additions & 0 deletions src/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,8 @@ dot(x, A, y) = dot(x, A*y) # generic fallback for cases that are not covered by

function dot(x::AbstractVector, A::AbstractMatrix, y::AbstractVector)
(axes(x)..., axes(y)...) == axes(A) || throw(DimensionMismatch())
# outermost zero call to avoid spurious sign ambiguity (like 0.0 - 0.0im)
any(isempty, (x, y)) && return zero(dot(zero(eltype(x)), zero(eltype(A)), zero(eltype(y))))
T = typeof(dot(first(x), first(A), first(y)))
s = zero(T)
i₁ = first(eachindex(x))
Expand Down
2 changes: 1 addition & 1 deletion src/hessenberg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ function dot(x::AbstractVector, H::UpperHessenberg, y::AbstractVector)
m = size(H, 1)
(length(x) == m == length(y)) || throw(DimensionMismatch())
if iszero(m)
return dot(zero(eltype(x)), zero(eltype(H)), zero(eltype(y)))
return zero(dot(zero(eltype(x)), zero(eltype(H)), zero(eltype(y))))
end
x₁ = x[1]
r = dot(x₁, H[1,1], y[1])
Expand Down
1 change: 1 addition & 0 deletions src/symmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ function dot(x::AbstractVector, A::HermOrSym, y::AbstractVector)
require_one_based_indexing(x, y)
n = length(x)
(n == length(y) == size(A, 1)) || throw(DimensionMismatch())
iszero(n) && return zero(dot(zero(eltype(x)), zero(eltype(A)), zero(eltype(y))))
data = A.data
s = dot(first(x), first(A), first(y))
r = zero(s+s)
Expand Down
8 changes: 4 additions & 4 deletions src/triangular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ function dot(x::AbstractVector, A::UpperTriangular, y::AbstractVector)
m = size(A, 1)
(length(x) == m == length(y)) || throw(DimensionMismatch())
if iszero(m)
return dot(zero(eltype(x)), zero(eltype(A)), zero(eltype(y)))
return zero(dot(zero(eltype(x)), zero(eltype(A)), zero(eltype(y))))
end
x₁ = x[1]
r = dot(x₁, A[1,1], y[1])
Expand All @@ -914,7 +914,7 @@ function dot(x::AbstractVector, A::UnitUpperTriangular, y::AbstractVector)
m = size(A, 1)
(length(x) == m == length(y)) || throw(DimensionMismatch())
if iszero(m)
return dot(zero(eltype(x)), zero(eltype(A)), zero(eltype(y)))
return zero(dot(zero(eltype(x)), zero(eltype(A)), zero(eltype(y))))
end
x₁ = first(x)
r = dot(x₁, y[1])
Expand All @@ -936,7 +936,7 @@ function dot(x::AbstractVector, A::LowerTriangular, y::AbstractVector)
m = size(A, 1)
(length(x) == m == length(y)) || throw(DimensionMismatch())
if iszero(m)
return dot(zero(eltype(x)), zero(eltype(A)), zero(eltype(y)))
return zero(dot(zero(eltype(x)), zero(eltype(A)), zero(eltype(y))))
end
r = zero(typeof(dot(first(x), first(A), first(y))))
@inbounds for j in axes(A, 2)
Expand All @@ -956,7 +956,7 @@ function dot(x::AbstractVector, A::UnitLowerTriangular, y::AbstractVector)
m = size(A, 1)
(length(x) == m == length(y)) || throw(DimensionMismatch())
if iszero(m)
return dot(zero(eltype(x)), zero(eltype(A)), zero(eltype(y)))
return zero(dot(zero(eltype(x)), zero(eltype(A)), zero(eltype(y))))
end
r = zero(typeof(dot(first(x), first(y))))
@inbounds for j in axes(A, 2)
Expand Down
4 changes: 2 additions & 2 deletions src/tridiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function dot(x::AbstractVector, S::SymTridiagonal, y::AbstractVector)
nx, ny = length(x), length(y)
(nx == size(S, 1) == ny) || throw(DimensionMismatch("dot"))
if nx ≤ 1
nx == 0 && return dot(zero(eltype(x)), zero(eltype(S)), zero(eltype(y)))
nx == 0 && return zero(dot(zero(eltype(x)), zero(eltype(S)), zero(eltype(y))))
return dot(x[1], S.dv[1], y[1])
end
dv, ev = S.dv, S.ev
Expand Down Expand Up @@ -1022,7 +1022,7 @@ function dot(x::AbstractVector, A::Tridiagonal, y::AbstractVector)
nx, ny = length(x), length(y)
(nx == size(A, 1) == ny) || throw(DimensionMismatch())
if nx ≤ 1
nx == 0 && return dot(zero(eltype(x)), zero(eltype(A)), zero(eltype(y)))
nx == 0 && return zero(dot(zero(eltype(x)), zero(eltype(A)), zero(eltype(y))))
return dot(x[1], A.d[1], y[1])
end
@inbounds begin
Expand Down
4 changes: 4 additions & 0 deletions test/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,10 @@ end
@test dot(x, B', y) ≈ dot(B*x, y)
elty <: Real && @test dot(x, transpose(B), y) ≈ dot(x, transpose(B)*y)
end
for (m, n) in ((0, 0), (1, 0), (0, 1))
v = zeros(ComplexF64, m); a = zeros(ComplexF64, m, n); w = zeros(Float64, n)
@test dot(v, a, w) === zero(ComplexF64)
end
end

@testset "condskeel #34512" begin
Expand Down