views:

329

answers:

8

I'm in the process of choosing a scientific library to use as a basis for a project. I need to do a lot of statistical, linear algebra, and signal processing tasks, and I figured there are probably some great libraries that already do this stuff better than I could program it myself.

For c++, I know about Boost, but don't have much experience to evaluate it. I have also heard of the GNU Scientific Library (GSL). Does anyone have experience with these or another library, and what are your opinions? Which ones are generally preferred? Any info would be great. Thanks.

+4  A: 

Linear Algebra pack is your one-stop-shop for all LA stuff. It's available in a variety of languages and flavors.

Between LAPACK and GSL, you shouldn't have too many functions not already made for you for figuring out solutions to problems.

Haven't had much SignalProcessing experience, so i can't speak to that..

Caladain
+8  A: 

Quick ones:

  • Boost is great, but not particularly 'scientific'
  • GNU GSL is very good ... but in plain C
  • For linear algebra and C++, I really like Armadillo
  • For signal processing it++ is popular
  • For anything statistical I use R with the Rcpp and RInside packages for C++ interfaces

To me, the Linux distributions matters. With Debian (and Ubuntu), I get a very large number of things included as e.g Armadillo (or the older Newmat) for linear algebra, plus of course Lapack (and Atlas) plus literally hundreds of other libraries. Scientific libraries are particularly well supported by the hundreds of developers (and as a disclaimer, I am one of those).

Dirk Eddelbuettel
+1 for the suggestion to use R for statistical work. There's really nothing else quite like it.
bta
Boost.Accumulators and it's random number library are awesome. The uBLAS interface can also be useful.
honk
Boost.Accumulators is awesome indeed. I just wish you could also 'cap' it for a number of observations or window.
Dirk Eddelbuettel
@Dirk: That's not too hard to work around. One needs to store the entries inside a container class that only stores the last X entries (throwing away the front if the container is full) and then fill the accumulator only once in a `std::for_each`. I use that for time-series analyses.
honk
If we keep N entries and update on new data, worst case is that for each new data point you complete re-compute via Accumulators even if N-1 points are identical. If wish there was an updating facility that would let Accumulators 'pop_front' and 'push_back'.
Dirk Eddelbuettel
@Dirk: I see there are actually `boot::accumulators::rolling_mean`, `rolling_sum` and `rolling_count` for extremely simple calculations. I can only guess that more advanced stuff (e.g. stuff that does need to keep all last N entries) would get too heavy implementationwise.
honk
+2  A: 

I worked on a computer vision project that used VXL:

http://vxl.sourceforge.net/

It may have a lot of things you aren't interested in, but it's broken up into packages. One of those is a "numerics" library (VNL):

http://public.kitware.com/vxl/doc/release/books/core/book_6.html#SEC44

Hostile Fork
+4  A: 

Have you considered an open source math-program like Maxima, as a starting base for your application?

http://maxima.sourceforge.net/

It seems particularly capable with regards to algebra, and equations solving.

Secondly, have you considered the value of something like combinations of Python+python libraries, with your main C++ application? You can link Python into your application and get a lot of math capabilities (numpy and scipy).

Warren P
+1 for python (numpy/scipy)
Ugo
+2  A: 

I personally use GSL and have been quite satisfied with it. As far as OS is concerned, there are a few ports that of GSL to Windows/Visual Studio out there that you could use:

  1. GSL Port to VS 2008

  2. Another GSl Port to VS 2008

  3. GSL Port to VS 2010

There are also a few C++ wrappers for GSL but they are incomplete. Given that GSL is a C library you have to be careful with memory management but otherwise it has met all my requirements so far.

Anon
+1  A: 

ROOT is maintained and used by the high energy physics community. Lots of powerful tool including linear algebra and statistics, but there is an underlying assumption that you'll be working on lists of events, so the approach is a little different from many other tools.

A nice feature of ROOT is that it uses cint for the REPL shell, which means that you can use the full power of the tool (with c++ syntax and tab completion) interactively or compiled, and you can freely mix compiled and interpreted code.

dmckee
+2  A: 

Assuming you're fine with copyleft licenses for your project, FFTW3 is very good for doing Fourier Transforms.

I'd also mention this list of numerical libraries at Wikipedia.

If you're wanting C/C++ for the fast execution time, I'd recommend looking into SciPy. The computationally intensive stuff is written in C and wrapped in Python for ease of use. Unless you have to do lots of nested looping in Python, the execution speed should be very good.

procrastinate_later
+1  A: 

GSL is good for linear algebra, but not as powerful as LAPACK. Blitz++ is a very useful implementation of matrices for C++ that speeds up the calculations.

corydalus
Blitz++ is dead. Try Armadillo (at arma.sf.net) for an excellent implementaion of similar ideas.
Dirk Eddelbuettel