Actual source code: borthog.c

  1: /*$Id: borthog.c,v 1.58 2001/08/07 03:03:51 balay Exp $*/
  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/sles/ksp/impls/gmres/gmresp.h

 11: /*
 12:     This is the basic orthogonalization routine using modified Gram-Schmidt.
 13:  */
 14: int KSPGMRESModifiedGramSchmidtOrthogonalization(KSP ksp,int it)
 15: {
 16:   KSP_GMRES *gmres = (KSP_GMRES *)(ksp->data);
 17:   int       ierr,j;
 18:   PetscScalar    *hh,*hes,tmp;

 21:   PetscLogEventBegin(KSP_GMRESOrthogonalization,ksp,0,0,0);
 22:   /* update Hessenberg matrix and do Gram-Schmidt */
 23:   hh  = HH(0,it);
 24:   hes = HES(0,it);
 25:   for (j=0; j<=it; j++) {
 26:     /* (vv(it+1), vv(j)) */
 27:     ierr   = VecDot(VEC_VV(it+1),VEC_VV(j),hh);
 28:     *hes++ = *hh;
 29:     /* vv(it+1) <- vv(it+1) - hh[it+1][j] vv(j) */
 30:     tmp    = - (*hh++);
 31:     ierr   = VecAXPY(&tmp,VEC_VV(j),VEC_VV(it+1));
 32:   }
 33:   PetscLogEventEnd(KSP_GMRESOrthogonalization,ksp,0,0,0);
 34:   return(0);
 35: }