ext/cvode/source/cvdense.c
void CVDenseDQJac(integer N, DenseMat J, RhsFn f, void *f_data, real tn,
		  N_Vector y, N_Vector fy, N_Vector ewt, real h, real uround,
		  void *jac_data, long int *nfePtr, N_Vector vtemp1,
		  N_Vector vtemp2, N_Vector vtemp3)
{
  real fnorm, minInc, inc, inc_inv, yjsaved, srur;
  real *y_data, *ewt_data;
  N_Vector ftemp, jthCol;
  integer j;

  ftemp = vtemp1; /* Rename work vector for use as f vector value */

  /* Obtain pointers to the data for ewt, y */
  ewt_data   = N_VDATA(ewt);
  y_data     = N_VDATA(y);

  /* Set minimum increment based on uround and norm of f */
  srur = RSqrt(uround);
  fnorm = N_VWrmsNorm(fy, ewt);
  minInc = (fnorm != ZERO) ?
           (MIN_INC_MULT * ABS(h) * uround * N * fnorm) : ONE;

  N_VMAKE(jthCol, y_data, N);  /* j loop overwrites this data address */

  /* This is the only for loop for 0..N-1 in CVODE */
  for (j = 0; j < N; j++) {

    /* Generate the jth col of J(tn,y) */
    
    N_VDATA(jthCol) = DENSE_COL(J,j);
    yjsaved = y_data[j];
    inc = MAX(srur*ABS(yjsaved), minInc/ewt_data[j]);
    y_data[j] += inc;
    f(N, tn, y, ftemp, f_data);
    inc_inv = ONE/inc;
    N_VLinearSum(inc_inv, ftemp, -inc_inv, fy, jthCol);
    y_data[j] = yjsaved;
  }

  N_VDISPOSE(jthCol);

  /* Increment counter nfe = *nfePtr */
  *nfePtr += N;
}
/*************** CVDenseDQJac ****************************************

 This routine generates a dense difference quotient approximation to
 the Jacobian of f(t,y). It assumes that a dense matrix of type
 DenseMat is stored column-wise, and that elements within each column
 are contiguous. The address of the jth column of J is obtained via
 the macro DENSE_COL and an N_Vector with the jth column as the
 component array is created using N_VMAKE and N_VDATA. Finally, the
 actual computation of the jth column of the Jacobian is done with a
 call to N_VLinearSum.

**********************************************************************/
CVDenseDQJac
This routine generates a dense difference quotient approximation to
the Jacobian of f(t,y). It assumes that a dense matrix of type
DenseMat is stored column-wise, and that elements within each column
are contiguous. The address of the jth column of J is obtained via
the macro DENSE_COL and an N_Vector with the jth column as the
component array is created using N_VMAKE and N_VDATA. Finally, the
actual computation of the jth column of the Jacobian is done with a
call to N_VLinearSum.
CVDenseDQJac This routine generates a dense difference quotient approximation to the Jacobian of f ( t y ) . It assumes that a dense matrix of type DenseMat is stored column - wise and that elements within each column are contiguous . The address of the jth column of J is obtained via the macro DENSE_COL and an N_Vector with the jth column as the component array is created using N_VMAKE and N_VDATA . Finally the actual computation of the jth column of the Jacobian is done with a call to N_VLinearSum .
void CVDenseDQJac(integer N, DenseMat J, RhsFn f, void *f_data, real tn,
		  N_Vector y, N_Vector fy, N_Vector ewt, real h, real uround,
		  void *jac_data, long int *nfePtr, N_Vector vtemp1,
		  N_Vector vtemp2, N_Vector vtemp3)
{
  real fnorm, minInc, inc, inc_inv, yjsaved, srur;
  real *y_data, *ewt_data;
  N_Vector ftemp, jthCol;
  integer j;
  ftemp = vtemp1; 
  ewt_data   = N_VDATA(ewt);
  y_data     = N_VDATA(y);
  srur = RSqrt(uround);
  fnorm = N_VWrmsNorm(fy, ewt);
  minInc = (fnorm != ZERO) ?
           (MIN_INC_MULT * ABS(h) * uround * N * fnorm) : ONE;
  N_VMAKE(jthCol, y_data, N);  
  for (j = 0; j < N; j++) {
    N_VDATA(jthCol) = DENSE_COL(J,j);
    yjsaved = y_data[j];
    inc = MAX(srur*ABS(yjsaved), minInc/ewt_data[j]);
    y_data[j] += inc;
    f(N, tn, y, ftemp, f_data);
    inc_inv = ONE/inc;
    N_VLinearSum(inc_inv, ftemp, -inc_inv, fy, jthCol);
    y_data[j] = yjsaved;
  }
  N_VDISPOSE(jthCol);
  *nfePtr += N;
}
void CVDenseDQJac ( integer N , DenseMat J , RhsFn f , void * f_data , real tn , N_Vector y , N_Vector fy , N_Vector ewt , real h , real uround , void * jac_data , long int * nfePtr , N_Vector vtemp1 , N_Vector vtemp2 , N_Vector vtemp3 ) { real fnorm , minInc , inc , inc_inv , yjsaved , srur ; real * y_data , * ewt_data ; N_Vector ftemp , jthCol ; integer j ; ftemp = vtemp1 ; ewt_data = N_VDATA ( ewt ) ; y_data = N_VDATA ( y ) ; srur = RSqrt ( uround ) ; fnorm = N_VWrmsNorm ( fy , ewt ) ; minInc = ( fnorm != ZERO ) ? ( MIN_INC_MULT * ABS ( h ) * uround * N * fnorm ) : ONE ; N_VMAKE ( jthCol , y_data , N ) ; for ( j = 0 ; j < N ; j ++ ) { N_VDATA ( jthCol ) = DENSE_COL ( J , j ) ; yjsaved = y_data [ j ] ; inc = MAX ( srur * ABS ( yjsaved ) , minInc / ewt_data [ j ] ) ; y_data [ j ] += inc ; f ( N , tn , y , ftemp , f_data ) ; inc_inv = ONE / inc ; N_VLinearSum ( inc_inv , ftemp , - inc_inv , fy , jthCol ) ; y_data [ j ] = yjsaved ; } N_VDISPOSE ( jthCol ) ; * nfePtr += N ; }
CVDenseDQJac 
This routine generates a dense difference quotient approximation to
the Jacobian of f(t,y).
CVDenseDQJac This routine generates a dense difference quotient approximation to the Jacobian of f ( t y ) .
/* Rename work vector for use as f vector value */ /* Obtain pointers to the data for ewt, y */ /* Set minimum increment based on uround and norm of f */ /* j loop overwrites this data address */ /* This is the only for loop for 0..N-1 in CVODE */ /* Generate the jth col of J(tn,y) */ /* Increment counter nfe = *nfePtr */