title: Removing the column(s) from matrices in a fast way C++
body: <p>Suppose that we have matrix <code>A (m*n)</code> stored in packed form (1-d array of size <code>m*n</code> - with leading dimension - columns). I need to get reduced matrices <code>A(S)</code> - which are resulted from deletion of 1 or more columns from <code>A</code>. I can easily to this by hand in the loops, but there is another approach - using selection matrices <code>I(S)</code> which are the identity matrices (all zeros but 1s on diagonal) with 1 or more column removed. Then, e.g. if I need to remove 3-rd row from <code>A</code>, I need to form <code>I(3)</code> - identity without 3rd column and then <code>A(3)=A*I(S)</code>. And since I'd need many variations of <code>A</code>, I would need all different identity matrices <code>I(S)</code> with different columns removed.</p>
  
  <p>I'm thinking of this way because I use Intel Math Kernel Library - which is extremely efficient for matrix multiplications.</p>
  
  <p>So the question is what do you think the fastest way of forming new matrix <code>A(S)</code>: by hand, directly working with <code>A</code> or first forming <code>I(S)</code> - and the question is how to quickly form these matrices - and then multiplying <code>A*I(S)</code> or you can suggest any other fast solution. </p>
  
  <p>To illustrate suppose that we have the matrix <code>A</code>:</p>
  
  <pre><code>1 2 3 
  
  4 5 6 
  
  7 8 9
  </code></pre>
  
  <p>It is stored in array <code>A=[1,4,7,2,5,8,3,6,9]. Suppose I need to form</code>A(2)` that is remove 2nd column. I need to have on output:</p>
  
  <pre><code>1 3 
  
  4 6 
  
  7 9
  </code></pre>
  
  <p>which is stored in C++ as <code>A_S=[1,4,7,3,6,9]</code>. 
  This can be done directly on matrix A, which would take <code>O(n^2)</code> time and not efficient for large matrices. Or we can form <code>I(2)</code>:</p>
  
  <pre><code>1 0
  
  0 1
  
  0 0
  </code></pre>
  
  <p>stored in c++ as <code>I_S = [1,0,0,0,1,0]</code>. Then <code>A(2) = A*I(2)</code></p>