Skip to content

Commit 83c8385

Browse files
authored
overload == (#73)
1 parent 47ec78a commit 83c8385

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/FillArrays.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using LinearAlgebra, SparseArrays
44
import Base: size, getindex, setindex!, IndexStyle, checkbounds, convert,
55
+, -, *, /, \, diff, sum, cumsum, maximum, minimum, sort, sort!,
66
any, all, axes, isone, iterate, unique, allunique, permutedims, inv,
7-
copy, vec, setindex!, count
7+
copy, vec, setindex!, count, ==
88

99
import LinearAlgebra: rank, svdvals!, tril, triu, tril!, triu!, diag, transpose, adjoint, fill!,
1010
norm2, norm1, normInf, normMinusInf, normp
@@ -17,6 +17,7 @@ export Zeros, Ones, Fill, Eye
1717

1818
abstract type AbstractFill{T, N, Axes} <: AbstractArray{T, N} end
1919

20+
==(a::AbstractFill, b::AbstractFill) = axes(a) == axes(b) && getindex_value(a) == getindex_value(b)
2021

2122
@inline function getindex(F::AbstractFill, k::Integer)
2223
@boundscheck checkbounds(F, k)

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,12 @@ end
286286
end
287287
end
288288

289+
@testset "==" begin
290+
@test Zeros(5,4) == Fill(0,5,4)
291+
@test Zeros(5,4) Zeros(3)
292+
@test Ones(5,4) == Fill(1,5,4)
293+
end
294+
289295
@testset "Rank" begin
290296
@test rank(Zeros(5,4)) == 0
291297
@test rank(Ones(5,4)) == 1

0 commit comments

Comments
 (0)