[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Order of matrix multiplication

From: Bernardo Sulzbach
Subject: Re: Order of matrix multiplication
Date: Mon, 12 Sep 2016 18:05:26 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 09/12/2016 04:54 PM, Nicholas Jankowski wrote:
On Mon, Sep 12, 2016 at 2:59 PM, Yu Liu <address@hidden> wrote:

FYI, numpy has a special function np.linalg.multi_dot to do this.
Their code has very detailed explanation of the well-known algorithm.

definitely looks like something that could be adapted.  That said, I did
just recall that there is an existing bug waiting to have a patch tested
and committed for mtimes related to improperly flattening an ND array. So
if anyone starts looking to make changes it should take the current offered
patch into account:

from that report it seems fixing mtimes was not the most trivial of tasks,
so 'tread with care'

numpy/linalg/ is a great resource. It seems to me definitely worth trying to perform such optimizations. Even if we in the end preserve mtimes (lack of) parenthesization for some reason, having another function which would figure out an optimal parenthesization by solving the matrix chain ordering problem (assuming it doesn't already exists around these parts) would be a nice thing.

I think it could definitely be a function of its own. See that the algorithm may introduce some noticeable overhead when determining how to best multiply the matrices while not giving anything back in return. Maybe mtimes docs should then point to this function saying that it does attempt to optimize parenthesization before multiplying the matrices. Also, if this was made into another function, the aforementioned ticked would not be an implementation blocking issue.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]