Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DotNumerics, AlgLib, dnAnalytics, Math.net, F# for Numerics, Mtxvec?

Tags:

I’ve been searching Google and Stack Overflow like crazy for days and have yet to find any recent, completely relevant information to answer the following question: What are the best C#/F#/.NET math libraries (specifically, those that wrap or implement the same functionality as Lapack, etc.)?

One of the better posts on Stack Overflow that I did see was: https://stackoverflow.com/questions/3227647/open-source-math-library-for-f

The reason that that post, and other previous posts, didn’t sufficiently answer my question was that no systematic comparison of user experiences with various libraries was given.

I’m interested in how completely the following libraries (in real-world usage) implement Lapack (or a broad set of equivalent linear algebra of functionality); and, I’m curious about their performance relative to each other particularly on very large matrices. Also, I’d like to hear about others’ experiences utilizing the various libraries: difficulties, ease of use, etc.

Below is a comprehensive list of the “free”/opensource/affordable .NET/F#/C# math libraries which – as far as I know – have a linear algebra feature set. I’d deeply appreciate it if the community here on Stack Overflow would chip in with any experiences they have with the following libraries:

  • DotNumerics
  • Alglib
  • dnAnalytics
  • Math.NET
  • F# for Numerics
  • MtxVec 2010

I’m interested in F# for Numerics (since I’m working with F#) but I’m having difficulty ascertaining the strengths and weaknesses of the various libraries. Like, which features are missing or included in various libraries, and how easily they are used and how well they perform.

DotNumerics seems like a comprehensive implementation of Lapack in C#, but I can’t find anyone who’s shared their experiences with it anywhere. Math.NET seems like it could eventually be an excellent, comprehensive math library for .NET, but it’s difficult to tell how active the project is and it seems that it’s very much in flux in its current stage. Alglib has been spoken of once or twice as being solid, but I’d like to hear more about them relative to others. I like the idea of supporting a native F# numerics library, but I’m not certain how committed the developer (Flying Frog Consultancy) is to supporting and developing F# for Numerics… and what functionality they plan to include in their 1.0 release and what their target date is for a 1.0 release.

like image 485
Abe Avatar asked Nov 11 '10 21:11

Abe


2 Answers

One common pitfall of choosing math library is that we hope there exists a math library for everything.

Before finding a library, you should first ask "what kind of math library do I want?". Then you will have a list of criteria, such as open source or not, high performance or not, portable or not, easy to use or not.

Following are my comments on the libraries in your list (I haven't used the last two):

1) DotNumerics

(http://www.dotnumerics.com/)

They use a fortran2C# translator that translates the Lapack procedures code into C# classes. User friendly C# wrappers are written for the raw Lapack classes.

2) Alglib (http://www.alglib.net/)

This library is available in several languages, like delphi, c++ and c#. I believe it has longer history than any other libraries you listed.

Most of the functions are translated from Lapack. And its interface is not so user friendly. (But you have the flexibility of Lapack style interface.) Using lapack style interface means that you need to know more about the matrix and its operations.

3) dnAnalytics (http://dnanalytics.codeplex.com/)

This library is merging into Math.Net now. It seems that the merging is not done yet. A few functions in dnA is still not available in Math.Net.

4) Math.NET (http://www.mathdotnet.com/) Its implementation is from scratch, i.e., it is not a direct translation from Lapack. They aim to provide a purely managed library for .Net platform. That means easy usage and portability are two primary goals. One concern is that whether their own implementation is correct or not. One good thing is that this library is portable in the sense that you can use it on Mono, XNA, Windows Mobile Phone with little effort.

The above libraries dont' focus on F#. However one of the team members in Math.Net works for MS Research Cambridge and is an F# expert. Like Cuda said, they will work out an F# interface for the library. Also they will provide native wrappers. But maybe you will wait a long time, longer than "several months" :)

For the concern of high performance, the above libraries don't provide native wrappers (at least now). If you want native performance + .Net, you had better use a commercial library. There are some open source solutions:

1. http://ilnumerics.net/ This is a numpy like solution for .Net. They PInvoke to Lapack dlls (e.g. the non-optimized lapack at netlib, the optimized versions from AMD and Intel.)

2. math provider in F#. read my answer in this question. Since F# source code is now open sourced. I may revise the library and release my updates :)

Usually you don't need a big math library. You just need some functionality, e.g., if you need a fast matrix multiplication procedure, using PInovke to a platform optimized BLAS dll is the easiest way. If you need do a education oriented math software for kids, then the quality of Math.net is enough. If you are in a company and developing reliable math components, then why don't use a commercial one backed by a high-quality team?

Finding a perfect math library is hard. But finding a library solution to your problem is usually easy.

like image 86
Yin Zhu Avatar answered Sep 20 '22 15:09

Yin Zhu


F# for Numerics is a product of my company, written in 100% F#. Our emphasis is on general techniques (everything from FFTs to random number generation) and not specifically linear algebra although basic linear algebra routines are provided (Cholesky, LU, QR, SVD on various matrix/element types) and we are particularly interested in ease of use from F#.

If you're after the full breadth of LAPACK then my recommendations are Alglib if you're on a budget or Extreme Optimization if you can afford it. Alglib is entirely managed code with an, umm, "quirky" API so it is relatively slow to run and cumbersome to use. Extreme Optimization is a nicer API wrapping the Intel MKL and some extra routines so it is easier to use and much faster to run.

I should warn you that the general quality of .NET libraries (free, commercial and even the framework itself) is comparatively poor if you are coming from an open source background. I tried many of the other libraries that you mentioned and was not at all impressed with them.

like image 43
J D Avatar answered Sep 17 '22 15:09

J D