title: How to calculate the generalized inverse of a Sparse Matrix in scipy
body: <p>I have a sparse matrix W, when I use <code>linalg.pinv(W)</code>, it throws some errors:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/ad9075/PycharmProjects/bednmf/test.py", line 14, in testNmfRun
      self.factor = factorization(self.V)
    File "/Users/ad9075/PycharmProjects/bednmf/nmf.py", line 18, in factorization
      W_trans = linalg.pinv(W)
    File "/Library/Python/2.7/site-packages/scipy/linalg/basic.py", line 540, in pinv
      b = np.identity(a.shape[0], dtype=a.dtype)
  IndexError: tuple index out of range`
  </code></pre>
  
  <p>But when I modify it to <code>linalg.pinv(W.todense())</code>, it works well. However, do I really need to convert the sparse matrix if I want to calculate the <strong>generaized inverse</strong>? Does anyone have ideas about this?</p>
  
  <p>Thanks!</p>