mathC
mathC is a set of subroutines, either in ANSI C or C++,
for various mathematical problems. It is used by almost all our software,
hence we found it convenient to create a separate download package for
it instead of bundling it with all our software packages.
The subroutines in mathC are based on many mathematical
textbooks and publications, on personal communications and hard
experience. Some subroutines were taken from the literature as they are,
some were signifcantly improved by us. Unless indicated otherwise in the
top portions of the source files, we do not claim authorship.
Installation requirements
- C version: an ANSI C compiler capable of handling dynamic libraries
(GNU gcc and HP-UX cc are known to work)
- C++ version: a C++ compiler capable of handling dynamic libraries
(GNU g++ is known to work)
- the make command (a standard feature of UNIX and Linux)
- the mathC source files (last update:
2011-01-31)
Installation
-
Unpack the mathC archive:
gzip -cd mathc.tar.gz | tar -xvf -
This creates the directories math/C and math/C++.
-
Make platform-specific changes for the C version:
cd math/C/src
./configure
-
Build the library:
make
- Repeat the last two steps for the C++ version.
Note: The recent configure script recognizes Linux only.
If you have a different operating system, you may have to modify the
configure script.
Please send us your configure script, and we will build your changes
into the official distribution.
Contents (C++ version)
- minimization, curve fitting
- min_brent: local minimum of a 1-dimensional function,
parabola minimum
- fit_marquardt: modified Marquardt-Levenberg method
- fit_powell: Powell's sequential minimization method
- fit_simplex: simplex method of Nelder and Mead
- min_scan1: absolute minimum of a 1-dimensional function
- differentiation
- diff_gradient: gradient of an n-dimensional function, Romberg's
method
- diff_hessian: Hessian of an n-dimensional function, Romberg's
method
- diff_ridders: derivative of an 1-dimensional function by Ridder's
method
- diff_romberg: derivative of an 1-dimensional function (also
bounded!) by Romberg's method
- diff_x: derivative of an 1-dimensional function confined to
[0; 1]
- diff_2all: 2-dimensional function, all derivatives up
to given order
- differential equations
- ode_runge_kutta: 1st degree ordinary ODE, Runge-Kutta method
- functions
- f_bessel_sph: spherical Bessel function (= J_{l+1/2}(x))
- f_gammaln: logarithm of Gamma function
- f_dfac: factorial (as double precision)
- f_ibinom_c: binomial coefficients (as integers)
- f_legendre: Legendre polynomials (function values or
coefficients)
- integration
- int_gauss: Gauss' method
- int_romberg: Romberg's iterative method
- int_simpson: Simpson's and Newton's rules
- interpolation
- ipl_akima: Akima polynomials
- ipl_spline: natural cubic spline polynomials
- ipl_eval: evaluation of Akima or spline polynomials
- ipl_pspline: periodic cubic spline polynomials
- ipl_peval: evaluation of periodic cubic spline polynomials
- ipl_lagrange: calculation of Lagrange polynomials
- ipl_reinsch: smoothing natural cubic spline polynomials
- ipl_track: polynomial intra/extrapolation of tables
- linear algebra
- lin_gauss: systems of linear equations by Gauss elimination
- lin_jacobi: eigenvalues and vectors of symmetric matrices,
Jacobi algorithm
- lin_matinv: matrix inversion, Gauss-Jordan algorithm
- nonlinear equations
- eqn_quadratic: linear or quadratic equation
- eqn_cubic: cubic equation (faster than Cardano's algorithm!)
- eqn_quartic: quartic polynomial equation
- eqn_quintic: 5th order polynomial equation
- eqn_polynomial: polynomial equation of arbitrary order
- eqn_regulafalsi: nonlinear equation by regula falsi,
Illinois method
- eqn_steffensen: nonlinear equation, Steffensen's substitution
method
- random numbers
- ran_cgr48: improved random number generator doing 48-bit
randomization (portable version, requires 64-bit integers)
- ran_shuffle: same as before, invokes drand48(3C)
- ran_stauffer: random number generator of D. Stauffer
(famous theoretical physicist from Cologne)
- ran_ecuyer: random number generator of P. l'Ecuyer (with
shuffling)
- ran_vector: unit vector with random orientation
- vector/matrix algebra
- numerous operations implemented as member functions of our own
Vector and Matrix template classes
- other
- sort_index: sort elements of a vector (merge sort method)
Some of these subroutines are not available in the C version, and
some are there under a different name.