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/ksp/ksp/impls/gmres/gmresp.h
11: /*
12: This is the basic orthogonalization routine using modified Gram-Schmidt.
13: */
16: int KSPGMRESModifiedGramSchmidtOrthogonalization(KSP ksp,int it)
17: {
18: KSP_GMRES *gmres = (KSP_GMRES *)(ksp->data);
19: int ierr,j;
20: PetscScalar *hh,*hes,tmp;
23: PetscLogEventBegin(KSP_GMRESOrthogonalization,ksp,0,0,0);
24: /* update Hessenberg matrix and do Gram-Schmidt */
25: hh = HH(0,it);
26: hes = HES(0,it);
27: for (j=0; j<=it; j++) {
28: /* (vv(it+1), vv(j)) */
29: VecDot(VEC_VV(it+1),VEC_VV(j),hh);
30: *hes++ = *hh;
31: /* vv(it+1) <- vv(it+1) - hh[it+1][j] vv(j) */
32: tmp = - (*hh++);
33: VecAXPY(&tmp,VEC_VV(j),VEC_VV(it+1));
34: }
35: PetscLogEventEnd(KSP_GMRESOrthogonalization,ksp,0,0,0);
36: return(0);
37: }