14

I am currently prototyping some algorithms in Matlab that rely on matrix, DSP, statistics and image analysis functionality.

Some examples of what I may need:

  • eigenvectors
  • convolution in 2D and 3D
  • FFT
  • Short Time Fourier Transform
  • Hilbert transform
  • Chebyshev polynomials
  • low pass filter
  • random multivariate gaussian numbers
  • kmeans

Later on I will need to implement these algorithms in C++.

I also have a license for Numerical Recipes in C++, which I like because it is well documented and have a wide variety of algorithms. I also found a class that helps with wrapping NR functions in MEX:nr3matlab.h. So using this class I should be able to generate wrappers that allow me to call NR functions from Matlab. This is very important to me, so that I can check each step when porting from Matlab to C++. However Numerical Recipes in C++ have some important shortcomings:

  • algorithms implemented in a simple, and not necessarily very efficient manner
  • not threaded

I am therefore considering using another numerical library. The ideal library should:

  • be as broad in scope and functionality as possible
  • be well documented
  • (have commercial support)
  • have already made Matlab wrappers
  • very robust
  • very efficient
  • threaded
  • (have a GPU implementation that can be turned on instead of the CPU with a "switch")

Which numerical library (libraries) would you suggest?

Thanks in advance for any answers!

Andy
  • 3,251
  • 4
  • 32
  • 53

4 Answers4

5

You have a pretty long list of requirements, and it may be challenging to cover them all with a single library.

For general Matlab-to-C++ transitions, I can highly recommend Armadillo which is a templated C++ library with a focus on linear algebra --- and a given focus on making it easy to write Matlab-alike expression. It as very good performance, is very well documented and actively maintained. You could start there and try to fill in the missing pieces for your task.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • Thanks. Also looks very good. I especially like that it is built upon Lapack whilst provding a much easier and Matlab-like interface. – Andy Feb 08 '12 at 20:16
  • On top of BLAS, which is an interface. So you can always drop in faster BLAS instead of default LAPACK. And Conrad knows his stuff and is a pleasure to work with. – Dirk Eddelbuettel Feb 08 '12 at 20:20
3

NAG could be one good option. Loads of financial institutions use it in their mathematical libraries. Don't have a GPU implementation though, when I last used it.

DumbCoder
  • 5,696
  • 3
  • 29
  • 40
  • Thanks. Looks very good. Do you know approximately how much 1 developer license cost? – Andy Feb 08 '12 at 18:45
  • @ Andreas Werner Paulsen - Google found out this. http://www.eduserv.org.uk/lns/agreements/nag/nag-pricing. Not sure how much it helps you. Educational institutions get preferential pricing, seems from their website. – DumbCoder Feb 08 '12 at 21:26
3

Actually you should have a look at openCV.

Although its first goal is computer vision/image processing, this library has a lot of linear algebra tools (Almost all that you ask for). At first, this library has been implemented by intel, with a lot of focus on performance. It can handle multi thread, IPP,... The syntax is rather easier to use than usual C++ library.

You should have a look at this cheat sheet. The syntax has been changed since version 2.0 to mimic matlab. This library is broadly used, and well active (last big update August 2011).

Oli
  • 15,935
  • 7
  • 50
  • 66
2

there is also the Eigen library: http://eigen.tuxfamily.org but it is mostly used as part of a larger framework. It offers basic (and a bit more complex) algebra

Gunther Struyf
  • 11,158
  • 2
  • 34
  • 58
  • It's a tour de force of c++ templating, but compiles are slow and error messages can be terribly long (terrible *and* long). – denis Mar 06 '12 at 16:39