Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions src/gmres.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ and [`krylov_solve!`](@ref) to run the Krylov method in-place.
function gmres! end

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

def_optargs_gmres = (:(x0::AbstractVector),)
def_optargs_gmres = (:(x0::AbstractArray{FC}),)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't to force FC because sometimes we warm-start from a solution in lower precision.
We could use a direct solver in Float32 to compute a very good approximate and then get more digits with a Krylov solvers.


def_kwargs_gmres = (:(; M = I ),
:(; N = I ),
Expand All @@ -114,7 +114,7 @@ optargs_gmres = (:x0,)
kwargs_gmres = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rtol, :itmax, :timemax, :verbose, :history, :callback, :iostream)

@eval begin
function gmres!(workspace :: GmresWorkspace{T,FC,S}, $(def_args_gmres...); $(def_kwargs_gmres...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}}
function gmres!(workspace :: GmresWorkspace{T,FC,S}, $(def_args_gmres...); $(def_kwargs_gmres...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractArray{FC}}

# Timer
start_time = time_ns()
Expand Down
4 changes: 2 additions & 2 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@ for (workspace, krylov, args, def_args, optargs, def_optargs, kwargs, def_kwargs
end

## In-place
@eval krylov_solve!(workspace :: $workspace{T,FC,S}, $(def_args...); $(def_kwargs...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}} = $(krylov!)(workspace, $(args...); $(kwargs...))
@eval krylov_solve!(workspace :: $workspace{T,FC,S}, $(def_args...); $(def_kwargs...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractArray{FC}} = $(krylov!)(workspace, $(args...); $(kwargs...))

for krylov_ip in (:krylov_solve!, krylov!)
@eval begin
if !isempty($optargs)
function $(krylov_ip)(workspace :: $workspace{T,FC,S}, $(def_args...), $(def_optargs...); $(def_kwargs...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractVector{FC}}
function $(krylov_ip)(workspace :: $workspace{T,FC,S}, $(def_args...), $(def_optargs...); $(def_kwargs...)) where {T <: AbstractFloat, FC <: FloatOrComplex{T}, S <: AbstractArray{FC}}
start_time = time_ns()
warm_start!(workspace, $(optargs...))
elapsed_time = start_time |> ktimer
Expand Down
Loading