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: int KSPGMRESUnmodifiedGramSchmidtOrthogonalization(KSP  ksp,int it)
 17: {
 18:   KSP_GMRES *gmres = (KSP_GMRES *)(ksp->data);
 19:   int       j,ierr;
 20:   PetscScalar    *hh,*hes;

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

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

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