title: Matrix Inverse using MathNet.Numerics
body: <p>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": </p>
  
  <pre><code>Matrix&lt;Complex32&gt; Ybus = Matrix&lt;Complex32&gt;.Build.Dense(numBuses, numBuses);
  
  Matrix&lt;Complex32&gt; Zbus = Matrix&lt;Complex32&gt;.Build.Dense(numBuses, numBuses);
  </code></pre>
  
  <p>My Ybus matches exactly the example in the book.</p>
  
  <pre><code>Ybus = j[ -13       5      4      0
              5   -13.5    2.5      2
              4     2.5     -9    2.5
              0       2    2.5   -4.5] 
  </code></pre>
  
  <p>But when I do an inversion </p>
  
  <pre><code>Zbus = Ybus.Inverse();
  </code></pre>
  
  <p>the results of Zbus are all NaN </p>
  
  <p>while the correct result from the book looks like this:</p>
  
  <pre><code>Zbus = j[ .15     .09    .12    .11
            .09     .15    .12    .13
            .12     .12    .25    .19
            .11     .13    .19    .39] 
  </code></pre>
  
  <p>Anyone have any ideas what the issue might be? Maybe inversion of a complex matrix has some issues?</p>
  
  <p><a href="https://i.stack.imgur.com/Se3o0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Se3o0.png" alt="enter image description here"></a></p>
  
  <p>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:</p>
  
  <p><a href="https://i.stack.imgur.com/tBiBo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tBiBo.png" alt="enter image description here"></a></p>