[Numpy-discussion] Matrix Class [was numpy release]
Tue Apr 29 03:50:59 CDT 2008
Bill Spotz wrote:
> On Apr 28, 2008, at 10:47 PM, Bill Spotz wrote:
>> As for this example, my version should work with a properly
>> implemented sparse_matrix A, but the array approach precludes that.
>> That is to say, I could convert A to a matrix if it is provided as an
>> array, but you could not convert a sparse_matrix to an array.
> I may be jumping to conclusions here. We could conceivably implement
> a sparse_array class upon which the sparse_matrix class is based.
In scipy, the iterative solvers (cg and like) should work with
LinearOperator (a class with matvec, rmatvec, and eventually matmat
methods) passed instead of the A matrix argument. There is a function
aslinearoperator() is scipy.sparse.linalg, that constructs a
LinearOperator instance from a numpy array, matrix and scipy sparse
matrix. It could be generalized to accept a function for a matrix-free
computation, too. Also LinearOperator.__mul__, __rmul__ could be easily
defined via matvec, rmatvec.
IMHO the all iterative solvers could use such a concept, to shield them
from what the system matrix A or the preconditioner actually are and to
be able writing them in a visually appealing way (i.e. close to what one
writes on a paper).
More information about the Numpy-discussion