ext/cvode/source/cvbandpre.c
int CVBandPrecond(integer N, real t, N_Vector y, N_Vector fy,
                  boole jok, boole *jcurPtr, real gamma,
                  N_Vector ewt, real h, real uround,
                  long int *nfePtr, void *bp_data,
                  N_Vector vtemp1, N_Vector vtemp2,
                  N_Vector vtemp3)
{
  integer ier;
  CVBandPreData pdata;

  /* Assume matrix and pivots have already been allocated. */
  pdata = (CVBandPreData) bp_data;

  if (jok) {
    /* If jok = TRUE, use saved copy of J. */
    *jcurPtr = FALSE;
    BandCopy(savedJ, savedP, mu, ml);
  } else {
    /* If jok = FALSE, call CVBandPDQJac for new J value. */
    *jcurPtr = TRUE;
    BandZero(savedJ);
    CVBandPDQJac(N, mu, ml, savedJ, f, f_data, t, y, fy, ewt,
	         h, uround, vtemp1, vtemp2);
    BandCopy(savedJ, savedP, mu, ml);
    *nfePtr += MIN( N, ml + mu + 1 );
  }
  
  /* Scale and add I to get savedP = I - gamma*J. */
  BandScale(-gamma, savedP);
  BandAddI(savedP);
 
  /* Do LU factorization of matrix. */
  ier = BandFactor(savedP, pivots);
 
  /* Return 0 if the LU was complete; otherwise return 1. */
  if (ier > 0) return(1);
  return(0);
}
/******************************************************************
 * Together CVBandPrecond and CVBandPSolve use a banded           *
 * difference quotient Jacobian to create a preconditioner.       *
 * CVBandPrecond calculates a new J, if necessary, then           *
 * calculates P = I - gamma*J, and does an LU factorization of P. *
 *                                                                *
 * The parameters of CVBandPrecond are as follows:                *
 *                                                                *
 * N       is the length of all vector arguments.                 *
 *                                                                *
 * t       is the current value of the independent variable.      *
 *                                                                *
 * y       is the current value of the dependent variable vector, *
 *           namely the predicted value of y(t).                  *
 *                                                                *
 * fy      is the vector f(t,y).                                  *
 *                                                                *
 * jok     is an input flag indicating whether Jacobian-related   *
 *         data needs to be recomputed, as follows:               *
 *           jok == FALSE means recompute Jacobian-related data   *
 *                  from scratch.                                 *
 *           jok == TRUE  means that Jacobian data from the       *
 *                  previous Precond call will be reused          *
 *                  (with the current value of gamma).            *
 *         A CVBandPrecond call with jok == TRUE should only      *
 *         occur after a call with jok == FALSE.                  *
 *                                                                *
 * jcurPtr is a pointer to an output integer flag which is        *
 *         set by CVBandPrecond as follows:                       *
 *           *jcurPtr = TRUE if Jacobian data was recomputed.     *
 *           *jcurPtr = FALSE if Jacobian data was not recomputed,*
 *                      but saved data was reused.                *
 *                                                                *
 * gamma   is the scalar appearing in the Newton matrix.          *
 *                                                                *
 * ewt     is the error weight vector.                            *
 *                                                                *
 * h       is a tentative step size in t.                         *
 *                                                                *
 * uround  is the machine unit roundoff.                          *
 *                                                                *
 * nfePtr  is a pointer to the memory location containing the     *
 *           CVODE problem data nfe = number of calls to f.       *
 *           The routine calls f a total of ml+mu+1 times, so     *
 *           it increments *nfePtr by ml+mu+1.                    *
 *                                                                *
 * bp_data is a pointer to preconditoner data - the same as the   *
 *            bp_data parameter passed to CVSpgmr.                *
 *                                                                *
 * vtemp1, vtemp2, and vtemp3 are pointers to memory allocated    *
 *           for vectors of length N for work space.  This        *
 *           routine uses only vtemp1 and vtemp2.                 *
 *                                                                *
 *                                                                *
 * The value to be returned by the CVBandPrecond function is      *
 *   0  if successful, or                                         *
 *   1  if the band factorization failed.                         *
 ******************************************************************/
Together CVBandPrecond and CVBandPSolve use a banded
difference quotient Jacobian to create a preconditioner.
CVBandPrecond calculates a new J, if necessary, then
calculates P = I - gamma*J, and does an LU factorization of P.

The parameters of CVBandPrecond are as follows:

N       is the length of all vector arguments.

t       is the current value of the independent variable.

y       is the current value of the dependent variable vector,
namely the predicted value of y(t).

fy      is the vector f(t,y).

jok     is an input flag indicating whether Jacobian-related
data needs to be recomputed, as follows:
jok == FALSE means recompute Jacobian-related data
from scratch.
jok == TRUE  means that Jacobian data from the
previous Precond call will be reused
(with the current value of gamma).
A CVBandPrecond call with jok == TRUE should only
occur after a call with jok == FALSE.

jcurPtr is a pointer to an output integer flag which is
set by CVBandPrecond as follows:
*jcurPtr = TRUE if Jacobian data was recomputed.
*jcurPtr = FALSE if Jacobian data was not recomputed,
but saved data was reused.

