Skip to content

Commit

Permalink
An implementation of USYMLQR
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Oct 31, 2024
1 parent c3ea5a2 commit f3bc587
Show file tree
Hide file tree
Showing 24 changed files with 856 additions and 166 deletions.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ makedocs(
"MINARES" => "examples/minares.md",
"TriCG" => "examples/tricg.md",
"TriMR" => "examples/trimr.md",
"USYMLQR" => "examples/usymlqr.md",
"BICGSTAB" => "examples/bicgstab.md",
"DQGMRES" => "examples/dqgmres.md",
"BLOCK-GMRES" => "examples/block_gmres.md",
Expand Down
1 change: 1 addition & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ DqgmresSolver
GmresSolver
UsymlqSolver
UsymqrSolver
UsymlqrSolver
TricgSolver
TrimrSolver
TrilqrSolver
Expand Down
25 changes: 25 additions & 0 deletions docs/src/examples/usymlqr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
```@example usymlqr
using Krylov, LinearOperators
using LinearAlgebra, Printf, SparseArrays
# Identity matrix.
eye(n::Int) = sparse(1.0 * I, n, n)
# Saddle-point systems
n = m = 5
A = [2^(i/j)*j + (-1)^(i-j) * n*(i-1) for i = 1:n, j = 1:n]
b = ones(n)
D = diagm(0 => [2.0 * i for i = 1:n])
m, n = size(A)
c = -b
# [D A] [x] = [b]
# [Aᴴ 0] [y] [c]
opH = BlockDiagonalOperator(inv(D), eye(n))
(x, y, stats) = usymlqr(A, b, c, M=D, ldiv=true)
K = [D A; A' zeros(n,n)]
B = [b; c]
r = B - K * [x; y]
resid = sqrt(dot(r, opH * r))
@printf("USYMLQR: Relative residual: %8.1e\n", resid)
```
2 changes: 1 addition & 1 deletion docs/src/matrix_free.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Some methods only require `A * v` products, whereas other ones also require `A'
| CG, CR, CAR | CGLS, CRLS, CGNE, CRMR |
| SYMMLQ, CG-LANCZOS, MINRES, MINRES-QLP, MINARES | LSLQ, LSQR, LSMR, LNLQ, CRAIG, CRAIGMR |
| DIOM, FOM, DQGMRES, GMRES, FGMRES, BLOCK-GMRES | BiLQ, QMR, BiLQR, USYMLQ, USYMQR, TriLQR |
| CGS, BICGSTAB | TriCG, TriMR |
| CGS, BICGSTAB | TriCG, TriMR, USYMLQR |
| CG-LANCZOS-SHIFT | CGLS-LANCZOS-SHIFT |

!!! info
Expand Down
2 changes: 1 addition & 1 deletion docs/src/preconditioners.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Methods concerned: [`CGNE`](@ref cgne), [`CRMR`](@ref crmr), [`LNLQ`](@ref lnlq)

### Saddle-point and symmetric quasi-definite systems

[`TriCG`](@ref tricg) and [`TriMR`](@ref trimr) can take advantage of the structure of Hermitian systems $Kz = d$ with the 2x2 block structure
[`TriCG`](@ref tricg), [`TriMR`](@ref trimr) and [`USYMLQR`](@ref usymlqr) can take advantage of the structure of Hermitian systems $Kz = d$ with the 2x2 block structure
```math
\begin{bmatrix} \tau E & \phantom{-}A \\ A^H & \nu F \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} b \\ c \end{bmatrix},
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/processes.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ T_{k,k+1} =

The function [`saunders_simon_yip`](@ref saunders_simon_yip(::Any, ::AbstractVector{FC}, ::AbstractVector{FC}, ::Int) where FC <: (Union{Complex{T}, T} where T <: AbstractFloat)) returns $V_{k+1}$, $\beta_1$, $T_{k+1,k}$, $U_{k+1}$, $\bar{\gamma}_1$ and $T_{k,k+1}^H$.

