Skip to content

Commit

Permalink
Optimize the generic function solve!
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Jun 28, 2023
1 parent 0de0116 commit 4723b13
Show file tree
Hide file tree
Showing 36 changed files with 221 additions and 41 deletions.
1 change: 1 addition & 0 deletions src/Krylov.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ include("lnlq.jl")
include("craig.jl")
include("craigmr.jl")

include("krylov_solve.jl")
end
4 changes: 4 additions & 0 deletions src/bicgstab.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ See [`BicgstabSolver`](@ref) for more details about the `solver`.
"""
function bicgstab! end

def_args_bicgstab = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_bicgstab = (:(; c::AbstractVector{FC} = b ),
:(; M = I ),
:(; N = I ),
Expand All @@ -103,6 +106,7 @@ def_kwargs_bicgstab = (:(; c::AbstractVector{FC} = b ),

def_kwargs_bicgstab = mapreduce(extract_parameters, vcat, def_kwargs_bicgstab)

args_bicgstab = (:A, :b)
kwargs_bicgstab = (:c, :M, :N, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
4 changes: 4 additions & 0 deletions src/bilq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ See [`BilqSolver`](@ref) for more details about the `solver`.
"""
function bilq! end

def_args_bilq = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_bilq = (:(; c::AbstractVector{FC} = b ),
:(; transfer_to_bicg::Bool = true),
:(; atol::T = eps(T) ),
Expand All @@ -88,6 +91,7 @@ def_kwargs_bilq = (:(; c::AbstractVector{FC} = b ),

def_kwargs_bilq = mapreduce(extract_parameters, vcat, def_kwargs_bilq)

args_bilq = (:A, :b)
kwargs_bilq = (:c, :transfer_to_bicg, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
5 changes: 5 additions & 0 deletions src/bilqr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ See [`BilqrSolver`](@ref) for more details about the `solver`.
"""
function bilqr! end

def_args_bilqr = (:(A ),
:(b::AbstractVector{FC}),
:(c::AbstractVector{FC}))

def_kwargs_bilqr = (:(; transfer_to_bicg::Bool = true),
:(; atol::T = eps(T) ),
:(; rtol::T = eps(T) ),
Expand All @@ -92,6 +96,7 @@ def_kwargs_bilqr = (:(; transfer_to_bicg::Bool = true),

def_kwargs_bilqr = mapreduce(extract_parameters, vcat, def_kwargs_bilqr)

args_bilqr = (:A, :b, :c)
kwargs_bilqr = (:transfer_to_bicg, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
4 changes: 4 additions & 0 deletions src/cg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ See [`CgSolver`](@ref) for more details about the `solver`.
"""
function cg! end

def_args_cg = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_cg = (:(; M = I ),
:(; ldiv::Bool = false ),
:(; radius::T = zero(T) ),
Expand All @@ -95,6 +98,7 @@ def_kwargs_cg = (:(; M = I ),

def_kwargs_cg = mapreduce(extract_parameters, vcat, def_kwargs_cg)

args_cg = (:A, :b)
kwargs_cg = (:M, :ldiv, :radius, :linesearch, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
4 changes: 4 additions & 0 deletions src/cg_lanczos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ See [`CgLanczosSolver`](@ref) for more details about the `solver`.
"""
function cg_lanczos! end

def_args_cg_lanczos = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_cg_lanczos = (:(; M = I ),
:(; ldiv::Bool = false ),
:(; check_curvature::Bool = false),
Expand All @@ -91,6 +94,7 @@ def_kwargs_cg_lanczos = (:(; M = I ),

def_kwargs_cg_lanczos = mapreduce(extract_parameters, vcat, def_kwargs_cg_lanczos)

args_cg_lanczos = (:A, :b)
kwargs_cg_lanczos = (:M, :ldiv, :check_curvature, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
5 changes: 5 additions & 0 deletions src/cg_lanczos_shift.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ See [`CgLanczosShiftSolver`](@ref) for more details about the `solver`.
"""
function cg_lanczos_shift! end

def_args_cg_lanczos_shift = (:(A ),
:(b::AbstractVector{FC} ),
:(shifts::AbstractVector{T}))

def_kwargs_cg_lanczos_shift = (:(; M = I ),
:(; ldiv::Bool = false ),
:(; check_curvature::Bool = false),
Expand All @@ -86,6 +90,7 @@ def_kwargs_cg_lanczos_shift = (:(; M = I ),

def_kwargs_cg_lanczos_shift = mapreduce(extract_parameters, vcat, def_kwargs_cg_lanczos_shift)

args_cg_lanczos_shift = (:A, :b, :shifts)
kwargs_cg_lanczos_shift = (:M, :ldiv, :check_curvature, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
4 changes: 4 additions & 0 deletions src/cgls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ See [`CglsSolver`](@ref) for more details about the `solver`.
"""
function cgls! end

def_args_cgls = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_cgls = (:(; M = I ),
:(; ldiv::Bool = false ),
:(; radius::T = zero(T) ),
Expand All @@ -110,6 +113,7 @@ def_kwargs_cgls = (:(; M = I ),

def_kwargs_cgls = mapreduce(extract_parameters, vcat, def_kwargs_cgls)

args_cgls = (:A, :b)
kwargs_cgls = (:M, :ldiv, :radius, , :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
4 changes: 4 additions & 0 deletions src/cgne.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ See [`CgneSolver`](@ref) for more details about the `solver`.
"""
function cgne! end

def_args_cgne = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_cgne = (:(; N = I ),
:(; ldiv::Bool = false ),
:(; λ::T = zero(T) ),
Expand All @@ -115,6 +118,7 @@ def_kwargs_cgne = (:(; N = I ),

def_kwargs_cgne = mapreduce(extract_parameters, vcat, def_kwargs_cgne)

args_cgne = (:A, :b)
kwargs_cgne = (:N, :ldiv, , :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
4 changes: 4 additions & 0 deletions src/cgs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ See [`CgsSolver`](@ref) for more details about the `solver`.
"""
function cgs! end

def_args_cgs = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_cgs = (:(; c::AbstractVector{FC} = b ),
:(; M = I ),
:(; N = I ),
Expand All @@ -104,6 +107,7 @@ def_kwargs_cgs = (:(; c::AbstractVector{FC} = b ),

def_kwargs_cgs = mapreduce(extract_parameters, vcat, def_kwargs_cgs)

args_cgs = (:A, :b)
kwargs_cgs = (:c, :M, :N, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
4 changes: 4 additions & 0 deletions src/cr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ See [`CrSolver`](@ref) for more details about the `solver`.
"""
function cr! end

def_args_cr = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_cr = (:(; M = I ),
:(; ldiv::Bool = false ),
:(; radius::T = zero(T) ),
Expand All @@ -102,6 +105,7 @@ def_kwargs_cr = (:(; M = I ),

def_kwargs_cr = mapreduce(extract_parameters, vcat, def_kwargs_cr)

args_cr = (:A, :b)
kwargs_cr = (:M, :ldiv, :radius, :linesearch, , :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
4 changes: 4 additions & 0 deletions src/craig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ See [`CraigSolver`](@ref) for more details about the `solver`.
"""
function craig! end

def_args_craig = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_craig = (:(; M = I ),
:(; N = I ),
:(; ldiv::Bool = false ),
Expand All @@ -153,6 +156,7 @@ def_kwargs_craig = (:(; M = I ),

def_kwargs_craig = mapreduce(extract_parameters, vcat, def_kwargs_craig)

args_craig = (:A, :b)
kwargs_craig = (:M, :N, :ldiv, :transfer_to_lsqr, :sqd, , :btol, :conlim, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
4 changes: 4 additions & 0 deletions src/craigmr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ See [`CraigmrSolver`](@ref) for more details about the `solver`.
"""
function craigmr! end

def_args_craigmr = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_craigmr = (:(; M = I ),
:(; N = I ),
:(; ldiv::Bool = false ),
Expand All @@ -142,6 +145,7 @@ def_kwargs_craigmr = (:(; M = I ),

def_kwargs_craigmr = mapreduce(extract_parameters, vcat, def_kwargs_craigmr)

args_craigmr = (:A, :b)
kwargs_craigmr = (:M, :N, :ldiv, :sqd, , :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
4 changes: 4 additions & 0 deletions src/crls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ See [`CrlsSolver`](@ref) for more details about the `solver`.
"""
function crls! end

def_args_crls = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_crls = (:(; M = I ),
:(; ldiv::Bool = false ),
:(; radius::T = zero(T) ),
Expand All @@ -101,6 +104,7 @@ def_kwargs_crls = (:(; M = I ),

def_kwargs_crls = mapreduce(extract_parameters, vcat, def_kwargs_crls)

args_crls = (:A, :b)
kwargs_crls = (:M, :ldiv, :radius, , :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
4 changes: 4 additions & 0 deletions src/crmr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ See [`CrmrSolver`](@ref) for more details about the `solver`.
"""
function crmr! end

def_args_crmr = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_crmr = (:(; N = I ),
:(; ldiv::Bool = false ),
:(; λ::T = zero(T) ),
Expand All @@ -113,6 +116,7 @@ def_kwargs_crmr = (:(; N = I ),

def_kwargs_crmr = mapreduce(extract_parameters, vcat, def_kwargs_crmr)

args_crmr = (:A, :b)
kwargs_crmr = (:N, :ldiv, , :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
4 changes: 4 additions & 0 deletions src/diom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ See [`DiomSolver`](@ref) for more details about the `solver`.
"""
function diom! end

def_args_diom = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_diom = (:(; M = I ),
:(; N = I ),
:(; ldiv::Bool = false ),
Expand All @@ -99,6 +102,7 @@ def_kwargs_diom = (:(; M = I ),

def_kwargs_diom = mapreduce(extract_parameters, vcat, def_kwargs_diom)

args_diom = (:A, :b)
kwargs_diom = (:M, :N, :ldiv, :reorthogonalization, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
4 changes: 4 additions & 0 deletions src/dqgmres.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ See [`DqgmresSolver`](@ref) for more details about the `solver`.
"""
function dqgmres! end

def_args_dqgmres = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_dqgmres = (:(; M = I ),
:(; N = I ),
:(; ldiv::Bool = false ),
Expand All @@ -99,6 +102,7 @@ def_kwargs_dqgmres = (:(; M = I ),

def_kwargs_dqgmres = mapreduce(extract_parameters, vcat, def_kwargs_dqgmres)

args_dqgmres = (:A, :b)
kwargs_dqgmres = (:M, :N, :ldiv, :reorthogonalization, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
4 changes: 4 additions & 0 deletions src/fgmres.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ See [`FgmresSolver`](@ref) for more details about the `solver`.
"""
function fgmres! end

def_args_fgmres = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_fgmres = (:(; M = I ),
:(; N = I ),
:(; ldiv::Bool = false ),
Expand All @@ -102,6 +105,7 @@ def_kwargs_fgmres = (:(; M = I ),

def_kwargs_fgmres = mapreduce(extract_parameters, vcat, def_kwargs_fgmres)

args_fgmres = (:A, :b)
kwargs_fgmres = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
4 changes: 4 additions & 0 deletions src/fom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ See [`FomSolver`](@ref) for more details about the `solver`.
"""
function fom! end

def_args_fom = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_fom = (:(; M = I ),
:(; N = I ),
:(; ldiv::Bool = false ),
Expand All @@ -95,6 +98,7 @@ def_kwargs_fom = (:(; M = I ),

def_kwargs_fom = mapreduce(extract_parameters, vcat, def_kwargs_fom)

args_fom = (:A, :b)
kwargs_fom = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
4 changes: 4 additions & 0 deletions src/gmres.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ See [`GmresSolver`](@ref) for more details about the `solver`.
"""
function gmres! end

def_args_gmres = (:(A ),
:(b::AbstractVector{FC}))

def_kwargs_gmres = (:(; M = I ),
:(; N = I ),
:(; ldiv::Bool = false ),
Expand All @@ -95,6 +98,7 @@ def_kwargs_gmres = (:(; M = I ),

def_kwargs_gmres = mapreduce(extract_parameters, vcat, def_kwargs_gmres)

args_gmres = (:A, :b)
kwargs_gmres = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
6 changes: 6 additions & 0 deletions src/gpmr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ See [`GpmrSolver`](@ref) for more details about the `solver`.
"""
function gpmr! end

def_args_gpmr = (:(A ),
:(B ),
:(b::AbstractVector{FC}),
:(c::AbstractVector{FC}))

def_kwargs_gpmr = (:(; C = I ),
:(; D = I ),
:(; E = I ),
Expand All @@ -135,6 +140,7 @@ def_kwargs_gpmr = (:(; C = I ),

def_kwargs_gpmr = mapreduce(extract_parameters, vcat, def_kwargs_gpmr)

args_gpmr = (:A, :B, :b, :c)
kwargs_gpmr = (:C, :D, :E, :F, :ldiv, :gsp, , , :reorthogonalization, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
Expand Down
Loading

0 comments on commit 4723b13

Please sign in to comment.