I'm trying to understand the documentation on the scipy.optimize.least_squares
function:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.least_squares.html
The possibilities for inputs are a bit messy, and the documentation is not super clear on all of them. It says that the argument jac
can be a callable returning a LinearOperator
.
I suppose, the provided
LinearOperator
is supposed to represent the Jacobian as a linear operator mapping the variable shifts to the residual shifts. Or is it the other way round?Which operations do I need to implement for the
LinearOperator
? Onlymatvec
, ormatmat
as well?Does providing a
LinearOperator
instead of the full Jacobi matrix actually speed up anything? Or is the full matrix built from the operator anyways? (And yes, in my example, evaluating theLinearOperator
is much faster than building the whole Jacobi matrix.)