Skip to content

Commit cf8c78d

Browse files
authored
Fix recursive adjoint/transpose (#322)
* fix recursive adjoint/transpose * Bump version to v1.9.2
1 parent 6c3d030 commit cf8c78d

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "FillArrays"
22
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
3-
version = "1.9.1"
3+
version = "1.9.2"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/fillalgebra.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ vec(a::AbstractFill) = fillsimilar(a, length(a))
66
# cannot do this for vectors since that would destroy scalar dot product
77

88

9-
transpose(a::Union{AbstractOnesMatrix, AbstractZerosMatrix}) = fillsimilar(a, reverse(axes(a)))
10-
adjoint(a::Union{AbstractOnesMatrix, AbstractZerosMatrix}) = fillsimilar(a, reverse(axes(a)))
11-
transpose(a::FillMatrix{T}) where T = Fill{T}(transpose(a.value), reverse(a.axes))
12-
adjoint(a::FillMatrix{T}) where T = Fill{T}(adjoint(a.value), reverse(a.axes))
9+
for OP in (:transpose, :adjoint)
10+
@eval begin
11+
function $OP(a::AbstractZerosMatrix)
12+
v = getindex_value(a)
13+
T = typeof($OP(v))
14+
Zeros{T}(reverse(axes(a)))
15+
end
16+
$OP(a::AbstractOnesMatrix) = fillsimilar(a, reverse(axes(a)))
17+
$OP(a::FillMatrix) = Fill($OP(a.value), reverse(a.axes))
18+
end
19+
end
1320

1421
permutedims(a::AbstractFillVector) = fillsimilar(a, (1, length(a)))
1522
permutedims(a::AbstractFillMatrix) = fillsimilar(a, reverse(a.axes))

test/runtests.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,19 @@ end
13941394
@test permutedims(Ones(2,4,5), [3,2,1]) Ones(5,4,2)
13951395
@test permutedims(Zeros(2,4,5), [3,2,1]) Zeros(5,4,2)
13961396
@test permutedims(Fill(2.0,2,4,5), [3,2,1]) Fill(2.0,5,4,2)
1397+
1398+
@testset "recursive" begin
1399+
S = SMatrix{2,3}(1:6)
1400+
Z = Zeros(typeof(S), 2, 3)
1401+
Y = zeros(typeof(S), 2, 3)
1402+
@test Z' == Y'
1403+
@test transpose(Z) == transpose(Y)
1404+
1405+
F = Fill(S, 2, 3)
1406+
G = fill(S, 2, 3)
1407+
@test F' == G'
1408+
@test transpose(F) == transpose(G)
1409+
end
13971410
end
13981411

13991412
@testset "reverse" begin

0 commit comments

Comments
 (0)