MCPcopy Create free account
hub / github.com/boutproject/BOUT-dev / CVodeDky

Function CVodeDky

externalpackages/PVODE/source/cvode.cpp:957–1007  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

955**********************************************************************/
956
957int CVodeDky(void *cvode_mem, real t, int k, N_Vector dky)
958{
959 real s, c, r;
960 real tfuzz, tp, tn1;
961 int i, j;
962 CVodeMem cv_mem;
963
964 cv_mem = (CVodeMem) cvode_mem;
965
966 /* Check all inputs for legality */
967
968 if (cvode_mem == NULL) {
969 fprintf(stdout, MSG_DKY_NO_MEM);
970 return(DKY_NO_MEM);
971 }
972
973 if (dky == NULL) {
974 fprintf(stdout, MSG_BAD_DKY);
975 return(BAD_DKY);
976 }
977
978 if ((k < 0) || (k > q)) {
979 fprintf(errfp, MSG_BAD_K, k);
980 return(BAD_K);
981 }
982
983 tfuzz = FUZZ_FACTOR * uround * (tn + hu);
984 tp = tn - hu - tfuzz;
985 tn1 = tn + tfuzz;
986 if ((t-tp)*(t-tn1) > ZERO) {
987 fprintf(errfp, MSG_BAD_T, t, tn-hu, tn);
988 return(BAD_T);
989 }
990
991 /* Sum the differentiated interpolating polynomial */
992
993 s = (t - tn) / h;
994 for (j=q; j >= k; j--) {
995 c = ONE;
996 for (i=j; i >= j-k+1; i--) c *= i;
997 if (j == q) {
998 N_VScale(c, zn[q], dky);
999 } else {
1000 N_VLinearSum(c, zn[j], s, dky, dky);
1001 }
1002 }
1003 if (k == 0) return(OKAY);
1004 r = RPowerI(h,-k);
1005 N_VScale(r, dky, dky);
1006 return(OKAY);
1007}
1008
1009/********************* CVodeFree **********************************
1010

Callers 2

runMethod · 0.85
CVodeFunction · 0.85

Calls 3

N_VScaleFunction · 0.85
N_VLinearSumFunction · 0.85
RPowerIFunction · 0.85

Tested by

no test coverage detected