Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StaticArrays support #768

Merged
merged 2 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think :FieldArray is also a valid subtype of StaticVector

julia> subtypes(StaticVector)
5-element Vector{Any}:
 FieldArray{Tuple{N}, T, 1} where {N, T}
 MArray{Tuple{N}, T, 1} where {N, T}
 SArray{Tuple{N}, T, 1} where {N, T}
 SizedArray{Tuple{N}, T, 1, M} where {N, T, M}
 StaticArrays.SUnitRange

Copy link

@gdalle gdalle Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if we could add :ComponentArray that would solve all my immediate problems 🙏

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
Copy link

@gdalle gdalle Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to also test other array formats like FillArrays? Test dependencies are basically free

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will do that with another PR.

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