# Appell function implementation in C++?

Is there a C++/C implementation of the Appell series? GSL and Boost do not seem to have this function.

You're probably better served writing a C wrapper for the Fortran implementation you linked to: Colavecchia, F. D., Gasaneo, G., "f1: a code to compute Appell's F1 hypergeometric function", Computer Physics Communications, Volume 157, Issue 1, p. 32-38 (2004), found at http://cpc.cs.qub.ac.uk/summaries/ADSJ.

The R package appell wraps that implementation of Appell's $F_{1}$. The R package provides additional implementations (all Fortran with R wrappers) and references. The Python package mpmath provides its own implementation; you could try translating that to C.

Given the niche field (special functions), and the lack of Google results for C or C++ implementations, the process of writing the wrapper (even if you have to learn how to do it) will probably take less time than searching another day or two for a native C or C++ implementation that may not even exist.

To write a wrapper, there are a number of sources available, but http://www.fortran90.org/src/best-practices.html#interfacing-with-c by Ondrej Certik is probably the best and most modern version describing the process of wrapping modern Fortran code; that is, Fortran 2003 or later. If the Colavecchia implementation is Fortran 90 or Fortran 95, you wouldn't have to change much of it beyond type declarations for the variables declared in the interface. The key is to use the iso_c_binding module; you can Google that term and it will help you write C wrappers (and, by extension, C++ wrappers).

If the Colavecchia code is uses Fortran 77, Fortran 90, or Fortran 95, then there are a number of links that will describe the kludgey process needed to get your wrapper to work. In that case, you might try following one of these less confusing resources (recommendations welcome!):

with the following caveats:

• I would ignore any recommendations of automated language wrappers or language headers for the time being; if they work, they're useful, but I've never gotten them to work for me, plus, you probably want to wrap a small number of functions, so automation won't be that helpful for you. (For a large project, such as PETSc, automated wrapper generation is essential.)
• Replace any mention of g77 with gfortran; g77 is no longer actively developed.

I'm sure there are other caveats, and it might be useful to turn "How do I write a C wrapper to a Fortran function?" into a separate question, in which case I'll migrate my answer and link to it.

• I have no idea how to write a wrapper. Any tips on where to begin? – becko May 14 '14 at 19:13
• Added a brief mention of references & caveats. – Geoff Oxberry May 14 '14 at 19:34
• The mpmath Appell functions do not wrap Colavecchia's implementation. Where did you get that idea? FWIW, the source code is here: github.com/fredrik-johansson/mpmath/blob/master/mpmath/… – Fredrik Johansson May 15 '14 at 22:09
• Not sure; I did look at the source code prior to writing this, but apparently not carefully enough. Will edit the answer; thanks catching my error. – Geoff Oxberry May 15 '14 at 22:32