Skip to content

Commit 6e882f4

Browse files
authored
FillArray interface for views, adjoints, and transpose (#123)
1 parent d88461b commit 6e882f4

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
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 = "0.10"
3+
version = "0.10.1"
44

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

src/FillArrays.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,4 +605,11 @@ end
605605

606606
Base.show(io::IO, ::MIME"text/plain", x::Union{Eye,AbstractFill}) = show(io, x)
607607

608+
##
609+
# interface
610+
##
611+
612+
getindex_value(a::LinearAlgebra.AdjOrTrans) = getindex_value(parent(a))
613+
getindex_value(a::SubArray) = getindex_value(parent(a))
614+
608615
end # module

test/runtests.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,3 +1138,20 @@ end
11381138
@test_throws BoundsError setindex!(ones(3), zeros(3), Trues(2))
11391139
@test_throws DimensionMismatch setindex!(ones(2), zeros(3), Trues(2))
11401140
end
1141+
1142+
@testset "FillArray interface" begin
1143+
@testset "views" begin
1144+
a = Fill(2.0,5)
1145+
v = view(a,1:2)
1146+
@test FillArrays.getindex_value(v) == FillArrays.unique_value(v) == 2.0
1147+
@test convert(Fill, v) Fill(2.0,2)
1148+
end
1149+
1150+
@testset "adjtrans" begin
1151+
a = Fill(2.0,5)
1152+
@test FillArrays.getindex_value(a') == FillArrays.unique_value(a') == 2.0
1153+
@test convert(Fill, a') Fill(2.0,1,5)
1154+
@test FillArrays.getindex_value(transpose(a)) == FillArrays.unique_value(transpose(a)) == 2.0
1155+
@test convert(Fill, transpose(a)) Fill(2.0,1,5)
1156+
end
1157+
end

0 commit comments

Comments
 (0)