Решение линейной системы с помощью Math.Net
Я пытаюсь решить линейную систему с помощью Math.Net со следующим кодом:
Print(ABlock.ToString());
Matrix<double> A = (2 * ABlock).InsertColumn(ABlock.ColumnCount, Vector<double>.Build.Dense(numSec, i => 1)).InsertRow(ABlock.RowCount, Vector<double>.Build.Dense(numSec + 1, i => 1));
A[A.RowCount - 1, A.ColumnCount - 1] = 0;
Print(A.ToString());
Vector<double> rightVector = Vector<double>.Build.Dense(numSec + 1, i => 0);
rightVector[rightVector.Count - 1] = 1;
Print(rightVector.ToString());
var solution = A.Solve(rightVector);
Print(solution);
Операторы печати возвращают следующее:
08/01/2020 09:00:00.241 DenseMatrix 6x6-Double 2.67283E-06
-1.5181E-06 1.41889E-06 2.83207E-06 1.30192E-08 1.76415E-08 -1.5181E-06 1.15091E-06 -2.83832E-07 -1.70733E-06 -1.04462E-06 -5.46717E-07 1.41889E-06 -2.83832E-07 1.69738E-06 1.32477E-06 -1.86892E-06 -9.61262E-07 2.83207E-06 -1.70733E-06 1.32477E-06 3.03461E-06 3.68749E-07 2.02359E-07 1.30192E-08 -1.04462E-06 -1.86892E-06 3.68749E-07 3.72695E-06 1.92852E-06 1.76415E-08 -5.46717E-07 -9.61262E-07 2.02359E-07 1.92852E-06 9.9796E-07
08/01/2020 09:00:00.241 DenseMatrix 7x7-Double 5.34566E-06
-3.0362E-06 2.83777E-06 5.66415E-06 2.60385E-08 3.5283E-08 1 -3.0362E-06 2.30181E-06 -5.67663E-07 -3.41466E-06 -2.08923E-06 -1.09343E-06 1 2.83777E-06 -5.67663E-07 3.39475E-06 2.64953E-06 -3.73784E-06 -1.92252E-06 1 5.66415E-06 -3.41466E-06 2.64953E-06 6.06923E-06 7.37497E-07 4.04718E-07 1 2.60385E-08 -2.08923E-06 -3.73784E-06 7.37497E-07 7.4539E-06 3.85704E-06 1 3.5283E-08 -1.09343E-06 -1.92252E-06 4.04718E-07 3.85704E-06 1.99592E-06 1 1 1 1 1 1 1 0
08/01/2020 09:00:00.241 DenseVector 7-Double 0 0 0 0 0 0 1
08/01/2020 09:00:00.241 DenseVector 7-Double NaN NaN NaN NaN ∞ -∞ 7.40686E-23
However, when I use the matrix A
and the vector rightVector
in Python, I get a "non-nan" solution. Why isn't it so with Math.Net?