Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

Try ILNumerics: We have a rel. long history as open source project and recently changed to commercial licenses for better and reliable support. I am biased but here comes a short feature list:

  • Better memory management, hence ...
  • Much faster algorithms
  • Uses MKL for linear algebra
  • n-dim array classes, syntax similar to Matlab
  • 3D plot controls
  • Support for 32/64 bit
  • Support for mono
  • Full feature list

I have us Mapack in the past and found it to be very good.

Although, I don't think it has Sparse matrices but it does support all the basic linear algegra functions.

Another alternative: IMSL for .NET. CenterSpace has the NMath libraries -- haven't used these.

I used Mapack (the .Net port not the COM version) in a neural network project at university. I can't exactly remember the fine details of the library, but it did everything I needed it to and wasn't particularly onerous to use.

Meta.Numerics (hosted on codeplex) is a free package that will compute eigenvalues and eigenvectors of non-symmetric matrices, but it does not currently treat sparse matrices specially.

have you considered math.net iridium ?

http://iridium.mathdotnet.com/

The now-defunct Managed DirectX library had some matrix support.

That has since been wrapped into Microsoft XNA, which is probably not a good fit for you, but the MDX Wikipedia article recommends something called SlimDX that might be okay.

Regarding .NET and Python, you could use IronPython. However, you'll also need Ironclad to make SciPy and NumPy work with IronPython.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top