Actual source code: borthog.c
petsc-3.10.5 2019-03-28
Report Typos and Errors

      2: /*
      3:     Routines used for the orthogonalization of the Hessenberg matrix.

      5:     Note that for the complex numbers version, the VecDot() and
      6:     VecMDot() arguments within the code MUST remain in the order
      7:     given for correct computation of inner products.
      8: */
      9:  #include <../src/ksp/ksp/impls/gmres/gmresimpl.h>

     11: /*@C
     12:      KSPGMRESModifiedGramSchmidtOrthogonalization -  This is the basic orthogonalization routine
     13:                 using modified Gram-Schmidt.

     15:      Collective on KSP

     17:   Input Parameters:
     18: +   ksp - KSP object, must be associated with GMRES, FGMRES, or LGMRES Krylov method
     19: -   its - one less then the current GMRES restart iteration, i.e. the size of the Krylov space

     21:    Options Database Keys:
     22: .  -ksp_gmres_modifiedgramschmidt - Activates KSPGMRESModifiedGramSchmidtOrthogonalization()

     24:    Level: intermediate

     26: .seealso:  KSPGMRESSetOrthogonalization(), KSPGMRESClassicalGramSchmidtOrthogonalization(), KSPGMRESGetOrthogonalization()

     28: @*/
     29: PetscErrorCode  KSPGMRESModifiedGramSchmidtOrthogonalization(KSP ksp,PetscInt it)
     30: {
     31:   KSP_GMRES      *gmres = (KSP_GMRES*)(ksp->data);
     33:   PetscInt       j;
     34:   PetscScalar    *hh,*hes;

     37:   PetscLogEventBegin(KSP_GMRESOrthogonalization,ksp,0,0,0);
     38:   /* update Hessenberg matrix and do Gram-Schmidt */
     39:   hh  = HH(0,it);
     40:   hes = HES(0,it);
     41:   for (j=0; j<=it; j++) {
     42:     /* (vv(it+1), vv(j)) */
     43:     VecDot(VEC_VV(it+1),VEC_VV(j),hh);
     44:     KSPCheckDot(ksp,*hh);
     45:     *hes++ = *hh;
     46:     /* vv(it+1) <- vv(it+1) - hh[it+1][j] vv(j) */
     47:     VecAXPY(VEC_VV(it+1),-(*hh++),VEC_VV(j));
     48:   }
     49:   PetscLogEventEnd(KSP_GMRESOrthogonalization,ksp,0,0,0);
     50:   return(0);
     51: }