[SciPy-user] New bmat constructor in SciPy

Travis E. Oliphant scipy-user@scipy.net
Tue Sep 23 19:31:49 CDT 2003

One of SciPy's goals is to ease transition to Python for Matlab users.

In that light r_[] and c_[] were added some time ago (but perhaps not 
well documented)

As I mentioned before

F = r_[c_[A,B],c_[C,D]]  would construct  F = [A  B]
                                               [C  D]

now, a new function has been added that does the same thing, but also 
creates a matrix object.

bmat (short for build matrix)

bmat([[A,B],[C,D]]) = bmat('A,B; C,D') = bmat(r_[c_[A,B],c_[C,D]])

This returns a Matrix object (* is matrix multiplication for this guy) 
constructed from the blocks A, B, C and D.

Of course these blocks must have the right shapes or an error will be 


r_['A,B;C,D']  does the same thing.

I hope this helps.

-Travis O.

More information about the SciPy-user mailing list