scipy/scipy — pull request #2692 by andrenarchy (2013-08-05 16:01:27+00:00)
Title: [ENH]: sparse.linalg.LinearOperator: add +, -, *, and ** operators

These commits enhance the `LinearOperator` class in `sparse.linalg` such that they can be added/substracted, multiplied and exponentiated. Unit tests are included and should cover all cases. I restructured the unit test for `LinearOperator` a bit.

# Background
With Krylov subspace methods, like the ones in `sparse.linalg` or in external packages like [KryPy](https://github.com/andrenarchy/krypy) (which I maintain), the `LinearOperator` class is very handy. However, sometimes you need to add or multiply LinearOperators. With these commits you can combine `LinearOperator`s like this:
```python
from scipy.sparse.linalg import LinearOperator
A = LinearOperator([2,2], lambda x: [5*x[0]+x[1], -x[0]])
I = LinearOperator([2,2], lambda x: x)

B = A*(I-A)**2 + I

print(B*[1,1])
```