[SciPy-user] Sparse: Efficient metod to convert to CSC format
William Hunter
willemjagter at gmail.com
Mon Oct 2 03:30:59 CDT 2006
I've been bugging Robert C. and Ed S. (thanks guys) for a while about
this now, but I think it might be good if I share my experiences with
other users.
When converting a sparse matrix to CSC format, one of the quickest
ways to get there is to give <sparse.csc_matrix> three vectors
containing;
(1) [values]: the values,
(2) [rowind]: the row indices and
(3) [colptr]: the column pointer.
If one times how long it takes to get your CSC matrix by doing
sparse.csc_matrix((values, rowind, colptr)) compared to the other ways
to get it, e.g., csc_matrix(dense_mtx), I've found that the first
method is faster (enough to be significant for me).
One can solve a sparse system with <linsolve.spsolve>, if your matrix
is in CSC format. And here's my question: Let's say I have a way (and
I might :-)) to construct those 3 vectors very quickly, how can I use
them directly as arguments in <linsolve.spsolve>? For example:
solution = linsolve.spsolve([values],[rowind],[colptr],[RHS])
This way I can skip the conversion to CSC format since it's already in
that form, albeit 'decomposed'.
--
William
More information about the SciPy-user
mailing list