title: Python equivalent of MATLAB's lsqr() with first argument a function
body: <p>As per title, I am looking for a Python equivalent of MATLAB's <code>lsqr()</code> (possibly in NumPy / SciPy) when the first argument is a function.</p>
  
  <p>Briefly, <code>lsqr</code> solves numerically for <code>x</code> the following problem:</p>
  
  <pre><code>argmin_x || A*x - b ||_2
  </code></pre>
  
  <p>where <code>x</code> and <code>b</code> are vectors (of potentially different size) and <code>A</code> is a linear operator.</p>
  
  <p>I believe that for numerical input the equivalent is <code>numpy.linalg.lstsq()</code>.</p>
  
  <p>The function <code>scipy.optimize.least_squares()</code> can, in principle, be used for solving the argmin problem, but it seems that it uses a different (and much slower) algorithm internally, which seems unsuited for optimization over relatively large inputs.</p>
  
  <p>I believe that <code>lsqr()</code> internally uses <code>A*x</code> and <code>A'*b</code> and does not require an explicit rappresentation of <code>A</code>.</p>
  
  <p>So, is there an equivalent of MATLAB's <code>lsqr</code> (with first argument a function)?</p>