static int CVBandPrecSetup(realtype t, N_Vector y, N_Vector fy, booleantype jok, booleantype *jcurPtr, realtype gamma, void *bp_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { long int ier; CVBandPrecData pdata; /* Assume matrix and pivots have already been allocated. */ pdata = (CVBandPrecData) 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(pdata, t, y, fy, tmp1, tmp2); BandCopy(savedJ, savedP, mu, ml); } /* 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); }
static int CVBandPrecSetup(realtype t, N_Vector y, N_Vector fy, booleantype jok, booleantype *jcurPtr, realtype gamma, void *bp_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { CVBandPrecData pdata; CVodeMem cv_mem; int retval; long int ier; /* Assume matrix and lpivots have already been allocated. */ pdata = (CVBandPrecData) bp_data; cv_mem = (CVodeMem) pdata->cvode_mem; 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; SetToZero(savedJ); retval = CVBandPDQJac(pdata, t, y, fy, tmp1, tmp2); if (retval < 0) { cvProcessError(cv_mem, -1, "CVBANDPRE", "CVBandPrecSetup", MSGBP_RHSFUNC_FAILED); return(-1); } if (retval > 0) { return(1); } BandCopy(savedJ, savedP, mu, ml); } /* Scale and add I to get savedP = I - gamma*J. */ BandScale(-gamma, savedP); AddIdentity(savedP); /* Do LU factorization of matrix. */ ier = BandGBTRF(savedP, lpivots); /* Return 0 if the LU was complete; otherwise return 1. */ if (ier > 0) return(1); return(0); }