[Numpy-discussion] [help needed] associativity and precedence of '@'
Charles R Harris
charlesr.harris at gmail.com
Sat Mar 15 16:52:57 EDT 2014
On Sat, Mar 15, 2014 at 2:12 PM, Alexander Belopolsky <ndarray at mac.com>wrote:
>
> On Sat, Mar 15, 2014 at 4:00 PM, Charles R Harris <
> charlesr.harris at gmail.com> wrote:
>
>> These days they are usually written as v*w.T, i.e., the outer product of
>> two vectors and are a fairly common occurrence in matrix expressions. For
>> instance, covariance matrices are defined as E(v * v.T)
>
>
> With the current numpy, we can do
>
> >>> x = arange(1, 5)
> >>> x[:,None].dot(x[None,:])
> array([[ 1, 2, 3, 4],
> [ 2, 4, 6, 8],
> [ 3, 6, 9, 12],
> [ 4, 8, 12, 16]])
>
> I assume once @ becomes available, we will have
>
> >>> x[:,None] @ x[None,:]
> array([[ 1, 2, 3, 4],
> [ 2, 4, 6, 8],
> [ 3, 6, 9, 12],
> [ 4, 8, 12, 16]])
>
Yes, that works. I was thinking more of easy translation of the forms found
in textbooks. Householder reflection, for instance, is usually written as
I - 2 * v * v.T
Where the `v` are unit vectors.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140315/9dfc8612/attachment.html>
More information about the NumPy-Discussion
mailing list