KSPComputeRitz#

Computes the Ritz or harmonic Ritz pairs associated with the smallest or largest in modulus, for the preconditioned operator.

Synopsis#

#include "petscksp.h" 
#include "petscmat.h" 
PetscErrorCode KSPComputeRitz(KSP ksp, PetscBool ritz, PetscBool small, PetscInt *nrit, Vec S[], PetscReal tetar[], PetscReal tetai[])

Not Collective

Input Parameters#

Output Parameters#

  • nrit - On input number of (harmonic) Ritz pairs to compute; on output, actual number of computed (harmonic) Ritz pairs

  • S - an array of the Ritz vectors, pass in an array of vectors of size nrit

  • tetar - real part of the Ritz values, pass in an array of size nrit

  • tetai - imaginary part of the Ritz values, pass in an array of size nrit

Notes#

This only works with a KSPType of KSPGMRES.

One must call KSPSetComputeRitz() before calling KSPSetUp() in order for this routine to work correctly.

This routine must be called after KSPSolve().

In GMRES, the (harmonic) Ritz pairs are computed from the Hessenberg matrix obtained during the last complete cycle of the GMRES solve, or during the partial cycle if the solve ended before a restart (that is a complete GMRES cycle was never achieved).

The number of actual (harmonic) Ritz pairs computed is less than or equal to the restart parameter for GMRES if a complete cycle has been performed or less or equal to the number of GMRES iterations.

KSPComputeEigenvalues() provides estimates for only the eigenvalues (Ritz values).

For real matrices, the (harmonic) Ritz pairs can be complex-valued. In such a case, the routine selects the complex (harmonic) Ritz value and its conjugate, and two successive entries of the vectors S are equal to the real and the imaginary parts of the associated vectors. When PETSc has been built with complex scalars, the real and imaginary parts of the Ritz values are still returned in tetar and tetai, as is done in KSPComputeEigenvalues(), but the Ritz vectors S are complex.

The (harmonic) Ritz pairs are given in order of increasing (harmonic) Ritz values in modulus.

The Ritz pairs do not necessarily accurately reflect the eigenvalues and eigenvectors of the operator, consider the excellent package SLEPc if accurate values are required.

See Also#

KSP: Linear System Solvers, KSPSetComputeRitz(), KSP, KSPGMRES, KSPComputeEigenvalues(), KSPSetComputeSingularValues(), KSPMonitorSingularValue()

Level#

advanced

Location#

src/ksp/ksp/interface/itfunc.c

Implementations#

KSPComputeRitz_GMRES in src/ksp/ksp/impls/gmres/gmreig.c


Edit on GitLab

Index of all KSP routines
Table of Contents for all manual pages
Index of all manual pages