[Numpy-discussion] Generalize hstack/vstack --> stack; Block matrices like in matlab

josef.pktd at gmail.com josef.pktd at gmail.com
Mon Sep 8 12:08:12 EDT 2014


On Mon, Sep 8, 2014 at 10:41 AM, Sturla Molden <sturla.molden at gmail.com>
wrote:

> Stefan Otte <stefan.otte at gmail.com> wrote:
>
> >     stack([[a, b], [c, d]])
> >
> > In my case `stack` replaced `hstack` and `vstack` almost completely.
> >
> > If you're interested in including it in numpy I created a pull request
> > [1]. I'm looking forward to getting some feedback!
>

np.asarray(np.bmat(....)) ?

Josef



>
> As far as I can see, it uses hstack and vstack. But that means a and b have
> to have the same number of rows, c and d must have the same rumber of rows,
> and hstack((a,b)) and hstack((c,d)) must have the same number of columns.
>
> Thus it requires a regularity like this:
>
> AAAABB
> AAAABB
> CCCDDD
> CCCDDD
> CCCDDD
> CCCDDD
>
> What if we just ignore this constraint, and only require the output to be
> rectangular? Now we have a 'tetris game':
>
> AAAABB
> AAAABB
> CCCCBB
> CCCCBB
> CCCCDD
> CCCCDD
>
> or
>
> AAAABB
> AAAABB
> CCCCBB
> CCCCBB
> CCCCBB
> CCCCBB
>
> This should be 'stackable', yes? Or perhaps we need another stacking
> function for this, say numpy.tetris?
>
> And while we're at it, what about higher dimensions? should there be an
> ndstack function too?
>
>
> Sturla
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140908/99a33e40/attachment.html>


More information about the NumPy-Discussion mailing list