title: How to create a sub-matrix in numpy
body: <p>I have a two-dimensional NxM numpy array:</p>
  
  <pre><code>a = np.ndarray((N,M), dtype=np.float32)
  </code></pre>
  
  <p>I would like to make a sub-matrix with a selected number of columns and matrices. For each dimension I have as input either a binary vector, or a vector of indices. How can I do this most efficient?</p>
  
  <p>Examples</p>
  
  <pre><code>a = array([[ 0,  1,  2,  3],
     [ 4,  5,  6,  7],
     [ 8,  9, 10, 11]])
  cols = [True, False, True]
  rows = [False, False, True, True]
  
  cols_i = [0,2]
  rows_i = [2,3]
  
  result = wanted_function(a, cols, rows) or wanted_function_i(a, cols_i, rows_i)
  result = array([[2,  3],
     [ 10, 11]])
  </code></pre>