Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "FillArrays"
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
version = "0.13.5"
version = "0.13.6"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
2 changes: 1 addition & 1 deletion src/FillArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Base: size, getindex, setindex!, IndexStyle, checkbounds, convert,
+, -, *, /, \, diff, sum, cumsum, maximum, minimum, sort, sort!,
any, all, axes, isone, iterate, unique, allunique, permutedims, inv,
copy, vec, setindex!, count, ==, reshape, _throw_dmrs, map, zero,
show, view, in, mapreduce, one
show, view, in, mapreduce, one, reverse

import LinearAlgebra: rank, svdvals!, tril, triu, tril!, triu!, diag, transpose, adjoint, fill!,
dot, norm2, norm1, normInf, normMinusInf, normp, lmul!, rmul!, diagzero, AbstractTriangular, AdjointAbsVec, TransposeAbsVec,
Expand Down
7 changes: 7 additions & 0 deletions src/fillalgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ function permutedims(B::AbstractFill, perm)
fillsimilar(B, dimsP)
end

function reverse(A::AbstractFill, start::Integer=firstindex(A), stop::Integer=lastindex(A))
checkbounds(A, start)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use @propagate_inbounds and @boundscheck ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good idea

checkbounds(A, stop)
A
end
reverse(A::AbstractFill; dims=:) = A

## Algebraic identities


Expand Down
10 changes: 10 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,16 @@ end
@test permutedims(Fill(2.0,2,4,5), [3,2,1]) ≡ Fill(2.0,5,4,2)
end

@testset "reverse" begin
for A in (Zeros{Int}(6), Ones(2,3), Fill("abc", 2, 3, 4))
@test reverse(A) == reverse(Array(A))
@test reverse(A, dims=1) == reverse(Array(A), dims=1)
end
A = Ones{Int}(6)
@test reverse(A, 2, 4) == reverse(Array(A), 2, 4)
@test_throws BoundsError reverse(A, 1, 10)
end

@testset "setindex!/fill!" begin
F = Fill(1,10)
@test (F[1] = 1) == 1
Expand Down