Boost logo

Boost :

From: Marcus Mendenhall (marcus.h.mendenhall_at_[hidden])
Date: 2006-03-21 14:13:15

I have been working on a compact (1 header, 1 cpp file, total about
1500 lines) and highly portable package for numerical operations on
smooth functions. The package is in internal use by my research
collaborators at Vanderbilt, and is very stable.

The package consists of routines for manipulating smooth functions,
which are defined as functions which are capable of not only
returning their value, but the first two derivatives. Obvious cases
are analytic functions, and cubic splines. The name of the package
(and the objects it represents) is C2Functions.

The most important and interesting parts of the package are

1) Very general spline support, including transparent change of
variables in both X and Y to permit storage of linearized spline
tables, while still presenting the function externally as it was
established. Examples are LogLogInterpolatingFunction,
LogLinInterpolatingFunction, etc., but the class is extensible to
other schemes. These transformations allow high accuracy
representation of functions by reducing the second derivatives in the
spline tables, while exactly reconstructing the derivatives when

2) Functional algebra, allowing one to generate new functions,
constructed of old ones, which automatically keep track of the
derivatives correctly. Thus, one can trivially write a new function
g=C2Sin(f) where f is another C2Function, and g will correctly carry
the derivatives through the composition. Available operators include
basic binary functions, and composition. This allows a very compact
representation of 'stiff' functions, such as the sine of a slowly
varying phase error superimposed on a time, since the phase error can
be embedded in an InterpolatingFunction, and the composition
operation will reconstruct the exact derivatives of the rapidly
varying sinusoid.

3) Very fast root finding and adaptive integration. Since the
functions are smooth, and have exactly known derivatives, numerical
methods are be introduced which are extraordinarily efficient.

4) Very light weight implementation. The C2Functions package is very
shallowly nested, and the objects it creates are very low consumers
of memory. They do almost no memory management themselves, leaving
the user to be in charge of remembering to create and destroy them.
In many cases, a lot of the work can be done with statically
constructed functional compositions, etc., into which one plugs a
pointer at run time to a particular function to which the operations
will apply.

As it currently stands, the only conflicts with Boost style are
1) naming... if the package is considered 'likely to be interesting',
I will rename all functions to conform to Boost style
2) exception specification... I put these in while writing the code,
thinking them to be a good idea, but I agree with the Boost
rationale, and would gladly eliminate them.

If this package is deemed interesting by the Boost community, it can
be quickly cleaned up for actual submission. At present, I am working
on a package of documentation for it, which describes both the thoery
behind the package and its application. This still needs a bit of work.


Thanks in advance.

Marcus Mendenhall
Research Associate Professor of Physics
Vanderbilt University

Boost list run by bdawes at, gregod at, cpdaniel at, john at