I'm writing some C# code that uses MathNet.Numerics.LinearAlgebra, and trying to match results with a textbook example. One part of the code does an inversion of a complex32 array "Ybus", and stores it in another array "Zbus":
Matrix<Complex32> Ybus = Matrix<Complex32>.Build.Dense(numBuses, numBuses);
Matrix<Complex32> Zbus = Matrix<Complex32>.Build.Dense(numBuses, numBuses);
My Ybus matches exactly the example in the book.
Ybus = j[ -13 5 4 0
5 -13.5 2.5 2
4 2.5 -9 2.5
0 2 2.5 -4.5]
But when I do an inversion
Zbus = Ybus.Inverse();
the results of Zbus are all NaN
while the correct result from the book looks like this:
Zbus = j[ .15 .09 .12 .11
.09 .15 .12 .13
.12 .12 .25 .19
.11 .13 .19 .39]
Anyone have any ideas what the issue might be? Maybe inversion of a complex matrix has some issues?
Lesson learned: don't make your arrays too big so that they have rows of 0's or the inverse will blow up :) ... Here's the right answer: