Skip to content

Commit b681ddd

Browse files
authored
Restore ± special cases (#227)
1 parent dc8aa6e commit b681ddd

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

Project.toml

+1-1
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.13.10"
3+
version = "0.13.11"
44

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

src/fillalgebra.jl

+5
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ function dot(u::AbstractVector{T}, D::Diagonal{U,<:Zeros}, v::AbstractVector{V})
212212
end
213213

214214
# Addition and Subtraction
215+
+(a::AbstractFill) = a
216+
-(a::Zeros) = a
217+
-(a::AbstractFill) = Fill(-getindex_value(a), size(a))
218+
219+
215220
function +(a::Zeros{T}, b::Zeros{V}) where {T, V} # for disambiguity
216221
promote_shape(a,b)
217222
return elconvert(promote_op(+,T,V),a)

test/runtests.jl

+8
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,14 @@ end
613613
@test zero(Ones(10,10)) == Zeros(10,10)
614614
@test zero(Fill(0.5, 10, 10)) == Zeros(10,10)
615615
end
616+
617+
@testset "Matrix ±" begin
618+
x = Fill([1,2], 5)
619+
z = Zeros{SVector{2,Int}}(5)
620+
@test +(z) -(z) z
621+
@test +(x) == x
622+
@test -(x) == Fill(-[1,2], 5)
623+
end
616624
end
617625

618626
@testset "maximum/minimum/svd/sort" begin

0 commit comments

Comments
 (0)