Matrix Library for .NET

Noldorin picture Noldorin · May 8, 2009 · Viewed 25.3k times · Source

I'm looking for a good (well-tested, fully-featured, and ideally with a nice interface) matrix library for .NET/C#. My main requirements here are only that it should be free (I don't particularly care whether it's open-source in this case) and preferably support sparse matrix operations. The obligatory requirements are all the basic operations (e.g. multiplication, transposition, inversion) as well as finding eigenvalues & eigenvectors. Implementation of a numerical rather than/as well as analytical methods for discovery of eigenvalues, particularly the Lanczos algorithm for sparse matrices, would be highly preferable since the matrices I'm going to be dealing with are very large (lengths of 10,000 upwards) as well as square, and also reasonably sparse. Saying that, I could be asking for a bit much there, so any suggestions for a reasonably complete matrix library would be great.

Now I'm aware that Python has one or two useful libraries for such tasks (namely NumPy/SciPy), but .NET unfortunately seems to be lacking in the area.

A bit of searching turned up the following libraries for .NET, which I could potentially used:

However, since I have had no experience whatsoever using any of these libraries or others (and not exactly enough time to check each of them out properly in any case), I would very much appreciate if anyone here could discuss their recommendations regarding the various libraries, their pros/cons particularly with regards to suitability for my uses, and their general experiences with them.

Resorting to MatLab is always an option, but not a preferred one, as it would be much more convenient if I could integrate the matrix math directly with my program.

Answer

Reed Copsey picture Reed Copsey · May 8, 2009

Edit:

It wasn't quite there last time I evaluated it, but there has been quite a bit of activity, so you should also consider the (free and open source) Math.NET Numerics.

In looking now, it seems they've finished their new version, and have added sparse matrix support, as well as other nice goodies.


If you want more robust support, you unfortunately really need to get into commercial packages for .NET atm.

There are two very feature-rich packages, both of which support matrices very well. Extreme Numerics works great, and has some very nice features. I've also heard very good things about the IMSL Visual Numerics math libraries.