Actual source code: borthog2.c

  1: /*$Id: borthog2.c,v 1.20 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 version uses UNMODIFIED Gram-Schmidt.  It is NOT always recommended, 
 13:   but it can give MUCH better performance than the default modified form
 14:   when running in a parallel environment.
 15:  */
 16: #undef __FUNCT__  
 18: int KSPGMRESUnmodifiedGramSchmidtOrthogonalization(KSP  ksp,int it)
 19: {
 20:   KSP_GMRES *gmres = (KSP_GMRES *)(ksp->data);
 21:   int       j,ierr;
 22:   PetscScalar    *hh,*hes;

 25:   PetscLogEventBegin(KSP_GMRESOrthogonalization,ksp,0,0,0);
 26:   /* update Hessenberg matrix and do unmodified Gram-Schmidt */
 27:   hh  = HH(0,it);
 28:   hes = HES(0,it);

 30:   /* 
 31:    This is really a matrix-vector product, with the matrix stored
 32:    as pointer to rows 
 33:   */
 34:   VecMDot(it+1,VEC_VV(it+1),&(VEC_VV(0)),hes);

 36:   /*
 37:     This is really a matrix-vector product: 
 38:         [h[0],h[1],...]*[ v[0]; v[1]; ...] subtracted from v[it+1].
 39:   */
 40:   for (j=0; j<=it; j++) hh[j] = -hes[j];
 41:   VecMAXPY(it+1,hh,VEC_VV(it+1),&VEC_VV(0));
 42:   for (j=0; j<=it; j++) hh[j] = -hh[j];
 43:   PetscLogEventEnd(KSP_GMRESOrthogonalization,ksp,0,0,0);
 44:   return(0);
 45: }