diff --git a/capi/examples/example.c b/capi/examples/example.c index 8a78f52..27493d6 100644 --- a/capi/examples/example.c +++ b/capi/examples/example.c @@ -10,7 +10,12 @@ int main() { const double x = 0.1, q2 = 1.65; for (int fl=-5; fl <=5; fl++) printf("flv=%d - xfx = %f\n", fl, xfxq2(fl, x, q2)); - printf("alphas(q2=%f) = %f\n", q2, alphasq2(q2)); + + double q2_vectorized[] = {1.65, 10.65}; + double* as_vectorized = alphasq2(q2_vectorized, 2); + + printf("alphas(q2=%f) = %f\n", q2_vectorized[0], as_vectorized[0]); + printf("alphas(q2=%f) = %f\n", q2_vectorized[1], as_vectorized[1]); return 0; } diff --git a/capi/src/pdfflow/pdfflow.h b/capi/src/pdfflow/pdfflow.h index 3dcd45a..0045c67 100644 --- a/capi/src/pdfflow/pdfflow.h +++ b/capi/src/pdfflow/pdfflow.h @@ -6,4 +6,4 @@ extern void mkpdf(const char *fname, const char * dirname); extern double xfxq2(int pid, double x, double q2); -extern double alphasq2(double q2); +extern double *alphasq2(double *q2, int n); diff --git a/capi/src/wrapper.py b/capi/src/wrapper.py index ebf9e4b..abe1f9a 100644 --- a/capi/src/wrapper.py +++ b/capi/src/wrapper.py @@ -1,6 +1,7 @@ # This file is part of from cpdfflow import ffi from pdfflow import pflow +import numpy as np pdf = None @@ -21,7 +22,9 @@ def xfxq2(pid, x, q2): @ffi.def_extern() -def alphasq2(q2): +def alphasq2(q2, n): """Returns the alpha strong coupling at specific q2 value.""" global pdf - return pdf.alphasQ2([q2]) + q2_numpy = np.frombuffer(ffi.buffer(q2, n*ffi.sizeof('double')), dtype='double') + ret = pdf.alphasQ2(q2_numpy).numpy() + return ffi.cast("double*", ffi.from_buffer(ret))