Skip to content
This repository has been archived by the owner on Feb 20, 2020. It is now read-only.

sotte/numpy_mdot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tired of numpy.dot?

Note: this is pre alpha!

TODO change that!

TODO Ideally this thould be integrated in numpy.

mdot chains multiplication calls and allows you to write

mdot(A, B, C, D)

instead of

np.dot(np.dot(np.dot(A, B), C), D)
A.dot(B).dot(C).dot(D)

Did I mention that it automatically speeds up the multiplication by setting the parens in an optimal fashion:

>>> %timeit np.dot(np.dot(np.dot(A, B), C), D)
1 loops, best of 3: 694 ms per loop
>>> %timeit mdot(A, B, C, D)
100 loops, best of 3: 5.18 ms per loop

Still, not satisfied? Get red rid of the overhead for calculating the optimal parens once and then use the expression:

>>> print_optimal(D, A, B, C, names=list("DABC"))
"np.dot(np.dot(D, np.dot(A, B)), C)"

Releases

No releases published

Packages

No packages published

Languages