Related methods: [`USYMLQ`](@ref usymlq), [`USYMQR`](@ref usymqr), [`TriLQR`](@ref trilqr), [`TriCG`](@ref tricg) and [`TriMR`](@ref trimr).
Related methods: [`USYMLQ`](@ref usymlq), [`USYMQR`](@ref usymqr), [`USYMLQR`](@ref usymlqr), [`TriLQR`](@ref trilqr), [`TriCG`](@ref tricg) and [`TriMR`](@ref trimr).

!!! note
The Saunders-Simon-Yip is equivalent to the block-Lanczos process applied to $\begin{bmatrix} 0 & A \\ A^H & 0 \end{bmatrix}$ with initial matrix $\begin{bmatrix} b & 0 \\ 0 & c \end{bmatrix}$.
Expand Down
7 changes: 7 additions & 0 deletions docs/src/solvers/sp_sqd.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@ tricg!
trimr
trimr!
```

## USYMLQR

```@docs
usymlqr!
usymlqr
```
6 changes: 3 additions & 3 deletions docs/src/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ Each table summarizes the storage requirements of Krylov methods recommended to

#### Saddle-point and Hermitian quasi-definite systems

| Methods | [`TriCG`](@ref tricg) | [`TriMR`](@ref trimr) |
|:--------:|:---------------------:|:---------------------:|
| Storage | $6n + 6m$ | $8n + 8m$ |
| Methods | [`TriCG`](@ref tricg) | [`TriMR`](@ref trimr) | [`USYMLQR`](@ref usymlqr) |
|:--------:|:---------------------:|:---------------------:|:-------------------------:|
| Storage | $6n + 6m$ | $8n + 8m$ | $7n + 6m$ |

#### Generalized saddle-point and non-Hermitian partitioned systems

Expand Down
1 change: 1 addition & 0 deletions src/Krylov.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ include("gpmr.jl")

include("usymlq.jl")
include("usymqr.jl")
include("usymlqr.jl")
include("tricg.jl")
include("trimr.jl")
include("trilqr.jl")
Expand Down
6 changes: 3 additions & 3 deletions src/block_krylov_solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ const BLOCK_KRYLOV_SOLVERS = Dict(:block_gmres => :BlockGmresSolver)
abstract type BlockKrylovSolver{T,FC,SV,SM} end

"""
Type for storing the vectors required by the in-place version of BLOCK-GMRES.
Workspace for the in-place version of BLOCK-GMRES.
The outer constructors
The outer constructors:
solver = BlockGmresSolver(m, n, p, memory, SV, SM)
solver = BlockGmresSolver(A, B, memory = 5)
may be used in order to create these vectors.
can be used to initialize this workspace.
`memory` is set to `div(n,p)` if the value given is larger than `div(n,p)`.
`memory` is an optional argument in the second constructor.
"""
Expand Down
69 changes: 35 additions & 34 deletions src/krylov_solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,41 @@ function solve! end

# Krylov methods
for (workspace, krylov, 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 )
(: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 )
(: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 )
(: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 )
(:UsymlqrSolver , :usymlqr , args_usymlqr , def_args_usymlqr , optargs_usymlqr , def_optargs_usymlqr , kwargs_usymlqr , def_kwargs_usymlqr )
(:CgLanczosShiftSolver , :cg_lanczos_shift , args_cg_lanczos_shift , def_args_cg_lanczos_shift , (), (), kwargs_cg_lanczos_shift , def_kwargs_cg_lanczos_shift )
(:CglsLanczosShiftSolver, :cgls_lanczos_shift, args_cgls_lanczos_shift, def_args_cgls_lanczos_shift, (), (), kwargs_cgls_lanczos_shift, def_kwargs_cgls_lanczos_shift)
]
Expand Down
Loading

0 comments on commit f3bc587

Please sign in to comment.