On Mon, Jul 03, 2006 at 11:16:26AM +0900, Bill Baxter wrote:
> What's the best way to combine say several 2-d arrays together into a grid?
> Here's the best I can see:
> 
> >>> a = eye(2,2)
> >>> b = 2*a
> >>> c = 3*a
> >>> d = 4*a
> >>> r_[c_[a,b],c_[c,d]]
> array([[1, 0, 2, 0],
>        [0, 1, 0, 2],
>        [3, 0, 4, 0],
>        [0, 3, 0, 4]])
> 
> In matlab you'd get the same effect by saying:   [ a, b; c, d ]
> 
> Compared to that,  r_[c_[a,b],c_[c,d]] looks quite a mess.

You could always explicitly write out what you are doing, i.e.

In [47]: N.vstack((N.hstack((a,b)), N.hstack((c,d))))
Out[47]:
array([[ 1.,  0.,  2.,  0.],
       [ 0.,  1.,  0.,  2.],
       [ 3.,  0.,  4.,  0.],
       [ 0.,  3.,  0.,  4.]])

Stéfan

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to