SciPy Interface


SciPy offers a large zoo of algorithms which exploit the possibility to pass a so called LinearOperator, which only provides methods for forward and backward transforms together with some simple properties like a datatype and shape parameters. This is exactly what we can provide for a specific instance of a fastmat Matrix. To this end, each fastmat Matrix has the (read only) property scipyLinearOperator, which provides a SciPy Linear operator realizing the transform specified by the fastmat object.

This allows to combine fastmat and SciPy in the most efficient manner possible. Here, fastmat provides the simple and efficient description of a huge variety of linear operators, which can then be used neatly and trouble free in SciPy.


The interface is provided by the factory fastmat.Matrix.scipyLinearOperator(), which returns an instance of scipy.sparse.linalg.LinearOperator. All fastmat matrices can be used from scipy methods supporting this interface, offering a wide range of functionality – by combining both worlds – to the user.

For a code example, see Solve a System of Linear Equations with Preconditioning.