ext/cvode/source/cvspgmr.c
static int CVSpgmrSolve(CVodeMem cv_mem, N_Vector b, N_Vector ynow,
			N_Vector fnow)
{
  real bnorm, res_norm;
  CVSpgmrMem cvspgmr_mem;
  int nli_inc, nps_inc, ier;
  
  cvspgmr_mem = (CVSpgmrMem) lmem;

  /* Test norm(b); if small, return x = 0 or x = b */
  deltar = delt*tq[4]; 
  bnorm = N_VWrmsNorm(b, ewt);
  if (bnorm <= deltar) {
    if (mnewt > 0) N_VConst(ZERO, b); 
    return(0);
  }

  /* Set vectors ycur and fcur for use by the Atimes and Psolve routines */
  ycur = ynow;
  fcur = fnow;

  /* Set inputs delta and initial guess x = 0 to SpgmrSolve */  
  delta = deltar * sqrtN;
  N_VConst(ZERO, x);
  
  /* Call SpgmrSolve and copy x to b */
  ier = SpgmrSolve(spgmr_mem, cv_mem, x, b, pretype, gstype, delta, 0,
		   cv_mem, ewt, ewt, CVSpgmrAtimesDQ, CVSpgmrPSolve,
		   &res_norm, &nli_inc, &nps_inc);
  N_VScale(ONE, x, b);
  
  /* Increment counters nli, nps, and ncfl */
  nli += nli_inc;
  nps += nps_inc;
  if (iopt != NULL) {
    iopt[SPGMR_NLI] = nli;
    iopt[SPGMR_NPS] = nps;
  }  
  if (ier != 0) { 
    ncfl++;
    if (iopt != NULL) iopt[SPGMR_NCFL] = ncfl;
  }

  /* Set return value to -1, 0, or 1 */
  if (ier < 0) return(-1);  
  if ((ier == SPGMR_SUCCESS) || 
      ((ier == SPGMR_RES_REDUCED) && (mnewt == 0)))
    return(0);
  return(1);  
}
/*************** CVSpgmrSolve ****************************************

 This routine handles the call to the generic solver SpgmrSolve
 for the solution of the linear system Ax = b with the SPGMR method,
 without restarts.  The solution x is returned in the vector b.

 If the WRMS norm of b is small, we return x = b (if this is the first
 Newton iteration) or x = 0 (if a later Newton iteration).

 Otherwise, we set the tolerance parameter and initial guess (x = 0),
 call SpgmrSolve, and copy the solution x into b.  The x-scaling and
 b-scaling arrays are both equal to ewt, and no restarts are allowed.

 The counters nli, nps, and ncfl are incremented, and the return value
 is set according to the success of SpgmrSolve.  The success flag is
 returned if SpgmrSolve converged, or if this is the first Newton
 iteration and the residual norm was reduced below its initial value.

**********************************************************************/
CVSpgmrSolve
This routine handles the call to the generic solver SpgmrSolve
for the solution of the linear system Ax = b with the SPGMR method,
without restarts.  The solution x is returned in the vector b.

If the WRMS norm of b is small, we return x = b (if this is the first
Newton iteration) or x = 0 (if a later Newton iteration).

Otherwise, we set the tolerance parameter and initial guess (x = 0),
call SpgmrSolve, and copy the solution x into b.  The x-scaling and
b-scaling arrays are both equal to ewt, and no restarts are allowed.

