Skip to content

Commit 3c9a2bc

Browse files
committed
Tweak for empty case.
1 parent 73eb5bc commit 3c9a2bc

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/linalg.jl

+8-3
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,15 @@ end
217217
@inline dot(a::StaticVector, b::StaticVector) = _vecdot(same_size(a, b), a, b)
218218
@inline function _vecdot(::Size{S}, a::StaticArray, b::StaticArray) where {S}
219219
if prod(S) == 0
220-
return zero(promote_op(*, eltype(a), eltype(b)))
220+
za = zero(eltype(a))
221+
zb = zero(eltype(b))
222+
else
223+
# Use an actual element if there is one, to support e.g. Vector{<:Number}
224+
# element types for which runtime size information is required to construct
225+
# a zero element.
226+
za = zero(a[1])
227+
zb = zero(b[1])
221228
end
222-
za = zero(a[1])
223-
zb = zero(b[1])
224229
ret = adjoint(za) * zb + adjoint(za) * zb
225230
@inbounds @simd for j = 1 : prod(S)
226231
ret += adjoint(a[j]) * b[j]

0 commit comments

Comments
 (0)