Skip to content

Commit 0095ad8

Browse files
authored
Merge pull request #399 from marius311/rectrans
make transpose and ctranspose recursive like Base
2 parents eaca0da + 6b48aaf commit 0095ad8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/linalg.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ end
6666
@generated function _transpose(::Size{S}, m::StaticMatrix) where {S}
6767
Snew = (S[2], S[1])
6868

69-
exprs = [:(m[$(LinearIndices(S)[j1, j2])]) for j2 = 1:S[2], j1 = 1:S[1]]
69+
exprs = [:(transpose(m[$(LinearIndices(S)[j1, j2])])) for j2 = 1:S[2], j1 = 1:S[1]]
7070

7171
return quote
7272
$(Expr(:meta, :inline))
@@ -84,7 +84,7 @@ end
8484
@generated function _adjoint(::Size{S}, m::StaticMatrix) where {S}
8585
Snew = (S[2], S[1])
8686

87-
exprs = [:(conj(m[$(LinearIndices(S)[j1, j2])])) for j2 = 1:S[2], j1 = 1:S[1]]
87+
exprs = [:(adjoint(m[$(LinearIndices(S)[j1, j2])])) for j2 = 1:S[2], j1 = 1:S[1]]
8888

8989
return quote
9090
$(Expr(:meta, :inline))

test/linalg.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ using StaticArrays, Compat.Test
121121
@test @inferred(adjoint(@SMatrix([1 2; 0 3]))) === @SMatrix([1 0; 2 3])
122122
@test @inferred(adjoint(@SMatrix([1 2 3; 4 5 6]))) === @SMatrix([1 4; 2 5; 3 6])
123123
@test @inferred(adjoint(@SMatrix([1 2*im 3; 4 5 6]))) === @SMatrix([1 4; -2*im 5; 3 6])
124+
125+
m = [1 2; 3 4] + im*[5 6; 7 8]
126+
@test @inferred(adjoint(@SVector [m,m])) == ctranspose([m,m])
127+
@test @inferred(transpose(@SVector [m,m])) == transpose([m,m])
128+
@test @inferred(adjoint(@SMatrix [m m; m m])) == ctranspose([[m] [m]; [m] [m]])
129+
@test @inferred(transpose(@SMatrix [m m; m m])) == transpose([[m] [m]; [m] [m]])
130+
124131
end
125132

126133
@testset "vcat() and hcat()" begin

0 commit comments

Comments
 (0)