diff --git a/Project.toml b/Project.toml index de927e29..245580c7 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/FillArrays.jl b/src/FillArrays.jl index 22320d3c..759708de 100644 --- a/src/FillArrays.jl +++ b/src/FillArrays.jl @@ -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, diff --git a/src/fillalgebra.jl b/src/fillalgebra.jl index 86a70a99..adb393e5 100644 --- a/src/fillalgebra.jl +++ b/src/fillalgebra.jl @@ -26,6 +26,13 @@ function permutedims(B::AbstractFill, perm) fillsimilar(B, dimsP) end +Base.@propagate_inbounds function reverse(A::AbstractFill, start::Integer, stop::Integer=lastindex(A)) + @boundscheck checkbounds(A, start) + @boundscheck checkbounds(A, stop) + A +end +reverse(A::AbstractFill; dims=:) = A + ## Algebraic identities diff --git a/test/runtests.jl b/test/runtests.jl index b690a390..2ec0d025 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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