Skip to content

Commit 8b90b9c

Browse files
authored
Add zero(::Type{<:SDiagonal}) (#905)
* Add zero(::Type{<:SDiagonal}) * version bump to v1.1.3
1 parent 9a9ddac commit 8b90b9c

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-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 = "StaticArrays"
22
uuid = "90137ffa-7385-5640-81b9-e52037218182"
3-
version = "1.1.2"
3+
version = "1.1.3"
44

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

src/SDiagonal.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ one(::Type{SDiagonal{N,T}}) where {N,T} = SDiagonal(ones(SVector{N,T}))
3939
one(::SDiagonal{N,T}) where {N,T} = SDiagonal(ones(SVector{N,T}))
4040

4141
Base.zero(::SDiagonal{N,T}) where {N,T} = SDiagonal(zeros(SVector{N,T}))
42+
Base.zero(::Type{SDiagonal{N,T}}) where {N,T} = SDiagonal(zeros(SVector{N,T}))
4243

4344
function LinearAlgebra.cholesky(D::SDiagonal)
4445
any(x -> x < 0, D.diag) && throw(LinearAlgebra.PosDefException(1))

test/SDiagonal.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,8 @@ using StaticArrays, Test, LinearAlgebra
111111
@test m*SMatrix{4,4}(Matrix{Float64}(I, 4, 4)) == m
112112
@test SMatrix{4,4}(Matrix{Float64}(I, 4, 4))/m == diagm(0 => [11; 12; 13; 14].\[1; 1; 1; 1])
113113
@test m\SMatrix{4,4}(Matrix{Float64}(I, 4, 4)) == diagm(0 => [11; 12; 13; 14].\[1; 1; 1; 1])
114+
115+
@test m + zero(m) == m
116+
@test m + zero(typeof(m)) == m
114117
end
115118
end

0 commit comments

Comments
 (0)