From f5fbae9f5ce57f3c01fe2b3a1fd3a98a3a62e949 Mon Sep 17 00:00:00 2001 From: Alexis Montoison <35051714+amontoison@users.noreply.github.com> Date: Sun, 13 Oct 2024 13:16:08 -0500 Subject: [PATCH] Use metaprogramming to generate out-of-place methods (#887) * Use metaprogramming to generate out-of-place methods * Add a function results --- src/bicgstab.jl | 21 ------ src/bilq.jl | 21 ------ src/bilqr.jl | 21 ------ src/block_gmres.jl | 21 ------ src/block_krylov_solvers.jl | 5 +- src/car.jl | 21 ------ src/cg.jl | 21 ------ src/cg_lanczos.jl | 21 ------ src/cgls.jl | 10 --- src/cgne.jl | 10 --- src/cgs.jl | 21 ------ src/cr.jl | 21 ------ src/craig.jl | 10 --- src/craigmr.jl | 10 --- src/crls.jl | 10 --- src/crmr.jl | 10 --- src/krylov_solve.jl | 135 ++++++++++++++++++++++++++---------- src/krylov_solvers.jl | 19 ++++- src/lnlq.jl | 10 --- src/minares.jl | 21 ------ src/minres_qlp.jl | 21 ------ src/qmr.jl | 21 ------ src/tricg.jl | 21 ------ src/trilqr.jl | 21 ------ src/trimr.jl | 21 ------ src/usymlq.jl | 21 ------ src/usymqr.jl | 21 ------ 27 files changed, 118 insertions(+), 468 deletions(-) diff --git a/src/bicgstab.jl b/src/bicgstab.jl index 16a3ceae9..5e2c8f5f6 100644 --- a/src/bicgstab.jl +++ b/src/bicgstab.jl @@ -113,27 +113,6 @@ optargs_bicgstab = (:x0,) kwargs_bicgstab = (:c, :M, :N, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function bicgstab($(def_args_bicgstab...), $(def_optargs_bicgstab...); $(def_kwargs_bicgstab...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = BicgstabSolver(A, b) - warm_start!(solver, $(optargs_bicgstab...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - bicgstab!(solver, $(args_bicgstab...); $(kwargs_bicgstab...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - - function bicgstab($(def_args_bicgstab...); $(def_kwargs_bicgstab...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = BicgstabSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - bicgstab!(solver, $(args_bicgstab...); $(kwargs_bicgstab...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - function bicgstab!(solver :: BicgstabSolver{T,FC,S}, $(def_args_bicgstab...); $(def_kwargs_bicgstab...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/bilq.jl b/src/bilq.jl index 5bda9802a..ab7580d43 100644 --- a/src/bilq.jl +++ b/src/bilq.jl @@ -106,27 +106,6 @@ optargs_bilq = (:x0,) kwargs_bilq = (:c, :transfer_to_bicg, :M, :N, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function bilq($(def_args_bilq...), $(def_optargs_bilq...); $(def_kwargs_bilq...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = BilqSolver(A, b) - warm_start!(solver, $(optargs_bilq...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - bilq!(solver, $(args_bilq...); $(kwargs_bilq...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - - function bilq($(def_args_bilq...); $(def_kwargs_bilq...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = BilqSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - bilq!(solver, $(args_bilq...); $(kwargs_bilq...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - function bilq!(solver :: BilqSolver{T,FC,S}, $(def_args_bilq...); $(def_kwargs_bilq...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/bilqr.jl b/src/bilqr.jl index 1abc60bce..93667db9f 100644 --- a/src/bilqr.jl +++ b/src/bilqr.jl @@ -104,27 +104,6 @@ optargs_bilqr = (:x0, :y0) kwargs_bilqr = (:transfer_to_bicg, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function bilqr($(def_args_bilqr...), $(def_optargs_bilqr...); $(def_kwargs_bilqr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = BilqrSolver(A, b) - warm_start!(solver, $(optargs_bilqr...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - bilqr!(solver, $(args_bilqr...); $(kwargs_bilqr...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.y, solver.stats) - end - - function bilqr($(def_args_bilqr...); $(def_kwargs_bilqr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = BilqrSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - bilqr!(solver, $(args_bilqr...); $(kwargs_bilqr...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.y, solver.stats) - end - function bilqr!(solver :: BilqrSolver{T,FC,S}, $(def_args_bilqr...); $(def_kwargs_bilqr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/block_gmres.jl b/src/block_gmres.jl index ea0b4b989..13985644c 100644 --- a/src/block_gmres.jl +++ b/src/block_gmres.jl @@ -91,27 +91,6 @@ optargs_block_gmres = (:X0,) kwargs_block_gmres = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function block_gmres($(def_args_block_gmres...), $(def_optargs_block_gmres...); memory :: Int=20, $(def_kwargs_block_gmres...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = BlockGmresSolver(A, B; memory) - warm_start!(solver, $(optargs_block_gmres...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - block_gmres!(solver, $(args_block_gmres...); $(kwargs_block_gmres...)) - solver.stats.timer += elapsed_time - return solver.X, solver.stats - end - - function block_gmres($(def_args_block_gmres...); memory :: Int=20, $(def_kwargs_block_gmres...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = BlockGmresSolver(A, B; memory) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - block_gmres!(solver, $(args_block_gmres...); $(kwargs_block_gmres...)) - solver.stats.timer += elapsed_time - return solver.X, solver.stats - end - function block_gmres!(solver :: BlockGmresSolver{T,FC,SV,SM}, $(def_args_block_gmres...); $(def_kwargs_block_gmres...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, SV <: AbstractVector{FC}, SM <: AbstractMatrix{FC}} # Timer diff --git a/src/block_krylov_solvers.jl b/src/block_krylov_solvers.jl index c6c128aeb..4d00c21dd 100644 --- a/src/block_krylov_solvers.jl +++ b/src/block_krylov_solvers.jl @@ -13,7 +13,7 @@ Type for storing the vectors required by the in-place version of BLOCK-GMRES. The outer constructors solver = BlockGmresSolver(m, n, p, memory, SV, SM) - solver = BlockGmresSolver(A, B; memory=5) + solver = BlockGmresSolver(A, B, memory = 5) may be used in order to create these vectors. `memory` is set to `div(n,p)` if the value given is larger than `div(n,p)`. @@ -59,7 +59,7 @@ function BlockGmresSolver(m, n, p, memory, SV, SM) return solver end -function BlockGmresSolver(A, B; memory::Int=5) +function BlockGmresSolver(A, B, memory = 5) m, n = size(A) s, p = size(B) SM = typeof(B) @@ -81,6 +81,7 @@ for (KS, fun, nsol, nA, nAt, warm_start) in [ if $nsol == 1 solution(solver :: $KS) = solver.X solution(solver :: $KS, p :: Integer) = (p == 1) ? solution(solver) : error("solution(solver) has only one output.") + results(solver :: $KS) = (solver.X, solver.stats) end issolved(solver :: $KS) = solver.stats.solved if $warm_start diff --git a/src/car.jl b/src/car.jl index 602b19978..9deda247a 100644 --- a/src/car.jl +++ b/src/car.jl @@ -95,27 +95,6 @@ optargs_car = (:x0,) kwargs_car = (:M, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function car($(def_args_car...), $(def_optargs_car...); $(def_kwargs_car...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = CarSolver(A, b) - warm_start!(solver, $(optargs_car...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - car!(solver, $(args_car...); $(kwargs_car...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - - function car($(def_args_car...); $(def_kwargs_car...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = CarSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - car!(solver, $(args_car...); $(kwargs_car...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - function car!(solver :: CarSolver{T,FC,S}, $(def_args_car...); $(def_kwargs_car...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/cg.jl b/src/cg.jl index 50517e427..3b21ae197 100644 --- a/src/cg.jl +++ b/src/cg.jl @@ -105,27 +105,6 @@ optargs_cg = (:x0,) kwargs_cg = (:M, :ldiv, :radius, :linesearch, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function cg($(def_args_cg...), $(def_optargs_cg...); $(def_kwargs_cg...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = CgSolver(A, b) - warm_start!(solver, $(optargs_cg...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - cg!(solver, $(args_cg...); $(kwargs_cg...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - - function cg($(def_args_cg...); $(def_kwargs_cg...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = CgSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - cg!(solver, $(args_cg...); $(kwargs_cg...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - function cg!(solver :: CgSolver{T,FC,S}, $(def_args_cg...); $(def_kwargs_cg...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/cg_lanczos.jl b/src/cg_lanczos.jl index 778a73d6f..c86053826 100644 --- a/src/cg_lanczos.jl +++ b/src/cg_lanczos.jl @@ -101,27 +101,6 @@ optargs_cg_lanczos = (:x0,) kwargs_cg_lanczos = (:M, :ldiv, :check_curvature, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function cg_lanczos($(def_args_cg_lanczos...), $(def_optargs_cg_lanczos...); $(def_kwargs_cg_lanczos...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = CgLanczosSolver(A, b) - warm_start!(solver, $(optargs_cg_lanczos...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - cg_lanczos!(solver, $(args_cg_lanczos...); $(kwargs_cg_lanczos...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - - function cg_lanczos($(def_args_cg_lanczos...); $(def_kwargs_cg_lanczos...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = CgLanczosSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - cg_lanczos!(solver, $(args_cg_lanczos...); $(kwargs_cg_lanczos...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - function cg_lanczos!(solver :: CgLanczosSolver{T,FC,S}, $(def_args_cg_lanczos...); $(def_kwargs_cg_lanczos...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/cgls.jl b/src/cgls.jl index c9355e52d..3e3034aa1 100644 --- a/src/cgls.jl +++ b/src/cgls.jl @@ -117,16 +117,6 @@ args_cgls = (:A, :b) kwargs_cgls = (:M, :ldiv, :radius, :λ, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function cgls($(def_args_cgls...); $(def_kwargs_cgls...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = CglsSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - cgls!(solver, $(args_cgls...); $(kwargs_cgls...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - function cgls!(solver :: CglsSolver{T,FC,S}, $(def_args_cgls...); $(def_kwargs_cgls...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/cgne.jl b/src/cgne.jl index 8a4e6dddb..d3589051b 100644 --- a/src/cgne.jl +++ b/src/cgne.jl @@ -122,16 +122,6 @@ args_cgne = (:A, :b) kwargs_cgne = (:N, :ldiv, :λ, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function cgne($(def_args_cgne...); $(def_kwargs_cgne...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = CgneSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - cgne!(solver, $(args_cgne...); $(kwargs_cgne...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - function cgne!(solver :: CgneSolver{T,FC,S}, $(def_args_cgne...); $(def_kwargs_cgne...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/cgs.jl b/src/cgs.jl index e95e74d17..f083f4dd7 100644 --- a/src/cgs.jl +++ b/src/cgs.jl @@ -114,27 +114,6 @@ optargs_cgs = (:x0,) kwargs_cgs = (:c, :M, :N, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function cgs($(def_args_cgs...), $(def_optargs_cgs...); $(def_kwargs_cgs...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = CgsSolver(A, b) - warm_start!(solver, $(optargs_cgs...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - cgs!(solver, $(args_cgs...); $(kwargs_cgs...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - - function cgs($(def_args_cgs...); $(def_kwargs_cgs...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = CgsSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - cgs!(solver, $(args_cgs...); $(kwargs_cgs...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - function cgs!(solver :: CgsSolver{T,FC,S}, $(def_args_cgs...); $(def_kwargs_cgs...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/cr.jl b/src/cr.jl index d816ce480..2a5f9527a 100644 --- a/src/cr.jl +++ b/src/cr.jl @@ -112,27 +112,6 @@ optargs_cr = (:x0,) kwargs_cr = (:M, :ldiv, :radius, :linesearch, :γ, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function cr($(def_args_cr...), $(def_optargs_cr...); $(def_kwargs_cr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = CrSolver(A, b) - warm_start!(solver, $(optargs_cr...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - cr!(solver, $(args_cr...); $(kwargs_cr...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - - function cr($(def_args_cr...); $(def_kwargs_cr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = CrSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - cr!(solver, $(args_cr...); $(kwargs_cr...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - function cr!(solver :: CrSolver{T,FC,S}, $(def_args_cr...); $(def_kwargs_cr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/craig.jl b/src/craig.jl index c4eef10d4..41f2d087d 100644 --- a/src/craig.jl +++ b/src/craig.jl @@ -162,16 +162,6 @@ 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 - function craig($(def_args_craig...); $(def_kwargs_craig...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = CraigSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - craig!(solver, $(args_craig...); $(kwargs_craig...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.y, solver.stats) - end - function craig!(solver :: CraigSolver{T,FC,S}, $(def_args_craig...); $(def_kwargs_craig...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/craigmr.jl b/src/craigmr.jl index 5f05aa2ae..1472b897a 100644 --- a/src/craigmr.jl +++ b/src/craigmr.jl @@ -149,16 +149,6 @@ args_craigmr = (:A, :b) kwargs_craigmr = (:M, :N, :ldiv, :sqd, :λ, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function craigmr($(def_args_craigmr...); $(def_kwargs_craigmr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = CraigmrSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - craigmr!(solver, $(args_craigmr...); $(kwargs_craigmr...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.y, solver.stats) - end - function craigmr!(solver :: CraigmrSolver{T,FC,S}, $(def_args_craigmr...); $(def_kwargs_craigmr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/crls.jl b/src/crls.jl index 40cca6f2e..62d1d11d4 100644 --- a/src/crls.jl +++ b/src/crls.jl @@ -108,16 +108,6 @@ args_crls = (:A, :b) kwargs_crls = (:M, :ldiv, :radius, :λ, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function crls($(def_args_crls...); $(def_kwargs_crls...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = CrlsSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - crls!(solver, $(args_crls...); $(kwargs_crls...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - function crls!(solver :: CrlsSolver{T,FC,S}, $(def_args_crls...); $(def_kwargs_crls...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/crmr.jl b/src/crmr.jl index db333856c..34bb9dd4d 100644 --- a/src/crmr.jl +++ b/src/crmr.jl @@ -120,16 +120,6 @@ args_crmr = (:A, :b) kwargs_crmr = (:N, :ldiv, :λ, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function crmr($(def_args_crmr...); $(def_kwargs_crmr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = CrmrSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - crmr!(solver, $(args_crmr...); $(kwargs_crmr...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - function crmr!(solver :: CrmrSolver{T,FC,S}, $(def_args_crmr...); $(def_kwargs_crmr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/krylov_solve.jl b/src/krylov_solve.jl index 2940bc7e8..f3fed1c41 100644 --- a/src/krylov_solve.jl +++ b/src/krylov_solve.jl @@ -5,44 +5,77 @@ Use the in-place Krylov method associated to `solver`. """ function solve! end -for (KS, fun, args, def_args, optargs, def_optargs, kwargs, def_kwargs) in [ - (:LsmrSolver , :lsmr! , args_lsmr , def_args_lsmr , () , () , kwargs_lsmr , def_kwargs_lsmr ) - (:CgsSolver , :cgs! , args_cgs , def_args_cgs , optargs_cgs , def_optargs_cgs , kwargs_cgs , def_kwargs_cgs ) - (:UsymlqSolver , :usymlq! , args_usymlq , def_args_usymlq , optargs_usymlq , def_optargs_usymlq , kwargs_usymlq , def_kwargs_usymlq ) - (:LnlqSolver , :lnlq! , args_lnlq , def_args_lnlq , () , () , kwargs_lnlq , def_kwargs_lnlq ) - (:BicgstabSolver , :bicgstab! , args_bicgstab , def_args_bicgstab , optargs_bicgstab , def_optargs_bicgstab , kwargs_bicgstab , def_kwargs_bicgstab ) - (:CrlsSolver , :crls! , args_crls , def_args_crls , () , () , kwargs_crls , def_kwargs_crls ) - (:LsqrSolver , :lsqr! , args_lsqr , def_args_lsqr , () , () , kwargs_lsqr , def_kwargs_lsqr ) - (:MinresSolver , :minres! , args_minres , def_args_minres , optargs_minres , def_optargs_minres , kwargs_minres , def_kwargs_minres ) - (:MinaresSolver , :minares! , args_minares , def_args_minares , optargs_minares , def_optargs_minares , kwargs_minares , def_kwargs_minares ) - (:CgneSolver , :cgne! , args_cgne , def_args_cgne , () , () , kwargs_cgne , def_kwargs_cgne ) - (:DqgmresSolver , :dqgmres! , args_dqgmres , def_args_dqgmres , optargs_dqgmres , def_optargs_dqgmres , kwargs_dqgmres , def_kwargs_dqgmres ) - (:SymmlqSolver , :symmlq! , args_symmlq , def_args_symmlq , optargs_symmlq , def_optargs_symmlq , kwargs_symmlq , def_kwargs_symmlq ) - (:TrimrSolver , :trimr! , args_trimr , def_args_trimr , optargs_trimr , def_optargs_trimr , kwargs_trimr , def_kwargs_trimr ) - (:UsymqrSolver , :usymqr! , args_usymqr , def_args_usymqr , optargs_usymqr , def_optargs_usymqr , kwargs_usymqr , def_kwargs_usymqr ) - (:BilqrSolver , :bilqr! , args_bilqr , def_args_bilqr , optargs_bilqr , def_optargs_bilqr , kwargs_bilqr , def_kwargs_bilqr ) - (:CrSolver , :cr! , args_cr , def_args_cr , optargs_cr , def_optargs_cr , kwargs_cr , def_kwargs_cr ) - (:CarSolver , :car! , args_car , def_args_car , optargs_car , def_optargs_car , kwargs_car , def_kwargs_car ) - (:CraigmrSolver , :craigmr! , args_craigmr , def_args_craigmr , () , () , kwargs_craigmr , def_kwargs_craigmr ) - (:TricgSolver , :tricg! , args_tricg , def_args_tricg , optargs_tricg , def_optargs_tricg , kwargs_tricg , def_kwargs_tricg ) - (:CraigSolver , :craig! , args_craig , def_args_craig , () , () , kwargs_craig , def_kwargs_craig ) - (:DiomSolver , :diom! , args_diom , def_args_diom , optargs_diom , def_optargs_diom , kwargs_diom , def_kwargs_diom ) - (:LslqSolver , :lslq! , args_lslq , def_args_lslq , () , () , kwargs_lslq , def_kwargs_lslq ) - (:TrilqrSolver , :trilqr! , args_trilqr , def_args_trilqr , optargs_trilqr , def_optargs_trilqr , kwargs_trilqr , def_kwargs_trilqr ) - (:CrmrSolver , :crmr! , args_crmr , def_args_crmr , () , () , kwargs_crmr , def_kwargs_crmr ) - (:CgSolver , :cg! , args_cg , def_args_cg , optargs_cg , def_optargs_cg , kwargs_cg , def_kwargs_cg ) - (:CgLanczosShiftSolver, :cg_lanczos_shift!, args_cg_lanczos_shift, def_args_cg_lanczos_shift, () , () , kwargs_cg_lanczos_shift, def_kwargs_cg_lanczos_shift) - (:CglsSolver , :cgls! , args_cgls , def_args_cgls , () , () , kwargs_cgls , def_kwargs_cgls ) - (:CgLanczosSolver , :cg_lanczos! , args_cg_lanczos , def_args_cg_lanczos , optargs_cg_lanczos, def_optargs_cg_lanczos, kwargs_cg_lanczos , def_kwargs_cg_lanczos ) - (:BilqSolver , :bilq! , args_bilq , def_args_bilq , optargs_bilq , def_optargs_bilq , kwargs_bilq , def_kwargs_bilq ) - (:MinresQlpSolver , :minres_qlp! , args_minres_qlp , def_args_minres_qlp , optargs_minres_qlp, def_optargs_minres_qlp, kwargs_minres_qlp , def_kwargs_minres_qlp ) - (:QmrSolver , :qmr! , args_qmr , def_args_qmr , optargs_qmr , def_optargs_qmr , kwargs_qmr , def_kwargs_qmr ) - (:GmresSolver , :gmres! , args_gmres , def_args_gmres , optargs_gmres , def_optargs_gmres , kwargs_gmres , def_kwargs_gmres ) - (:FgmresSolver , :fgmres! , args_fgmres , def_args_fgmres , optargs_fgmres , def_optargs_fgmres , kwargs_fgmres , def_kwargs_fgmres ) - (:FomSolver , :fom! , args_fom , def_args_fom , optargs_fom , def_optargs_fom , kwargs_fom , def_kwargs_fom ) - (:GpmrSolver , :gpmr! , args_gpmr , def_args_gpmr , optargs_gpmr , def_optargs_gpmr , kwargs_gpmr , def_kwargs_gpmr ) +# Krylov methods +for (KS, fun, fun2, args, def_args, optargs, def_optargs, kwargs, def_kwargs) in [ + (:LsmrSolver , :lsmr! , :lsmr , args_lsmr , def_args_lsmr , () , () , kwargs_lsmr , def_kwargs_lsmr ) + (:CgsSolver , :cgs! , :cgs , args_cgs , def_args_cgs , optargs_cgs , def_optargs_cgs , kwargs_cgs , def_kwargs_cgs ) + (:UsymlqSolver , :usymlq! , :usymlq , args_usymlq , def_args_usymlq , optargs_usymlq , def_optargs_usymlq , kwargs_usymlq , def_kwargs_usymlq ) + (:LnlqSolver , :lnlq! , :lnlq , args_lnlq , def_args_lnlq , () , () , kwargs_lnlq , def_kwargs_lnlq ) + (:BicgstabSolver , :bicgstab! , :bicgstab , args_bicgstab , def_args_bicgstab , optargs_bicgstab , def_optargs_bicgstab , kwargs_bicgstab , def_kwargs_bicgstab ) + (:CrlsSolver , :crls! , :crls , args_crls , def_args_crls , () , () , kwargs_crls , def_kwargs_crls ) + (:LsqrSolver , :lsqr! , :lsqr , args_lsqr , def_args_lsqr , () , () , kwargs_lsqr , def_kwargs_lsqr ) + (:MinresSolver , :minres! , :minres , args_minres , def_args_minres , optargs_minres , def_optargs_minres , kwargs_minres , def_kwargs_minres ) + (:MinaresSolver , :minares! , :minares , args_minares , def_args_minares , optargs_minares , def_optargs_minares , kwargs_minares , def_kwargs_minares ) + (:CgneSolver , :cgne! , :cgne , args_cgne , def_args_cgne , () , () , kwargs_cgne , def_kwargs_cgne ) + (:DqgmresSolver , :dqgmres! , :dqgmres , args_dqgmres , def_args_dqgmres , optargs_dqgmres , def_optargs_dqgmres , kwargs_dqgmres , def_kwargs_dqgmres ) + (:SymmlqSolver , :symmlq! , :symmlq , args_symmlq , def_args_symmlq , optargs_symmlq , def_optargs_symmlq , kwargs_symmlq , def_kwargs_symmlq ) + (:TrimrSolver , :trimr! , :trimr , args_trimr , def_args_trimr , optargs_trimr , def_optargs_trimr , kwargs_trimr , def_kwargs_trimr ) + (:UsymqrSolver , :usymqr! , :usymqr , args_usymqr , def_args_usymqr , optargs_usymqr , def_optargs_usymqr , kwargs_usymqr , def_kwargs_usymqr ) + (:BilqrSolver , :bilqr! , :bilqr , args_bilqr , def_args_bilqr , optargs_bilqr , def_optargs_bilqr , kwargs_bilqr , def_kwargs_bilqr ) + (:CrSolver , :cr! , :cr , args_cr , def_args_cr , optargs_cr , def_optargs_cr , kwargs_cr , def_kwargs_cr ) + (:CarSolver , :car! , :car , args_car , def_args_car , optargs_car , def_optargs_car , kwargs_car , def_kwargs_car ) + (:CraigmrSolver , :craigmr! , :craigmr , args_craigmr , def_args_craigmr , () , () , kwargs_craigmr , def_kwargs_craigmr ) + (:TricgSolver , :tricg! , :tricg , args_tricg , def_args_tricg , optargs_tricg , def_optargs_tricg , kwargs_tricg , def_kwargs_tricg ) + (:CraigSolver , :craig! , :craig , args_craig , def_args_craig , () , () , kwargs_craig , def_kwargs_craig ) + (:DiomSolver , :diom! , :diom , args_diom , def_args_diom , optargs_diom , def_optargs_diom , kwargs_diom , def_kwargs_diom ) + (:LslqSolver , :lslq! , :lslq , args_lslq , def_args_lslq , () , () , kwargs_lslq , def_kwargs_lslq ) + (:TrilqrSolver , :trilqr! , :trilqr , args_trilqr , def_args_trilqr , optargs_trilqr , def_optargs_trilqr , kwargs_trilqr , def_kwargs_trilqr ) + (:CrmrSolver , :crmr! , :crmr , args_crmr , def_args_crmr , () , () , kwargs_crmr , def_kwargs_crmr ) + (:CgSolver , :cg! , :cg , args_cg , def_args_cg , optargs_cg , def_optargs_cg , kwargs_cg , def_kwargs_cg ) + (:CgLanczosShiftSolver, :cg_lanczos_shift!, :cg_lanczos_shift, args_cg_lanczos_shift, def_args_cg_lanczos_shift, () , () , kwargs_cg_lanczos_shift, def_kwargs_cg_lanczos_shift) + (:CglsSolver , :cgls! , :cgls , args_cgls , def_args_cgls , () , () , kwargs_cgls , def_kwargs_cgls ) + (:CgLanczosSolver , :cg_lanczos! , :cg_lanczos , args_cg_lanczos , def_args_cg_lanczos , optargs_cg_lanczos, def_optargs_cg_lanczos, kwargs_cg_lanczos , def_kwargs_cg_lanczos ) + (:BilqSolver , :bilq! , :bilq , args_bilq , def_args_bilq , optargs_bilq , def_optargs_bilq , kwargs_bilq , def_kwargs_bilq ) + (:MinresQlpSolver , :minres_qlp! , :minres_qlp , args_minres_qlp , def_args_minres_qlp , optargs_minres_qlp, def_optargs_minres_qlp, kwargs_minres_qlp , def_kwargs_minres_qlp ) + (:QmrSolver , :qmr! , :qmr , args_qmr , def_args_qmr , optargs_qmr , def_optargs_qmr , kwargs_qmr , def_kwargs_qmr ) + (:GmresSolver , :gmres! , :gmres , args_gmres , def_args_gmres , optargs_gmres , def_optargs_gmres , kwargs_gmres , def_kwargs_gmres ) + (:FgmresSolver , :fgmres! , :fgmres , args_fgmres , def_args_fgmres , optargs_fgmres , def_optargs_fgmres , kwargs_fgmres , def_kwargs_fgmres ) + (:FomSolver , :fom! , :fom , args_fom , def_args_fom , optargs_fom , def_optargs_fom , kwargs_fom , def_kwargs_fom ) + (:GpmrSolver , :gpmr! , :gpmr , args_gpmr , def_args_gpmr , optargs_gpmr , def_optargs_gpmr , kwargs_gpmr , def_kwargs_gpmr ) ] + # window :: 5 -> lslq, lsmr, lsqr, minres, symmlq + # shifts -> CgLanczosShiftSolver(A, b, nshifts) + # memory :: 20 -> diom, dqgmres, fom, gmres, fgmres, gpmr + if fun2 ∉ (:lslq, :lsmr, :lsqr, :minres, :symmlq, :cg_lanczos_shift, :diom, :dqgmres, :fom, :gmres, :fgmres, :gpmr) + @eval begin + ## Out-of-place + function $(fun2)($(def_args...); $(def_kwargs...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} + start_time = time_ns() + solver = $KS(A, b) + elapsed_time = ktimer(start_time) + timemax -= elapsed_time + $(fun)(solver, $(args...); $(kwargs...)) + solver.stats.timer += elapsed_time + return results(solver) + end + + if !isempty($optargs) + function $(fun2)($(def_args...), $(def_optargs...); $(def_kwargs...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} + start_time = time_ns() + solver = $KS(A, b) + warm_start!(solver, $(optargs...)) + elapsed_time = ktimer(start_time) + timemax -= elapsed_time + $(fun)(solver, $(args...); $(kwargs...)) + solver.stats.timer += elapsed_time + return results(solver) + end + end + end + end + @eval begin + ## In-place solve!(solver :: $KS{T,FC,S}, $(def_args...); $(def_kwargs...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} = $(fun)(solver, $(args...); $(kwargs...)) if !isempty($optargs) @@ -61,10 +94,36 @@ for (KS, fun, args, def_args, optargs, def_optargs, kwargs, def_kwargs) in [ end end -for (KS, fun, args, def_args, optargs, def_optargs, kwargs, def_kwargs) in [ - (:BlockGmresSolver, :block_gmres!, args_block_gmres, def_args_block_gmres, optargs_block_gmres, def_optargs_block_gmres, kwargs_block_gmres, def_kwargs_block_gmres), +# Block-Krylov methods +for (KS, fun, fun2, args, def_args, optargs, def_optargs, kwargs, def_kwargs) in [ + (:BlockGmresSolver, :block_gmres!, :block_gmres, args_block_gmres, def_args_block_gmres, optargs_block_gmres, def_optargs_block_gmres, kwargs_block_gmres, def_kwargs_block_gmres), ] @eval begin + ## Out-of-place + function $(fun2)($(def_args...); memory :: Int=20, $(def_kwargs...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} + start_time = time_ns() + solver = $KS(A, B, memory) + elapsed_time = ktimer(start_time) + timemax -= elapsed_time + $(fun)(solver, $(args...); $(kwargs...)) + solver.stats.timer += elapsed_time + return results(solver) + end + + if !isempty($optargs) + function $(fun2)($(def_args...), $(def_optargs...); memory :: Int=20, $(def_kwargs...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} + start_time = time_ns() + solver = $KS(A, B, memory) + warm_start!(solver, $(optargs...)) + elapsed_time = ktimer(start_time) + timemax -= elapsed_time + $(fun)(solver, $(args...); $(kwargs...)) + solver.stats.timer += elapsed_time + return results(solver) + end + end + + ## In-place solve!(solver :: $KS{T,FC,SV,SM}, $(def_args...); $(def_kwargs...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, SV <: AbstractVector{FC}, SM <: AbstractMatrix{FC}} = $(fun)(solver, $(args...); $(kwargs...)) if !isempty($optargs) diff --git a/src/krylov_solvers.jl b/src/krylov_solvers.jl index d9f9fd9b1..857fc27f2 100644 --- a/src/krylov_solvers.jl +++ b/src/krylov_solvers.jl @@ -1896,6 +1896,21 @@ Return the number of operator-vector products with `A'` performed by the Krylov """ function Atprod end +""" + results(solver) + +Return a tuple containing the solution(s) and the statistics associated with the `solver`. +Allows retrieving the output arguments of an out-of-place method from the in-place method. + +For example, instead of `x, stats = cg(A, b)`, you can use: +```julia + solver = CgSolver(A, b) + cg!(solver, A, b) + x, stats = results(solver) +``` +""" +function results end + for (KS, fun, nsol, nA, nAt, warm_start) in [ (:CarSolver , :car! , 1, 1, 0, true ) (:LsmrSolver , :lsmr! , 1, 1, 1, false) @@ -1946,10 +1961,12 @@ for (KS, fun, nsol, nA, nAt, warm_start) in [ if $nsol == 1 solution(solver :: $KS) = solver.x solution(solver :: $KS, p :: Integer) = (p == 1) ? solution(solver) : error("solution(solver) has only one output.") + results(solver :: $KS) = (solver.x, solver.stats) end if $nsol == 2 - solution(solver :: $KS) = solver.x, solver.y + solution(solver :: $KS) = (solver.x, solver.y) solution(solver :: $KS, p :: Integer) = (1 ≤ p ≤ 2) ? solution(solver)[p] : error("solution(solver) has only two outputs.") + results(solver :: $KS) = (solver.x, solver.y, solver.stats) end if $KS ∈ (BilqrSolver, TrilqrSolver) issolved_primal(solver :: $KS) = solver.stats.solved_primal diff --git a/src/lnlq.jl b/src/lnlq.jl index f59f5daf4..3ba4f1338 100644 --- a/src/lnlq.jl +++ b/src/lnlq.jl @@ -156,16 +156,6 @@ args_lnlq = (:A, :b) kwargs_lnlq = (:M, :N, :ldiv, :transfer_to_craig, :sqd, :λ, :σ, :utolx, :utoly, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function lnlq($(def_args_lnlq...); $(def_kwargs_lnlq...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = LnlqSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - lnlq!(solver, $(args_lnlq...); $(kwargs_lnlq...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.y, solver.stats) - end - function lnlq!(solver :: LnlqSolver{T,FC,S}, $(def_args_lnlq...); $(def_kwargs_lnlq...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/minares.jl b/src/minares.jl index 19d1be972..5da0b5251 100644 --- a/src/minares.jl +++ b/src/minares.jl @@ -100,27 +100,6 @@ optargs_minares = (:x0,) kwargs_minares = (:M, :ldiv, :λ, :atol, :rtol, :Artol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function minares($(def_args_minares...), $(def_optargs_minares...); $(def_kwargs_minares...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = MinaresSolver(A, b) - warm_start!(solver, $(optargs_minares...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - minares!(solver, $(args_minares...); $(kwargs_minares...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - - function minares($(def_args_minares...); $(def_kwargs_minares...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = MinaresSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - minares!(solver, $(args_minares...); $(kwargs_minares...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - function minares!(solver :: MinaresSolver{T,FC,S}, $(def_args_minares...); $(def_kwargs_minares...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/minres_qlp.jl b/src/minres_qlp.jl index 9cb569f6a..6f5f79f70 100644 --- a/src/minres_qlp.jl +++ b/src/minres_qlp.jl @@ -109,27 +109,6 @@ optargs_minres_qlp = (:x0,) kwargs_minres_qlp = (:M, :ldiv, :λ, :atol, :rtol, :Artol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function minres_qlp($(def_args_minres_qlp...), $(def_optargs_minres_qlp...); $(def_kwargs_minres_qlp...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = MinresQlpSolver(A, b) - warm_start!(solver, $(optargs_minres_qlp...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - minres_qlp!(solver, $(args_minres_qlp...); $(kwargs_minres_qlp...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - - function minres_qlp($(def_args_minres_qlp...); $(def_kwargs_minres_qlp...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = MinresQlpSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - minres_qlp!(solver, $(args_minres_qlp...); $(kwargs_minres_qlp...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - function minres_qlp!(solver :: MinresQlpSolver{T,FC,S}, $(def_args_minres_qlp...); $(def_kwargs_minres_qlp...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/qmr.jl b/src/qmr.jl index 2a1ad578c..66517f7e3 100644 --- a/src/qmr.jl +++ b/src/qmr.jl @@ -112,27 +112,6 @@ optargs_qmr = (:x0,) kwargs_qmr = (:c, :M, :N, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function qmr($(def_args_qmr...), $(def_optargs_qmr...); $(def_kwargs_qmr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = QmrSolver(A, b) - warm_start!(solver, $(optargs_qmr...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - qmr!(solver, $(args_qmr...); $(kwargs_qmr...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - - function qmr($(def_args_qmr...); $(def_kwargs_qmr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = QmrSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - qmr!(solver, $(args_qmr...); $(kwargs_qmr...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - function qmr!(solver :: QmrSolver{T,FC,S}, $(def_args_qmr...); $(def_kwargs_qmr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/tricg.jl b/src/tricg.jl index 99d714bdd..93b475623 100644 --- a/src/tricg.jl +++ b/src/tricg.jl @@ -134,27 +134,6 @@ optargs_tricg = (:x0, :y0) kwargs_tricg = (:M, :N, :ldiv, :spd, :snd, :flip, :τ, :ν, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function tricg($(def_args_tricg...), $(def_optargs_tricg...); $(def_kwargs_tricg...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = TricgSolver(A, b) - warm_start!(solver, $(optargs_tricg...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - tricg!(solver, $(args_tricg...); $(kwargs_tricg...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.y, solver.stats) - end - - function tricg($(def_args_tricg...); $(def_kwargs_tricg...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = TricgSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - tricg!(solver, $(args_tricg...); $(kwargs_tricg...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.y, solver.stats) - end - function tricg!(solver :: TricgSolver{T,FC,S}, $(def_args_tricg...); $(def_kwargs_tricg...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/trilqr.jl b/src/trilqr.jl index 042db2604..472234def 100644 --- a/src/trilqr.jl +++ b/src/trilqr.jl @@ -103,27 +103,6 @@ optargs_trilqr = (:x0, :y0) kwargs_trilqr = (:transfer_to_usymcg, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function trilqr($(def_args_trilqr...), $(def_optargs_trilqr...); $(def_kwargs_trilqr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = TrilqrSolver(A, b) - warm_start!(solver, $(optargs_trilqr...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - trilqr!(solver, $(args_trilqr...); $(kwargs_trilqr...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.y, solver.stats) - end - - function trilqr($(def_args_trilqr...); $(def_kwargs_trilqr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = TrilqrSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - trilqr!(solver, $(args_trilqr...); $(kwargs_trilqr...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.y, solver.stats) - end - function trilqr!(solver :: TrilqrSolver{T,FC,S}, $(def_args_trilqr...); $(def_kwargs_trilqr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/trimr.jl b/src/trimr.jl index 780265e4a..e30e2cb01 100644 --- a/src/trimr.jl +++ b/src/trimr.jl @@ -135,27 +135,6 @@ optargs_trimr = (:x0, :y0) kwargs_trimr = (:M, :N, :ldiv, :spd, :snd, :flip, :sp, :τ, :ν, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function trimr($(def_args_trimr...), $(def_optargs_trimr...); $(def_kwargs_trimr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = TrimrSolver(A, b) - warm_start!(solver, $(optargs_trimr...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - trimr!(solver, $(args_trimr...); $(kwargs_trimr...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.y, solver.stats) - end - - function trimr($(def_args_trimr...); $(def_kwargs_trimr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = TrimrSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - trimr!(solver, $(args_trimr...); $(kwargs_trimr...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.y, solver.stats) - end - function trimr!(solver :: TrimrSolver{T,FC,S}, $(def_args_trimr...); $(def_kwargs_trimr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/usymlq.jl b/src/usymlq.jl index 73d6c7114..711e60938 100644 --- a/src/usymlq.jl +++ b/src/usymlq.jl @@ -112,27 +112,6 @@ optargs_usymlq = (:x0,) kwargs_usymlq = (:transfer_to_usymcg, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function usymlq($(def_args_usymlq...), $(def_optargs_usymlq...); $(def_kwargs_usymlq...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = UsymlqSolver(A, b) - warm_start!(solver, $(optargs_usymlq...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - usymlq!(solver, $(args_usymlq...); $(kwargs_usymlq...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - - function usymlq($(def_args_usymlq...); $(def_kwargs_usymlq...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = UsymlqSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - usymlq!(solver, $(args_usymlq...); $(kwargs_usymlq...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - function usymlq!(solver :: UsymlqSolver{T,FC,S}, $(def_args_usymlq...); $(def_kwargs_usymlq...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer diff --git a/src/usymqr.jl b/src/usymqr.jl index de69ffea0..3c81ba444 100644 --- a/src/usymqr.jl +++ b/src/usymqr.jl @@ -115,27 +115,6 @@ optargs_usymqr = (:x0,) kwargs_usymqr = (:atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream) @eval begin - function usymqr($(def_args_usymqr...), $(def_optargs_usymqr...); $(def_kwargs_usymqr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = UsymqrSolver(A, b) - warm_start!(solver, $(optargs_usymqr...)) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - usymqr!(solver, $(args_usymqr...); $(kwargs_usymqr...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - - function usymqr($(def_args_usymqr...); $(def_kwargs_usymqr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}} - start_time = time_ns() - solver = UsymqrSolver(A, b) - elapsed_time = ktimer(start_time) - timemax -= elapsed_time - usymqr!(solver, $(args_usymqr...); $(kwargs_usymqr...)) - solver.stats.timer += elapsed_time - return (solver.x, solver.stats) - end - function usymqr!(solver :: UsymqrSolver{T,FC,S}, $(def_args_usymqr...); $(def_kwargs_usymqr...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} # Timer