Skip to content

Commit

Permalink
StaticArrays support
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Aug 8, 2023
1 parent 88f518b commit 804d10c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,15 @@ steps:
Pkg.instantiate()
include("test/gpu/metal.jl")'
timeout_in_minutes: 30

- label: "CPUs -- StaticArrays.jl"
plugins:
- JuliaCI/julia#v1:
version: 1.9
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("StaticArrays")
Pkg.instantiate()
include("test/test_extensions.jl")'
timeout_in_minutes: 30
4 changes: 2 additions & 2 deletions src/krylov_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ function ktypeof(v::S) where S <: DenseVector
end

function ktypeof(v::S) where S <: AbstractVector
if S.name.name == :Zeros || S.name.name == :Ones
if S.name.name == :Zeros || S.name.name == :Ones || S.name.name == :SArray || S.name.name || :MArray
T = eltype(S)
return Vector{T} # FillArrays
return Vector{T} # FillArrays, StaticArrays
else
return S # BlockArrays, PartitionedArrays, etc...
end
Expand Down
21 changes: 21 additions & 0 deletions test/test_extensions.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using LinearAlgebra, SparseArrays, Test
using Krylov, StaticArrays

@testset "StaticArrays" begin
n = 2
m = 3

for T in (Float32, Float64)
A = rand(Float32, n, n)
b = SVector{n}(rand(Float32, n))
@test Krylov.ktypeof(b) == Vector{T}
x, stats = gmres(A, b)
@test stats.solved

A = rand(Float64, m, m)
b = MVector{m}(rand(Float64, m))
@test Krylov.ktypeof(b) == Vector{T}
x, stats = gmres(A, b)
@test stats.solved
end
end

0 comments on commit 804d10c

Please sign in to comment.