Skip to content

Commit 3fbe634

Browse files
authored
Support zero! for StaticArrays (#262)
1 parent 3687e2c commit 3fbe634

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name = "ArrayLayouts"
22
uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "1.11.1"
4+
version = "1.11.2"
55

66
[deps]
77
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
8+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
89
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
910

1011
[weakdeps]
@@ -33,8 +34,7 @@ Quaternions = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0"
3334
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
3435
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
3536
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
36-
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
3737
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3838

3939
[targets]
40-
test = ["Aqua", "Infinities", "Quaternions", "Random", "StableRNGs", "SparseArrays", "StaticArrays", "Test"]
40+
test = ["Aqua", "Infinities", "Quaternions", "Random", "StableRNGs", "SparseArrays", "Test"]

src/ArrayLayouts.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ using LinearAlgebra.BLAS: BlasComplex, BlasFloat, BlasReal
2424
const AdjointQtype{T} = isdefined(LinearAlgebra, :AdjointQ) ? LinearAlgebra.AdjointQ{T} : Adjoint{T,<:AbstractQ}
2525

2626
using FillArrays: AbstractFill, axes_print_matrix_row, getindex_value
27+
using StaticArrays
2728

2829
using Base: require_one_based_indexing
2930

@@ -306,6 +307,8 @@ function zero!(_, A::AbstractArray{<:AbstractArray})
306307
A
307308
end
308309

310+
zero!(_, A::AbstractArray{<:SArray}) = fill!(A,zero(eltype(A)))
311+
309312
_norm(_, A, p) = invoke(norm, Tuple{Any,Real}, A, p)
310313
LinearAlgebra.norm(A::LayoutArray, p::Real=2) = _norm(MemoryLayout(A), A, p)
311314
LinearAlgebra.norm(A::SubArray{<:Any,N,<:LayoutArray}, p::Real=2) where N = _norm(MemoryLayout(A), A, p)

test/test_muladd.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module TestMulAdd
22

3-
using ArrayLayouts, FillArrays, Random, StableRNGs, LinearAlgebra, Test, Quaternions
3+
using ArrayLayouts, FillArrays, Random, StableRNGs, LinearAlgebra, Test, Quaternions, StaticArrays
44
using ArrayLayouts: DenseColumnMajor, AbstractStridedLayout, AbstractColumnMajor, DiagonalLayout, mul, Mul, zero!
55

66
Random.seed!(0)
77
@testset "Multiplication" begin
88
@testset "zero!" begin
9-
for A in (randn(5,5), [randn(5,5),randn(4,4)])
9+
for A in (randn(5,5), [randn(5,5),randn(4,4)], [SVector(2,3), SVector(3,4)])
1010
zero!(A)
1111
@test iszero(A)
1212
end

0 commit comments

Comments
 (0)