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 84990dd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
14 changes: 14 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,17 @@ steps:
Pkg.instantiate()
include("test/gpu/metal.jl")'
timeout_in_minutes: 30

- label: "CPUs -- StaticArrays.jl"
plugins:
- JuliaCI/julia#v1:
version: 1.9
agents:
queue: "juliaecosystem"
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 || S.name.name == :SizedArray
T = eltype(S)
return Vector{T} # FillArrays
return Vector{T} # FillArrays, StaticArrays
else
return S # BlockArrays, PartitionedArrays, etc...
end
Expand Down
25 changes: 25 additions & 0 deletions test/test_extensions.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using LinearAlgebra, SparseArrays, Test
using Krylov, StaticArrays

@testset "StaticArrays" begin
n = 5

for T in (Float32, Float64)
A = rand(T, n, n)

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

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

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

0 comments on commit 84990dd

Please sign in to comment.