|
69 | 69 | @inline transpose(a::Adjoint{<:Any,<:Union{StaticVector,StaticMatrix}}) = conj(a.parent) |
70 | 70 | @inline transpose(a::Adjoint{<:Real,<:Union{StaticVector,StaticMatrix}}) = a.parent |
71 | 71 |
|
72 | | -@generated function _transpose(::Size{S}, m::StaticMatrix) where {S} |
73 | | - Snew = (S[2], S[1]) |
74 | | - |
75 | | - exprs = [:(transpose(m[$(LinearIndices(S)[j1, j2])])) for j2 = 1:S[2], j1 = 1:S[1]] |
76 | | - |
| 72 | +@generated function _transpose(::Size{S}, m::StaticMatrix{n1, n2, T}) where {n1, n2, S, T} |
| 73 | + exprs = [:(transpose(m[$(LinearIndices(S)[j1, j2])])) for j2 in 1:n2, j1 in 1:n1] |
77 | 74 | return quote |
78 | 75 | $(Expr(:meta, :inline)) |
79 | 76 | elements = tuple($(exprs...)) |
80 | | - @inbounds return similar_type($m, eltype(elements), Size($Snew))(elements) |
| 77 | + @inbounds return similar_type($m, Base.promote_op(transpose, T), Size($(n2,n1)))(elements) |
81 | 78 | end |
82 | 79 | end |
83 | 80 |
|
|
86 | 83 | @inline adjoint(a::Transpose{<:Real,<:Union{StaticVector,StaticMatrix}}) = a.parent |
87 | 84 | @inline adjoint(a::Adjoint{<:Any,<:Union{StaticVector,StaticMatrix}}) = a.parent |
88 | 85 |
|
89 | | -@generated function _adjoint(::Size{S}, m::StaticMatrix) where {S} |
90 | | - Snew = (S[2], S[1]) |
91 | | - |
92 | | - exprs = [:(adjoint(m[$(LinearIndices(S)[j1, j2])])) for j2 = 1:S[2], j1 = 1:S[1]] |
93 | | - |
| 86 | +@generated function _adjoint(::Size{S}, m::StaticMatrix{n1, n2, T}) where {n1, n2, S, T} |
| 87 | + exprs = [:(adjoint(m[$(LinearIndices(S)[j1, j2])])) for j2 in 1:n2, j1 in 1:n1] |
94 | 88 | return quote |
95 | 89 | $(Expr(:meta, :inline)) |
96 | 90 | elements = tuple($(exprs...)) |
97 | | - @inbounds return similar_type($m, eltype(elements), Size($Snew))(elements) |
| 91 | + @inbounds return similar_type($m, Base.promote_op(adjoint, T), Size($(n2,n1)))(elements) |
98 | 92 | end |
99 | 93 | end |
100 | 94 |
|
|
0 commit comments