summaryrefslogtreecommitdiff
path: root/packages/sundials/src/helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'packages/sundials/src/helpers.c')
-rw-r--r--packages/sundials/src/helpers.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/packages/sundials/src/helpers.c b/packages/sundials/src/helpers.c
index 3e1a9a8..d51310c 100644
--- a/packages/sundials/src/helpers.c
+++ b/packages/sundials/src/helpers.c
@@ -69,3 +69,26 @@ int Jac(realtype t, N_Vector y, N_Vector fy, SUNMatrix J,
69 69
70 return 0; /* return with success */ 70 return 0; /* return with success */
71} 71}
72
73
74/* check the computed solution */
75int check_ans(N_Vector y, realtype t, realtype rtol, realtype atol)
76{
77 int passfail=0; /* answer pass (0) or fail (1) flag */
78 realtype ans, err, ewt; /* answer data, error, and error weight */
79 realtype ONE=RCONST(1.0);
80
81 /* compute solution error */
82 ans = atan(t);
83 ewt = ONE / (rtol * SUNRabs(ans) + atol);
84 err = ewt * SUNRabs(NV_Ith_S(y,0) - ans);
85
86 /* is the solution within the tolerances? */
87 passfail = (err < ONE) ? 0 : 1;
88
89 if (passfail) {
90 fprintf(stdout, "\nSUNDIALS_WARNING: check_ans error=%g \n\n", err);
91 }
92
93 return(passfail);
94}