[Numpy-discussion] Assembling an array from parts

Bill Baxter wbaxter@gmail....
Sun Apr 1 21:41:31 CDT 2007

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


More information about the Numpy-discussion mailing list