5

I'm looking for a C# linear algebra library.

I wan't to solve a homogeneous linear system with least squares minimization.

I've been trying to use some librarys but I was just able to find the trivial solution.

Any recommendations?

Bruna
  • 366
  • 2
  • 15
  • 2
    Have other questions on this topic not helped (e.g. http://stackoverflow.com/questions/392857/c-sharp-linear-algebra-library)? Which libraries have you tried? Math.NET? Please give details. :) – James Dec 19 '11 at 15:06
  • 3
    Perhaps Singular Value Decomposition of the [Accord.NET](http://accord-net.origo.ethz.ch/wiki/features) would help? – oleksii Dec 19 '11 at 15:22

2 Answers2

3

See:

They are open source too!

2

As commenter oleksii mentioned, you can use Accord.NET to achieve this as well. But you can also use its Solver extension method for that instead of manually creating a SVD:

// Suppose you have matrices A and b and would
// like to find x such that Ax = b (solve for x). 

// So you would have matrices
double[,] A = ... // matrix A
double[]  b = ... // vector b

// Then all that is necessary is to call:
double[] x = A.Solve(b, leastSquares: true);

And that is it. It also works when b is a matrix as well.

Disclaimer: I am the author of this library.

Cesar
  • 2,059
  • 25
  • 30
  • 1
    Are you sure this works? I used your code. Unfortunately, there is an error: "Error 1 'System.Array' does not contain a definition for 'Solve' and no extension method 'Solve' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?) " Where am I going wrong? – math Aug 15 '13 at 10:18
  • Hmmm... Please make sure you are adding the directive "using Accord.Math;" on top of your source file, and see if it helps. If it doesn't, please let me know! – Cesar Aug 16 '13 at 13:50
  • 3
    Like the disclaimer! :D – grapeot Jun 06 '14 at 22:29