[Numpy-discussion] ndarray.T2 for 2D transpose
Charles R Harris
charlesr.harris at gmail.com
Fri Apr 8 12:59:22 EDT 2016
On Thu, Apr 7, 2016 at 4:03 PM, Stéfan van der Walt <stefanv at berkeley.edu>
> On 7 April 2016 at 11:17, Chris Barker <chris.barker at noaa.gov> wrote:
> > np.col_vector(arr)
> > which would be a synonym for np.reshape(arr, (-1,1))
> > would that make anyone happy?
> I'm curious to see use cases where this doesn't solve the problem.
> The most common operations that I run into:
> colvec = lambda x: np.c_[x]
> x = np.array([1, 2, 3])
> A = np.arange(9).reshape((3, 3))
> 1) x @ x (equivalent to x @ colvec(x))
> 2) A @ x (equivalent to A @ colvec(x), apart from the shape)
> 3) x @ A
> 4) x @ colvec(x) -- gives an error, but perhaps this should work and
> be equivalent to np.dot(colvec(x), rowvec(x)) ?
> If (4) were changed, 1D arrays would mostly* be interpreted as row
> vectors, and there would be no need for a rowvec function. And we
> already do that kind of magic for (2).
Apropos column/row vectors, I've toyed a bit with the idea of adding a flag
to numpy arrays to indicate that the last index is one or the other, and
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion