Skip to content

Commit 477f2b9

Browse files
authored
permutedims for BroadcastArray (#227)
1 parent b16122f commit 477f2b9

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "LazyArrays"
22
uuid = "5078a376-72f3-5289-bfd5-ec5146d43c02"
3-
version = "0.22.14"
3+
version = "0.22.15"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/lazybroadcasting.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,4 +391,6 @@ for op in (:*, :\, :/)
391391
getindex(A::BroadcastMatrix{<:Any,typeof($op),<:Tuple{AbstractVector,AbstractMatrix}}, ::Colon, j::Integer) = broadcast($op, A.args[1], A.args[2][:,j])
392392
getindex(A::BroadcastMatrix{<:Any,typeof($op),<:Tuple{AbstractMatrix,AbstractVector}}, ::Colon, j::Integer) = broadcast($op, A.args[1][:,j], A.args[2])
393393
end
394-
end
394+
end
395+
396+
permutedims(A::BroadcastArray{T}) where T = BroadcastArray{T}(A.f, map(_permutedims,A.args)...)

test/broadcasttests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,4 +339,13 @@ import Base: broadcasted
339339
@test rowsupport(A, 3) == 3:5
340340
end
341341
end
342+
343+
@testset "permutedims" begin
344+
A = BroadcastArray(exp, randn(5,5) .+ im)
345+
@test permutedims(A) transpose(A)
346+
B = BroadcastArray(+, randn(5,5) .+ im, 1)
347+
@test permutedims(B) transpose(B)
348+
C = BroadcastArray(+, randn(5,5) .+ im, randn(5))
349+
@test permutedims(C) transpose(C)
350+
end
342351
end

0 commit comments

Comments
 (0)