[Numpy-discussion] Proposal: Chaining np.dot with mdot helper function

Eelco Hoogendoorn hoogendoorn.eelco at gmail.com
Thu Feb 20 09:41:36 EST 2014


Erik; take a look at np.einsum

The only reason against such dot semantics is that there isn't much to be
gained in elegance that np.einsum already provides, For a plain chaining,
multiple arguments to dot would be an improvement; but if you want to go
for more complex products, the elegance of np.einsum will be hard to beat


On Thu, Feb 20, 2014 at 3:27 PM, Eric Moore <ewm at redtetrahedron.org> wrote:

>
>
> On Thursday, February 20, 2014, Eelco Hoogendoorn <
> hoogendoorn.eelco at gmail.com> wrote:
>
>> If the standard semantics are not affected, and the most common
>> two-argument scenario does not take more than a single if-statement
>> overhead, I don't see why it couldn't be a replacement for the existing
>> np.dot; but others mileage may vary.
>>
>>
>> On Thu, Feb 20, 2014 at 11:34 AM, Stefan Otte <stefan.otte at gmail.com>wrote:
>>
>>> Hey,
>>>
>>> so I propose the following.  I'll implement a new function `mdot`.
>>> Incorporating the changes in `dot` are unlikely. Later, one can still
>>> include
>>> the features in `dot` if desired.
>>>
>>> `mdot` will have a default parameter `optimize`.  If `optimize==True` the
>>> reordering of the multiplication is done.  Otherwise it simply chains the
>>> multiplications.
>>>
>>> I'll test and benchmark my implementation and create a pull request.
>>>
>>> Cheers,
>>>  Stefan
>>> _______________________________________________
>>> NumPy-Discussion mailing list
>>> NumPy-Discussion at scipy.org
>>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>>
>>
>> Another consideration here is that we need a better way to work with
> stacked matrices such as np.linalg handles now.  Ie I want to compute the
> matrix product of two (k, n, n) arrays producing a (k,n,n) result.  Near
> as  I can tell there isn't a way to do this right now that doesn't involve
> an explicit loop. Since dot will return a (k, n, k, n) result. Yes this
> output contains what I want but it also computes a lot of things that I
> don't want too.
>
> It would also be nice to be able to do a matrix product reduction, (k, n,
> n) -> (n, n) in a single line too.
>
> Eric
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140220/2721987f/attachment.html>


More information about the NumPy-Discussion mailing list