Putting hypergeometric function in gnuplot with GSL (patching)
Autor: Hélio | Publicado: 2016-08-12T14:09:00-07:00

My gnuplot version with hypergeometric function using GNU Scientific Library
hyperg_2F1.patch

--- ./src/eval.c.orig&nbsp;&nbsp;&nbsp; 2016-08-12 17:06:35.250145505 -0300+++ ./src/eval.c&nbsp;&nbsp;&nbsp; 2016-05-03 12:34:08.000000000 -0300@@ -191,6 +191,7 @@&nbsp;&nbsp;&nbsp;&nbsp; {"lambertw",&nbsp; f_lambertw}, /* HBB, from G.Kuhnle 20001107 */&nbsp;&nbsp;&nbsp;&nbsp; {"airy",&nbsp; f_airy},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* janert, 20090905 */&nbsp;&nbsp;&nbsp;&nbsp; {"expint",&nbsp; f_expint},&nbsp;&nbsp;&nbsp;&nbsp; /* Jim Van Zandt, 20101010 */+&nbsp;&nbsp;&nbsp; {"hyperg_2F1",f_hyperg_2F1},&nbsp;#ifdef HAVE_LIBCERF&nbsp;&nbsp;&nbsp;&nbsp; {"cerf", f_cerf},&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* complex error function */--- ./src/specfun.c.orig&nbsp;&nbsp;&nbsp; 2016-08-12 17:06:35.248145450 -0300+++ ./src/specfun.c&nbsp;&nbsp;&nbsp; 2016-05-03 12:20:14.000000000 -0300@@ -49,6 +49,7 @@&nbsp;#include "specfun.h"&nbsp;#include "stdfn.h"&nbsp;#include "util.h"+#include "gsl/gsl_sf_hyperg.h"&nbsp;#define ITMAX&nbsp;&nbsp; 200@@ -3031,9 +3032,11 @@&nbsp;extern double p1evl ( double, void *, int );&nbsp;extern double sin ( double );&nbsp;extern double cos ( double );+extern double gsl_sf_hyperg_2F1( double , double, double, double);&nbsp;#else&nbsp;double fabs(), exp(), sqrt();&nbsp;double polevl(), p1evl(), sin(), cos();+double gsl_sf_hyperg_2F1();&nbsp;#endif&nbsp;int --- ./src/standard.c.orig&nbsp;&nbsp;&nbsp; 2016-08-12 17:06:35.255145644 -0300+++ ./src/standard.c&nbsp;&nbsp;&nbsp; 2016-05-03 14:40:24.741731493 -0300@@ -39,6 +39,7 @@&nbsp;#include "gadgets.h"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* for 'ang2rad' and 'zero' */&nbsp;#include "gp_time.h"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* needed by f_tmsec() and friendsa */&nbsp;#include "util.h"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* for int_error() */+#include "gsl/gsl_sf_hyperg.h"&nbsp;static double carlson_elliptic_rc(double x,double y);&nbsp;static double carlson_elliptic_rf(double x,double y,double z);@@ -57,7 +58,7 @@&nbsp;static double yone __PROTO((double x));&nbsp;static double rj1 __PROTO((double x));&nbsp;static double ry1 __PROTO((double x));-+extern double gsl_sf_hyperg_2F1(double,double,double,double);&nbsp;/* The bessel function approximations here are from&nbsp; * "Computer Approximations"&nbsp; * by Hart, Cheney et al.@@ -841,6 +842,30 @@&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;}+void+f_hyperg_2F1(union argument *arg)+{+&nbsp;&nbsp;&nbsp; struct value a1;+&nbsp;&nbsp;&nbsp; double&nbsp;&nbsp;&nbsp; aa,bb,cc,zz;++&nbsp;&nbsp;&nbsp; (void) arg;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* avoid -Wunused warning */+&nbsp;&nbsp;&nbsp; zz=real(pop(&amp;a1));+&nbsp;&nbsp;&nbsp; cc=real(pop(&amp;a1));+&nbsp;&nbsp;&nbsp; bb=real(pop(&amp;a1));+&nbsp;&nbsp;&nbsp; aa=real(pop(&amp;a1));+//&nbsp;&nbsp;&nbsp; if (fabs(imag(&amp;a1)) &gt; zero || fabs(imag(&amp;a2)) &gt; zero)+//&nbsp;&nbsp;&nbsp; int_error(NO_CARET, "can only do elliptic integrals of reals");++&nbsp;&nbsp;&nbsp; if (zz &lt; 1.0 &amp;&amp; zz &gt; 0)+&nbsp;&nbsp;&nbsp; push(Gcomplex(&amp;a1, gsl_sf_hyperg_2F1(aa,bb,cc,zz), 0.0));+&nbsp;&nbsp;&nbsp; else if (zz &lt; 0) {+&nbsp;&nbsp;&nbsp; push(Gcomplex(&amp;a1, pow(1-zz,-aa)*gsl_sf_hyperg_2F1(aa,cc-bb,cc,zz/(zz-1)), 0.0));+&nbsp;&nbsp;&nbsp; } else {+&nbsp;&nbsp;&nbsp; undefined=TRUE;+&nbsp;&nbsp;&nbsp; push(&amp;a1);+&nbsp;&nbsp;&nbsp; }++}&nbsp;/* Terminate the autoconversion from string to numeric values */&nbsp;#undef pop--- ./src/standard.h.orig&nbsp;&nbsp;&nbsp; 2016-08-12 17:06:35.252145560 -0300+++ ./src/standard.h&nbsp;&nbsp;&nbsp; 2016-05-03 12:37:23.000000000 -0300@@ -93,5 +93,6 @@&nbsp;void f_tmyear __PROTO((union argument *x));&nbsp;void f_tmwday __PROTO((union argument *x));&nbsp;void f_tmyday __PROTO((union argument *x));+void f_hyperg_2F1 __PROTO((union argument *x));&nbsp;#endif /* GNUPLOT_STANDARD_H */