Skip to content

Commit 561005d

Browse files
committed
Fix inference on adjoint operations (fixes #546)
1 parent cf87ee2 commit 561005d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/abstractarray.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Base.axes(s::StaticArray) = _axes(Size(s))
1313
@pure function _axes(::Size{sizes}) where {sizes}
1414
map(SOneTo, sizes)
1515
end
16+
Base.axes(rv::Adjoint{<:Any,<:StaticVector}) = (SOneTo(1), axes(rv.parent)...)
17+
Base.axes(rv::Transpose{<:Any,<:StaticVector}) = (SOneTo(1), axes(rv.parent)...)
1618

1719
function Base.summary(io::IO, a, inds::Tuple{SOneTo, Vararg{SOneTo}})
1820
print(io, Base.dims2string(length.(inds)), " ")

test/broadcast.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ end
4949
@test @inferred(v .- m) === @SMatrix [0 -1; 1 0]
5050
@test @inferred(m .^ v) === @SMatrix [1 2; 81 256]
5151
@test @inferred(v .^ m) === @SMatrix [1 1; 64 256]
52+
# Issue #546
53+
@test @inferred(m ./ (v .* v')) === @SMatrix [1.0 0.5; 0.75 0.25]
54+
testinf(m, v) = m ./ (v .* v')
55+
@test @inferred(testinf(m, v)) === @SMatrix [1.0 0.5; 0.75 0.25]
5256
end
5357

5458
@testset "2x2 StaticMatrix with 1x2 StaticMatrix" begin

0 commit comments

Comments
 (0)