Skip to content

Commit

Permalink
Add tests with LinearOperators.jl (#863)
Browse files Browse the repository at this point in the history
* Add tests with LinearOperators.jl

* Update block_gmres for complex numbers

* Update block_gmres.jl
  • Loading branch information
amontoison authored May 20, 2024
1 parent b5bb89a commit 8ecc293
Show file tree
Hide file tree
Showing 3 changed files with 33 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 @@ -98,3 +98,17 @@ steps:
Pkg.instantiate()
include("test/cpu/component_arrays.jl")'
timeout_in_minutes: 30

- label: "CPUs -- LinearOperators.jl"
plugins:
- JuliaCI/julia#v1:
version: "1.10"
agents:
queue: "juliaecosystem"
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("LinearOperators")
Pkg.instantiate()
include("test/cpu/linear_operators.jl")'
timeout_in_minutes: 30
5 changes: 3 additions & 2 deletions src/block_gmres.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ kwargs_block_gmres = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rto
# Define the blocks D1 and D2
D1 = view(D, 1:p, :)
D2 = view(D, p+1:2p, :)
trans = FC <: AbstractFloat ? 'T' : 'C'

# Coefficients for mul!
α = -one(FC)
Expand Down Expand Up @@ -263,7 +264,7 @@ kwargs_block_gmres = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rto
for i = 1 : inner_iter-1
D1 .= R[nr+i]
D2 .= R[nr+i+1]
@kormqr!('L', 'T', H[i], τ[i], D)
@kormqr!('L', trans, H[i], τ[i], D)
R[nr+i] .= D1
R[nr+i+1] .= D2
end
Expand All @@ -276,7 +277,7 @@ kwargs_block_gmres = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rto
# Update Zₖ = (Qₖ)ᴴΓE₁ = (Λ₁, ..., Λₖ, Λbarₖ₊₁)
D1 .= Z[inner_iter]
D2 .= zero(FC)
@kormqr!('L', 'T', H[inner_iter], τ[inner_iter], D)
@kormqr!('L', trans, H[inner_iter], τ[inner_iter], D)
Z[inner_iter] .= D1

# Update residual norm estimate.
Expand Down
16 changes: 16 additions & 0 deletions test/cpu/linear_operators.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using LinearAlgebra, SparseArrays, Test
using Krylov, LinearOperators

@testset "LinearOperators" begin
n = 50
p = 5

for T in (Float64, ComplexF64)
A = rand(T, n, n)
B = rand(T, n, p)

opA = LinearOperator(A)
x, stats = block_gmres(opA, B)
@test stats.solved
end
end

0 comments on commit 8ecc293

Please sign in to comment.