[Numpy-discussion] Generalize hstack/vstack --> stack; Block matrices like in matlab
cjw at ncf.ca
Mon Sep 8 18:14:24 EDT 2014
On 08-Sep-14 4:40 PM, Joseph Martinot-Lagarde wrote:
> Le 08/09/2014 15:29, Stefan Otte a écrit :
>> quite often I work with block matrices. Matlab offers the convenient notation
>> [ a b; c d ]
This would appear to be a desirable way to go.
Numpy has something similar for strings. The above is neater.
>> to stack matrices. The numpy equivalent is kinda clumsy:
>> vstack([hstack([a,b]), hstack([c,d])])
>> I wrote the little function `stack` that does exactly that:
>> 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
>> . I'm looking forward to getting some feedback!
>>  https://github.com/numpy/numpy/pull/5057
> The outside brackets are redundant, stack([[a, b], [c, d]]) should be
> stack([a, b], [c, d])
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
More information about the NumPy-Discussion