README.md /size: 5973 b    last modification: 2025-02-21 11:03
1# libcerf
2
3This is the home page of **libcerf**, a self-contained numeric library that provides an efficient and accurate implementation of complex error functions, along with Dawson, Faddeeva, and Voigt functions.
4
5# User Documentation
6
7## Synopsis
8
9In the following, "complex" stands for the C99 data type "double _Complex":
10
11  * complex [cerf](http://apps.jcns.fz-juelich.de/man/cerf.html) (complex): The complex error function erf(z).
12  * complex [cerfc](http://apps.jcns.fz-juelich.de/man/cerf.html) (complex): The complex complementary error function erfc(z) = 1 - erf(z).
13  * complex [cerfcx](http://apps.jcns.fz-juelich.de/man/erfcx.html) (complex z): The underflow-compensating function erfcx(z) = exp(z^2) erfc(z).
14  * double [erfcx](http://apps.jcns.fz-juelich.de/man/erfcx.html) (double x): The same for real x.
15  * complex [cerfi](http://apps.jcns.fz-juelich.de/man/erfi.html) (complex z): The imaginary error function erfi(z) = -i erf(iz).
16  * double [erfi](http://apps.jcns.fz-juelich.de/man/erfi.html) (double x): The same for real x.
17  * complex [w_of_z](http://apps.jcns.fz-juelich.de/man/w_of_z.html) (complex z): Faddeeva's scaled complex error function w(z) = exp(-z^2) erfc(-iz).
18  * double [im_w_of_x](http://apps.jcns.fz-juelich.de/man/w_of_z.html) (double x): The same for real x, returning the purely imaginary result as a real number.
19  * complex [cdawson](http://apps.jcns.fz-juelich.de/man/dawson.html) (complex z): Dawson's integral D(z) = sqrt(pi)/2 * exp(-z^2) * erfi(z).
20  * double [dawson](http://apps.jcns.fz-juelich.de/man/dawson.html) (double x): The same for real x.
21  * double [voigt](http://apps.jcns.fz-juelich.de/man/voigt.html) (double x, double sigma, double gamma): The convolution of a Gaussian and a Lorentzian.
22  * double [voigt_hwhm](http://apps.jcns.fz-juelich.de/man/voigt_hwhm.html) (double sigma, double gamma): The half width at half maximum of the Voigt profile.
23
24## Accuracy
25
26By construction, it is expected that the relative accuracy is generally better than 1E-13. This has been confirmed by comparison with high-precision Maple computations and with a *long double* computation using Fourier transform representation and double-exponential transform.
27
28## Copyright and Citation
29
30Copyright (C) [Steven G. Johnson](http:*math.mit.edu/~stevenj), Massachusetts Institute of Technology, 2012; [Joachim Wuttke](http:*www.fz-juelich.de/SharedDocs/Personen/JCNS/EN/Wuttke_J.html), Forschungszentrum Jülich, 2013.
31
32License: [MIT License](http://opensource.org/licenses/MIT)
33
34When using libcerf in scientific work, please cite as follows:
35  * S. G. Johnson, A. Cervellino, J. Wuttke: libcerf, numeric library for complex error functions, version [...], http://apps.jcns.fz-juelich.de/libcerf
36
37Please send bug reports to the authors, or submit them through the Gitlab issue tracker.
38
39## Further references
40
41Most function evaluations in this library rely on Faddeeva's function w(z).
42
43This function has been reimplemented from scratch by [Steven G. Johnson](http://math.mit.edu/~stevenj);
44project web site http://ab-initio.mit.edu/Faddeeva. The implementation partly relies on algorithms from the following publications:
45  * Walter Gautschi, *Efficient computation of the complex error function,* SIAM J. Numer. Anal. 7, 187 (1970).
46  * G. P. M. Poppe and C. M. J. Wijers, *More efficient computation of the complex error function,* ACM Trans. Math. Soft. 16, 38 (1990).
47  * Mofreh R. Zaghloul and Ahmed N. Ali, *Algorithm 916: Computing the Faddeyeva and Voigt Functions,* ACM Trans. Math. Soft. 38, 15 (2011).
48
49# Installation
50
51## From source
52
53Download location: http://apps.jcns.fz-juelich.de/src/libcerf/
54
55Build&install are based on CMake. Out-of-source build is enforced.
56After unpacking the source, go to the source directory and do:
57
58  mkdir build
59  cd build
60  cmake ..
61  make
62  make install
63
64To test, run the programs in directory test/.
65
66The library has been developed using gcc-4.7. Reports about successful compilation with older versions of gcc would be welcome. For correct support of complex numbers it seems that at least gcc-4.3 is required. Compilation with gcc-4.2 works after removing of the "-Werror" flag from *configure*.
67
68## Binary packages
69
70  * Linux:
71    * [rpm package](https://build.opensuse.org/package/show/science/libcerf) by Christoph Junghans
72    * [Gentoo package](http://packages.gentoo.org/package/sci-libs/libcerf) by Christoph Junghans
73    * [Debian package](https://packages.debian.org/jessie/libs/libcerf1) by Eugen Wintersberger
74  * OS X:
75    * [MacPorts::libcerf](http://www.macports.org/ports.php?by=name&substr=libcerf), by Mojca Miklavec
76    * [Homebrew/homebrew-science/libcerf.rb](https://formulae.brew.sh/formula/libcerf), by Roman Garnett
77
78# Code structure
79
80The code consists of
81- the library's C source (directory lib/),
82- test code (directory test/),
83- manual pages (directory man/),
84- build utilities (aclocal.m4, build-aux/, config*, m4/, Makefile*).
85
86## Compilation
87
88The library libcerf is written in C. It can be compiled as C code (default) or as C++ code (with option -DCERF_CPP=ON). Compilation as C++ is useful especially under MS Windows because as per 2018 the C compiler of Visual Studio does not support C90, nor any newer language standard, and is unable to cope with complex numbers.
89
90Otherwise, the library is self-contained, and installation should be
91straightforward, using the usual command sequence
92
93  ./configure
94  make
95  sudo make install
96
97The command ./configure takes various options that are explained in the
98file INSTALL.
99
100## Language bindings
101
102For use with other programming languages, libcerf should be either linked directly, or provided with a trivial wrapper. Such language bindings are added to the libcerf package as contributed by their authors.
103
104The following bindings are available:
105  * **fortran**, by Antonio Cervellino (Paul Scherrer Institut)
106
107Further contributions will be highly welcome.
108
109Please report bugs to the package maintainer.
110