Skip to content

Commit 5e501b7

Browse files
authored
Merge pull request #559 from marius311/master
make dot recursive like Base
2 parents 03b2ce8 + 60cb8cf commit 5e501b7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/linalg.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ end
228228
return :(zero(promote_op(*, eltype(a), eltype(b))))
229229
end
230230

231-
expr = :(conj(a[1]) * b[1])
231+
expr = :(adjoint(a[1]) * b[1])
232232
for j = 2:prod(S)
233-
expr = :($expr + conj(a[$j]) * b[$j])
233+
expr = :($expr + adjoint(a[$j]) * b[$j])
234234
end
235235

236236
return quote

test/linalg.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ using StaticArrays, Test, LinearAlgebra
116116
@test @inferred(dot(v1, -v2)) === -40
117117
@test @inferred(dot(v1*im, v2*im)) === 40*im*conj(im)
118118
@test @inferred(StaticArrays.bilinear_vecdot(v1*im, v2*im)) === 40*im*im
119+
# inner product, whether via `dot` or written out as `x'*y`, should be recursive like Base:
120+
@test @inferred(dot(@SVector[[1,2],[3,4]], @SVector[[1,2],[3,4]])) === 30
121+
@test @inferred(@SVector[[1,2],[3,4]]' * @SVector[[1,2],[3,4]]) === 30
122+
119123
end
120124

121125
@testset "transpose() and conj()" begin

0 commit comments

Comments
 (0)