gammapy/ringtophat — Issue #8: Major design decisions: Pixel datatype support? C or C++?
Author: cdeil
Created: 2012-02-24 17:59:29+00:00
State: open
Labels: ENH

Pixel datatype support
----------------------------

We need at least int and double, for speed / memory footprint we probably also want int32 and float32.

C or C++
------------

We are unsure if we should use C or C++.

Advantages of using C++:

* No pointers, std::vector does the memory management.
* Templates allow many datatypes (int, uint, double of various precisions) with ease

Disadvantages of using C++:

* Making it build everywhere is probably a bit harder?
* Portable python bindings (different systems, compilers, python versions) are harder? A bit, much?

Code simplicity and speed should be identical with C or C++.

Is it true that the only C solutions to supporting several datatypes are:

* Duplicate the code for each data type or
* Use macros (would that work?)

If so I would strongly suggest we use C++ templates.

Before we decide on C or C++, and for guidance on making a good API, let's briefly look at a few popular C and C++ libraries for linear algebra and image processing. This is what a quick google search turned up (mostly C++, only some C):

* http://www.boost.org/doc/libs/1_48_0/libs/gil/example/convolution.cpp
* http://www.fftw.org/
* http://numpy.scipy.org/
* http://www.gnu.org/software/gsl/ (partly C++)
* http://www.imagemagick.org/
* http://eigen.tuxfamily.org/
* http://arma.sourceforge.net/
* http://seldon.sourceforge.net/
* http://fftwpp.sourceforge.net/ (even has 2D FFT convolution)
* http://opencv.willowgarage.com/wiki/
* http://cimg.sourceforge.net/