I am trying to solve a system of homogeneous linear equations like Ax=0
.
Here is an example matrix which has already been reduced for simplicity:
1 2 | 0
3 6 | 0
The solution I am hoping to get is at least [ 2, -1 ]
. But the fundamental solution is [2C; -1C]
. You can see that Det(A) = 0
and Rank(A) = 1
. Of course you know that such systems have trivial solution [0,0]
.
I am trying:
Matrix<double> A = Matrix<double>.Build.DenseOfArray(new double[,]
{
{ 1, 2 },
{ 3, 6 }
});
Vector<double> B = Vector<double>.Build.Dense(new double[] { 0, 0 });
var result = A.Solve(B); //result = Nan, Nan.
This solution doesn't work for my situation (B = 0, Det(A) = 0).
To solve linear equations you can try
Matrix<T>.SolveIterative(Vector<T> input, IIterativeSolver<T> solver, Iterator<T> iterator = null, IPreconditioner<T> preconditioner = null)
.To get available solvers:
It gives:
Try them all with you data:
Like this:
In your case it's no luck. The result is:
Though it could work like here.
Anyway
MathNet
is so good that one can easily build the solution.Using linear algebra from college and the library functionality:
And now:
Gives:
Another example:
Gives: