[Numpy-discussion] Vector stacks

Eric Wieser wieser.eric+numpy at gmail.com
Sat Jul 1 18:38:56 EDT 2017

What would these classes offer over these simple functions:

def rvec(x):  return x[...,np.newaxis,:]def cvec(x):  return x[...,:,np.newaxis]

That also makes rvec(x) + cvec(y) behave in the least surprising way, with
no extra work


On Sat, 1 Jul 2017 at 23:32 Charles R Harris <charlesr.harris at gmail.com>

> Hi All,
> The  '@' operator works well with stacks of matrices, but not with stacks
> of vectors. Given the recent addition of '__array_ufunc__',  and the intent
> to make `__matmul__` use a ufunc, I've been wondering is it would make
> sense to add ndarray subclasses 'rvec' and 'cvec' that would override that
> operator so as to behave like stacks of row/column vectors. Any other ideas
> for the solution to stacked vectors are welcome.
> Thoughts?
> Chuck
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20170701/0bd98012/attachment.html>

More information about the NumPy-Discussion mailing list