gamma   is the scalar appearing in the Newton matrix.

ewt     is the error weight vector.

h       is a tentative step size in t.

uround  is the machine unit roundoff.

nfePtr  is a pointer to the memory location containing the
CVODE problem data nfe = number of calls to f.
The routine calls f a total of ml+mu+1 times, so
it increments *nfePtr by ml+mu+1.

bp_data is a pointer to preconditoner data - the same as the
bp_data parameter passed to CVSpgmr.

vtemp1, vtemp2, and vtemp3 are pointers to memory allocated
for vectors of length N for work space.  This
routine uses only vtemp1 and vtemp2.


The value to be returned by the CVBandPrecond function is
0  if successful, or
1  if the band factorization failed.
Together CVBandPrecond and CVBandPSolve use a banded difference quotient Jacobian to create a preconditioner . CVBandPrecond calculates a new J if necessary then calculates P = I - gamma * J and does an LU factorization of P . The parameters of CVBandPrecond are as follows : N is the length of all vector arguments . t is the current value of the independent variable . y is the current value of the dependent variable vector namely the predicted value of y ( t ) . fy is the vector f ( t y ) . jok is an input flag indicating whether Jacobian - related data needs to be recomputed as follows : jok == FALSE means recompute Jacobian - related data from scratch . jok == TRUE means that Jacobian data from the previous Precond call will be reused ( with the current value of gamma ) . A CVBandPrecond call with jok == TRUE should only occur after a call with jok == FALSE . jcurPtr is a pointer to an output integer flag which is set by CVBandPrecond as follows : * jcurPtr = TRUE if Jacobian data was recomputed . * jcurPtr = FALSE if Jacobian data was not recomputed but saved data was reused . gamma is the scalar appearing in the Newton matrix . ewt is the error weight vector . h is a tentative step size in t . uround is the machine unit roundoff . nfePtr is a pointer to the memory location containing the CVODE problem data nfe = number of calls to f . The routine calls f a total of ml + mu + 1 times so it increments * nfePtr by ml + mu + 1 . bp_data is a pointer to preconditoner data - the same as the bp_data parameter passed to CVSpgmr . vtemp1 vtemp2 and vtemp3 are pointers to memory allocated for vectors of length N for work space . This routine uses only vtemp1 and vtemp2 . The value to be returned by the CVBandPrecond function is 0 if successful or 1 if the band factorization failed .
int CVBandPrecond(integer N, real t, N_Vector y, N_Vector fy,
                  boole jok, boole *jcurPtr, real gamma,
                  N_Vector ewt, real h, real uround,
                  long int *nfePtr, void *bp_data,
                  N_Vector vtemp1, N_Vector vtemp2,
                  N_Vector vtemp3)
{
  integer ier;
  CVBandPreData pdata;
  pdata = (CVBandPreData) bp_data;
  if (jok) {
    *jcurPtr = FALSE;
    BandCopy(savedJ, savedP, mu, ml);
  } else {
    *jcurPtr = TRUE;
    BandZero(savedJ);
    CVBandPDQJac(N, mu, ml, savedJ, f, f_data, t, y, fy, ewt,
	         h, uround, vtemp1, vtemp2);
    BandCopy(savedJ, savedP, mu, ml);
    *nfePtr += MIN( N, ml + mu + 1 );
  }
  BandScale(-gamma, savedP);
  BandAddI(savedP);
  ier = BandFactor(savedP, pivots);
  if (ier > 0) return(1);
  return(0);
}
int CVBandPrecond ( integer N , real t , N_Vector y , N_Vector fy , boole jok , boole * jcurPtr , real gamma , N_Vector ewt , real h , real uround , long int * nfePtr , void * bp_data , N_Vector vtemp1 , N_Vector vtemp2 , N_Vector vtemp3 ) { integer ier ; CVBandPreData pdata ; pdata = ( CVBandPreData ) bp_data ; if ( jok ) { * jcurPtr = FALSE ; BandCopy ( savedJ , savedP , mu , ml ) ; } else { * jcurPtr = TRUE ; BandZero ( savedJ ) ; CVBandPDQJac ( N , mu , ml , savedJ , f , f_data , t , y , fy , ewt , h , uround , vtemp1 , vtemp2 ) ; BandCopy ( savedJ , savedP , mu , ml ) ; * nfePtr += MIN ( N , ml + mu + 1 ) ; } BandScale ( - gamma , savedP ) ; BandAddI ( savedP ) ; ier = BandFactor ( savedP , pivots ) ; if ( ier > 0 ) return ( 1 ) ; return ( 0 ) ; }
Together CVBandPrecond and CVBandPSolve use a banded           
 difference quotient Jacobian to create a preconditioner.
Together CVBandPrecond and CVBandPSolve use a banded difference quotient Jacobian to create a preconditioner .
/* Assume matrix and pivots have already been allocated. */ /* If jok = TRUE, use saved copy of J. */ /* If jok = FALSE, call CVBandPDQJac for new J value. */ /* Scale and add I to get savedP = I - gamma*J. */ /* Do LU factorization of matrix. */ /* Return 0 if the LU was complete; otherwise return 1. */