title: MathNET Matrix Casting
body: <p>I have recently started using the MathNET library and it is awesome. I am working heavily with matrices and vectors. The library works great, but I am finding that I have to use casting all the time; an example of this would be:</p>
  
  <pre><code>using MathNet.Numerics.LinearAlgebra.Double;
  ...
  Matrix P = (DenseMatrix)(T.Multiply(P.TransposeAndMultiply(T)) + 
      R.Multiply(Q.TransposeAndMultiply(R)));
  </code></pre>
  
  <p>or </p>
  
  <pre><code>using MathNet.Numerics.LinearAlgebra.Double;
  ...
  Vector a, v, y;
  Matrix F, K, Z;
  ...
  Matrix FI = (DenseMatrix)F.Inverse();
  if (FI != null)
      K = (DenseMatrix)K.Multiply(FI);
  ...
  v = (DenseVector)(y - Z.Multiply(a));
  </code></pre>
  
  <p>Why do I have to cast using (<code>(DenseMatrix)</code>/<code>(DenseVector)</code>) and is there a way around having to do this for each operation?</p>