From 25343d3723ae70690f056b0a501f5941892fbf93 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 23 Feb 2021 16:24:48 +0530 Subject: Provide test integrals. * include/integrands.h, src/integrands.sc: New files. --- include/integrands.h | 15 +++++++++++++++ src/integrands.sc | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 include/integrands.h create mode 100644 src/integrands.sc diff --git a/include/integrands.h b/include/integrands.h new file mode 100644 index 0000000..b4735a8 --- /dev/null +++ b/include/integrands.h @@ -0,0 +1,15 @@ +#ifndef INTEGRANDS_H +#define INTEGRANDS_H + +#include + +typedef struct { + double *coefficients; + int degree; +} polynomial_integrand_params; + +double polynomial_integrand (double r, const gsl_vector* x, void *params); +double gaussian_integrand (double r, const gsl_vector* x, void *params); +double x_coordinate_integrand (double r, const gsl_vector* x, void *params); + +#endif diff --git a/src/integrands.sc b/src/integrands.sc new file mode 100644 index 0000000..750530c --- /dev/null +++ b/src/integrands.sc @@ -0,0 +1,19 @@ +(pre-include "gsl/gsl_math.h") +(pre-include "gsl/gsl_poly.h") +(pre-include "integrands.h") + +(define (polynomial-integrand r x -params) (double double (const gsl-vector*) void*) + (let* ((params polynomial-integrand-params* + (convert-type -params polynomial-integrand-params*))) + (return (gsl-poly-eval (: params coefficients) + (+ (: params degree) 1) + r)))) + +(define (gaussian-integrand r x -params) (double double (const gsl-vector*) void*) + ;; This is a workaround to fix negation bug in sph-sc. See + ;; https://github.com/sph-mn/sph-sc/issues/5 . TODO: Remove + ;; workaround once bug is fixed upstream. + (return (exp (- 0 (/ (gsl-pow-2 r) 2))))) + +(define (x-coordinate-integrand r x -params) (double double (const gsl-vector*) void*) + (return (fabs (* r (gsl-vector-get x 0))))) -- cgit v1.2.3