Algorithm Base Class

class fastmat.algorithms.Algorithm

Bases: object

Algorithm Base Class

The baseclass of all algorithms that operate on Matrices. This abstract baseclass introduces general framework concepts such as interfaces for parameter specification, algorithm execution, logging and callbacks.

>>> algI = fma.ISTA(Fourier(10))
>>> algI.cbResult = lambda i: print(i.arrResult)
>>> algI.cbStep = lambda i: print(i.numStep)
>>> algI.cbTrace = fma.Algorithm.snapshot
>>> algI.process(np.ones(10) + np.random.randn(10))
>>> plt.imshow(np.hstack((np.abs(tt.arrX) for tt in algI.trace)))
__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.


Call the callback if it is not None.


Process an array of data by the algorithm.

This method also accepts passing additional parameters as keyworded arguments. These arguments will be applied to the algorithm instance using self.updateParameters().

If no additional parameters are required the self._process() method may also be called directly for slightly higher call performance.


Add the current instances’ state (without the trace) to the trace.


Update the parameters of the algorithm instance with the supllied keyworded arguments.

Apply the set of parameters specified in kwargs by iteratively passing them to setattr(self, …). Specifying an parameter which does not have a mathing attribute in the algorithm class will cause an AttributeError to be raised.