I am trying to solve a Matrix in Math.Net when one of the actual solutions to the matrix is 0, but I am getting -NaN- as results.
Here is an example matrix which has already been reduced for simplicity.
1 0 1 | 10000
0 1 -1 | 1000
0 0 0 | 0
Code example:
public void DoExample()
{
Matrix<double> A = Matrix<double>.Build.DenseOfArray(new double[,] {
{ 1, 0, 1 },
{ 0, 1, -1 },
{ 0, 0, 0 },
});
Vector<double> B = Vector<double>.Build.Dense(new double[] { 10000, 1000, 0 });
var result = A.Solve(B);
}
The solution I am hoping to get to is [ 10000, 1000, 0 ].
As you can see, the result I want is already the augment vector. This is because I simplified the matrix to reduced row echelon form (RREF) by hand using Gauss-Jordan for this example. If I could somehow use a Gauss-Jordan operations within Math.Net to do this, I could check for the scenario where an all 0 row exists in the RREF matrix. Can this be done?
Otherwise, is there any way I can recognize when 0 is the only possible solution for one of the variables using the existing Math.Net linear algebra solver operations?
Thanks!