title: Point-wise Multiply Column Array and Matrix using Math.Net Numerics with C#
body: <p>I want to perform a point-wise multiplication of a column array with each column array/vector in a given Matrix in C# using the Math.Net Numerics library.</p>
  
  <p>There is little documentation on operations like this, so far I have the code below which doesn't work. I am trying to use LINQ as I prefer that over for loops. the problem I'm having with LINQ is I can't reassign my matrix when I try to enumerate each column of my matrix as a vector and do the PointwiseMultiply() method.</p>
  
  <p>Matrix <em>fitKernel</em> is my matrix, and I want to point-wise multiply each column by the <em>wF</em> column array and update my matrix <em>fitKernel</em> using LINQ. fitKernel is 9 x 5 Matrix, and wF is a 9 x 1 double[] array that I convert to a Vector in the LINQ below.</p>
  
  <pre><code>Matrix&lt;double&gt; fitKernel = Matrix&lt;double&gt;.Build.DenseOfColumnArrays(c1, c2, c3, c4, ones); 
  
  double[] wF = Enumerable.Repeat(1.0, 9).ToArray();
  
  fitKernel = fitKernel.EnumerateColumns()
              .Select(v =&gt; v.PointwiseMultiply(Vector&lt;double&gt;.Build.DenseOfArray(wF)));
  </code></pre>
  
  <p>The above code using the EnumerateColumns() returns an IEnumerable of vectors, but when I try to assign the value to fitKernel it complains about assigning a type of Enumerable to a Matrix.</p>