53

Is there stable linear algebra (more specifically, vectors, matrices, multidimensional arrays and basic operations on them) library for C#?

Search yielded a few open source libraries which are either not updated for couple of years or are in an early beta stage - and Centerspace NMath. Which alternatives are worth checking?

Matthew Strawbridge
  • 19,940
  • 10
  • 72
  • 93
ima
  • 8,105
  • 3
  • 20
  • 19

7 Answers7

38

Math.NET. We're using it in production.

Michael Todd
  • 16,679
  • 4
  • 49
  • 69
Rinat Abdullin
  • 23,036
  • 8
  • 57
  • 80
  • 6
    Just be aware that there are several packages in Math.NET. Some are LGPL but a couple are GPL, which, for a commercial application, could well be an issue. – cletus Dec 25 '08 at 21:46
  • Thanks, looks better. I still miss multidimensional lattices, matrices of custom types etc, but it should work – ima Dec 26 '08 at 07:21
  • Can somebody provide performance comparison of Math.NET and other libraries (like those from [@harrydev's answer] (http://stackoverflow.com/a/2222267/311865))? Especially I'm interested in performance of matrix multiplication, matrix by scalar multiplication and vector summing operations. Are those operations paralleled on multiple cores if the computer have them? – Rasto Aug 16 '12 at 13:28
  • Looks like things have changed, most of the licenses are now MIT. They try to relicense the remaining few LGPL licenses - mainly still there because they have a hard time to contact the authors. – tobiak777 Feb 14 '16 at 11:11
  • 1
    Is the computation in Math.Net vectorized? – Eduardo Pignatelli Oct 23 '18 at 08:03
11

See: http://en.wikipedia.org/wiki/List_of_numerical_libraries

http://www.alglib.net/ - Open source. Multi-language library.

http://www.mathdotnet.com/ - Open source. As mentioned by others. dnAnalytics is replaced by http://numerics.mathdotnet.com/ in this.

http://www.lutzroeder.com/dotnet/ - Lutz Roeder has a open source port Mapack.Net of LAPACK.

http://www.extremeoptimization.com/ - Commercial.

nietras
  • 3,949
  • 1
  • 34
  • 38
  • 12
    This answer would be more helpful if people who need C# algebra libraries didn't know how to use google. – ima Feb 10 '10 at 09:03
6

I am using ILNumerics.NET

www.ilnumerics.net

Very good support and stable. I don't have any comparison though.

Marc
  • 12,706
  • 7
  • 61
  • 97
4

We have evaluated nMath and were quite pleased with its programmability and speed. Their support staff even worked over a weekend to figure out a bug we found. We liked that they used Intel's Kernel Math library instead of rolling their own numerics. [Edited to add: have been using in production for years]

Sebastian Good
  • 6,310
  • 2
  • 33
  • 57
2

Few weeks ago I found a new c# library FinMath contains implementations of many various methods and techniques including basic linear algebra, such as:

  1. Vector and Matrix implementations (easy to use high-level interfaces covering most of all BLAS functionality)
  2. Algorithms of matrix factorizations (LU, QR, SVD, Cholesky).

And many other useful things like statistics, factor and cluster analysis, linear and quadratic programming solver and etc.

Unfortunately, it's not free, but it's extremely fast, because it uses MKL for most complex computations and at the same time it distributed as single library supports both 32bit and 64bit modes and requires no special maintenance to use, like taking care about native libraries.

Wisdom's Wind
  • 1,448
  • 9
  • 10
1

Although it is not updated, not open source, and not for commercial usage, one might want to check out D* from Microsoft Research. It's a very cool symbolic math library, especially for doing derivatives, but really it's a little matlab in the hands of a .NET programmer.

http://research.microsoft.com/en-us/downloads/4714703d-782c-4e37-830d-0e3b7662f743

Ziriax
  • 1,012
  • 10
  • 19
1

Have you looked into dnAnalytics?

cletus
  • 616,129
  • 168
  • 910
  • 942
  • yes, but version "0.3.1 Beta" makes me nervous thinking about including it into important long term project – ima Dec 25 '08 at 15:10
  • That's a fair point but beta means different things to different people. At one end is the Ext-GWT guy who wakes up in the morning and decides to make the alpha1 version final. At the other end is gmail, still in beta. dnAnalytics has been around since October 2007 and still active. Worth a look? – cletus Dec 25 '08 at 15:21
  • 1
    Frankly, not. 23 lines of documentation, useless XML doc (Object object - the object), very wide feature set with gaping holes in the middle... Looks like supporting code for some other project, or may be training ground for developers. – ima Dec 25 '08 at 16:43
  • DnAnalytics is no longer supported. Not it is a part of Math.NET Numerics. – vharavy Nov 25 '11 at 10:27