/
krylov.jl
57 lines (43 loc) · 1.5 KB
/
krylov.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
module TlpKrylov
using LinearAlgebra
using Krylov
using LinearOperators
const LO = LinearOperators
using ..KKT: AbstractKKTBackend, AbstractKKTSolver
using ..KKT: AbstractKKTSystem, K1, K2
import ..KKT: arithmetic, backend, linear_system
import ..KKT: setup, update!, solve!
include("defs.jl")
"""
Backend{KS<:Krylov.KrylovSolver,V<:AbstractVector}
[Krylov.jl](https://github.com/JuliaSmoothOptimizers/Krylov.jl)-based backend for solving linear systems.
The type is parametrized by:
* `KS<:Krylov.KrylovSolver`: workspace type for the Krylov method.
Also defines the Krylov method to be used.
* `V<:AbstractVector`: the vector storage type used within the Krylov method.
This should be set to `Vector{T}` (for arithmetic `T`) unless, e.g., one uses a GPU.
See the [Krylov.jl documentation](https://juliasmoothoptimizers.github.io/Krylov.jl/dev/inplace/) for further details.
# Example usage
All the following examples assume everything runs on a CPU in `Float64` arithmetic.
* To use the conjugate gradient:
```julia
backend = KKT.TlpKrylov.Backend(Krylov.CgSolver, Vector{Float64})
```
* To use MINRES:
```julia
backend = KKT.TlpKrylov.Backend(Krylov.MinresSolver, Vector{Float64})
```
"""
struct Backend{KS,V} <: AbstractKKTBackend
krylov_solver::Type{KS}
vector_storage::Type{V}
end
"""
AbstractKrylovSolver{T}
Abstract type for Kyrlov-based linear solvers.
"""
abstract type AbstractKrylovSolver{T} <: AbstractKKTSolver{T} end
include("spd.jl")
include("sid.jl")
include("sqd.jl")
end # module