[SciPy-Dev] utility for composing sparse matrices
Mon Sep 20 08:26:16 CDT 2010
On Mon, Sep 20, 2010 at 6:25 AM, Robert Cimrman <firstname.lastname@example.org> wrote:
> 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])
>> 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.
I never heard of it either, but it looks useful and needs some advertising.
The equivalent of scipy.linalg.block_diag would also be very useful
for building sparse matrices (in stats).
>> 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.
> SciPy-Dev mailing list
More information about the SciPy-Dev