[Numpy-discussion] matmul needs some clarification.
Charles R Harris
charlesr.harris at gmail.com
Wed Jun 3 17:12:48 EDT 2015
On Wed, Jun 3, 2015 at 1:38 PM, Alexander Belopolsky <ndarray at mac.com>
wrote:
>
> On Sat, May 30, 2015 at 6:23 PM, Charles R Harris <
> charlesr.harris at gmail.com> wrote:
>
>> The problem arises when multiplying a stack of matrices times a vector.
>> PEP465 defines this as appending a '1' to the dimensions of the vector and
>> doing the defined stacked matrix multiply, then removing the last dimension
>> from the result. Note that in the middle step we have a stack of matrices
>> and after removing the last dimension we will still have a stack of
>> matrices. What we want is a stack of vectors, but we can't have those with
>> our conventions. This makes the result somewhat unexpected. How should we
>> resolve this?
>
>
> I think that before tackling the @ operator, we should implement the pure
> dot of stacks of matrices and dot of stacks of vectors generalized ufuncs.
> The first will have a 2d "core" and the second - 1d. Let's tentatively
> call them matmul and vecmul. Hopefully matrix vector product can be
> reduced to the vecmul,
> but I have not fully figured this out. If not - we may need the third
> ufunc.
>
The `@` operator is done. I originally started with four ufuncs, mulvecvec,
mulmatvec, etc, but decided to wait on that until we merged the ufunc and
multiarray packages and did some other ufunc work. The matmul function can
certainly be upgraded in the future, but is as good as dot right now except
it doesn't handle object arrays.
>
> Once we have these ufuncs, we can decide what @ operator should do in
> terms of them and possibly some axes manipulation.
>
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150603/83a30a53/attachment.html>
More information about the NumPy-Discussion
mailing list