[Numpy-discussion] Assembling an array from parts

Kevin Jacobs <jacobs@bioinformed.com> bioinformed@gmail....
Sun Apr 1 23:05:12 CDT 2007


I had to poke around before finding it too:

  bmat( [[K,G],[G.T, zeros(nc)]] )

On 4/1/07, Bill Baxter <wbaxter@gmail.com> wrote:
>
> What's the best way of assembling a big matrix from parts?
> I'm using lagrange multipliers to enforce constraints and this kind of
> matrix comes up a lot:
>
> [[ K,   G],
> [ G.T  , 0]]
>
> In matlab you can use the syntax
>    [K G; G' zeros(nc)]
>
> In numpy I'm using
>    vstack([ hstack([ K,G ]), hstack([ G.T, zeros((nc,nc)) ]) ])
>
> Which has a lot of excess verbiage and parentheses that make it hard
> to type and hard to parse what's going on.  It would be a little nicer
> if there were some kind of function like 'arraystack':
>
>   arraystack( [ [K, G], [G.T, zeros((nc,nc)) ]] )
>
> Is there anything like this already?  I haven't found anything in the
> example list like that.  But maybe concatenate() is flexible enough
>
> --bb
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070402/fb6f2fbf/attachment-0001.html 


More information about the Numpy-discussion mailing list