[SciPy-Dev] utility for composing sparse matrices

Robert Cimrman cimrman3@ntc.zcu...
Mon Sep 20 05:25:41 CDT 2010

On Mon, 20 Sep 2010, Pauli Virtanen wrote:

> Mon, 20 Sep 2010 10:26:58 +0200, Robert Cimrman wrote:
>> FYI: I have created a function that creates a sparse matrix from sparse
>> (or dense) blocks, somewhat in the spirit of np.r_ and friends, see the
>> example below.
>> Shall we add it to scipy.sparse? It may help to go around some of the
>> fancy-indexing limitations.
> Add some tests, and I see no problem in putting it in. Also, I'd check
> that cases such as
> 	compose_sparse([A, B])
> 	compose_sparse(A)
> are handled sensibly.
> Also, the equivalent function in `Numpy` is called `bmat`. Should the
> name here reflect that.

I have been using numpy so long, unaware of bmat - call me exlusive array 
user :). It's sensible to make it work with 0D and 1D arrays, yes.

> Also, we would need to think if it is possible to get the sparse matrices
> in Scipy to play along with functions in Numpy. (E.g. np.bmat() and
> np.linalg.dot() doing the correct stuff for sparse matrices.)

I would love to see this. I guess some basic sparse matrix support would 
have to be in Numpy directly(?). A good candidate is IMHO the COO format - 
it is simple, can be easily converted and has the 'data' array.

I will create an enhancement ticket with the function renamed to bmat, and 
a test, then.


More information about the SciPy-Dev mailing list