The counters nli, nps, and ncfl are incremented, and the return value
is set according to the success of SpgmrSolve.  The success flag is
returned if SpgmrSolve converged, or if this is the first Newton
iteration and the residual norm was reduced below its initial value.
CVSpgmrSolve This routine handles the call to the generic solver SpgmrSolve for the solution of the linear system Ax = b with the SPGMR method without restarts . The solution x is returned in the vector b . If the WRMS norm of b is small we return x = b ( if this is the first Newton iteration ) or x = 0 ( if a later Newton iteration ) . Otherwise we set the tolerance parameter and initial guess ( x = 0 ) call SpgmrSolve and copy the solution x into b . The x - scaling and b - scaling arrays are both equal to ewt and no restarts are allowed . The counters nli nps and ncfl are incremented and the return value is set according to the success of SpgmrSolve . The success flag is returned if SpgmrSolve converged or if this is the first Newton iteration and the residual norm was reduced below its initial value .
static int CVSpgmrSolve(CVodeMem cv_mem, N_Vector b, N_Vector ynow,
			N_Vector fnow)
{
  real bnorm, res_norm;
  CVSpgmrMem cvspgmr_mem;
  int nli_inc, nps_inc, ier;
  cvspgmr_mem = (CVSpgmrMem) lmem;
  deltar = delt*tq[4]; 
  bnorm = N_VWrmsNorm(b, ewt);
  if (bnorm <= deltar) {
    if (mnewt > 0) N_VConst(ZERO, b); 
    return(0);
  }
  ycur = ynow;
  fcur = fnow;
  delta = deltar * sqrtN;
  N_VConst(ZERO, x);
  ier = SpgmrSolve(spgmr_mem, cv_mem, x, b, pretype, gstype, delta, 0,
		   cv_mem, ewt, ewt, CVSpgmrAtimesDQ, CVSpgmrPSolve,
		   &res_norm, &nli_inc, &nps_inc);
  N_VScale(ONE, x, b);
  nli += nli_inc;
  nps += nps_inc;
  if (iopt != NULL) {
    iopt[SPGMR_NLI] = nli;
    iopt[SPGMR_NPS] = nps;
  }  
  if (ier != 0) { 
    ncfl++;
    if (iopt != NULL) iopt[SPGMR_NCFL] = ncfl;
  }
  if (ier < 0) return(-1);  
  if ((ier == SPGMR_SUCCESS) || 
      ((ier == SPGMR_RES_REDUCED) && (mnewt == 0)))
    return(0);
  return(1);  
}
static int CVSpgmrSolve ( CVodeMem cv_mem , N_Vector b , N_Vector ynow , N_Vector fnow ) { real bnorm , res_norm ; CVSpgmrMem cvspgmr_mem ; int nli_inc , nps_inc , ier ; cvspgmr_mem = ( CVSpgmrMem ) lmem ; deltar = delt * tq [ 4 ] ; bnorm = N_VWrmsNorm ( b , ewt ) ; if ( bnorm <= deltar ) { if ( mnewt > 0 ) N_VConst ( ZERO , b ) ; return ( 0 ) ; } ycur = ynow ; fcur = fnow ; delta = deltar * sqrtN ; N_VConst ( ZERO , x ) ; ier = SpgmrSolve ( spgmr_mem , cv_mem , x , b , pretype , gstype , delta , 0 , cv_mem , ewt , ewt , CVSpgmrAtimesDQ , CVSpgmrPSolve , & res_norm , & nli_inc , & nps_inc ) ; N_VScale ( ONE , x , b ) ; nli += nli_inc ; nps += nps_inc ; if ( iopt != NULL ) { iopt [ SPGMR_NLI ] = nli ; iopt [ SPGMR_NPS ] = nps ; } if ( ier != 0 ) { ncfl ++ ; if ( iopt != NULL ) iopt [ SPGMR_NCFL ] = ncfl ; } if ( ier < 0 ) return ( -1 ) ; if ( ( ier == SPGMR_SUCCESS ) || ( ( ier == SPGMR_RES_REDUCED ) && ( mnewt == 0 ) ) ) return ( 0 ) ; return ( 1 ) ; }
CVSpgmrSolve 
This routine handles the call to the generic solver SpgmrSolve
for the solution of the linear system Ax = b with the SPGMR method,
without restarts.
CVSpgmrSolve This routine handles the call to the generic solver SpgmrSolve for the solution of the linear system Ax = b with the SPGMR method without restarts .
/* Test norm(b); if small, return x = 0 or x = b */ /* Set vectors ycur and fcur for use by the Atimes and Psolve routines */ /* Set inputs delta and initial guess x = 0 to SpgmrSolve */ /* Call SpgmrSolve and copy x to b */ /* Increment counters nli, nps, and ncfl */ /* Set return value to -1, 0, or 1 */