Popular recipes tagged "infix"http://code.activestate.com/recipes/tags/infix/popular/2010-06-07T05:57:07-07:00ActiveState Code RecipesInfix operators for numpy arrays (Python)
2010-06-07T05:57:07-07:00John Schulmanhttp://code.activestate.com/recipes/users/4171677/http://code.activestate.com/recipes/577201-infix-operators-for-numpy-arrays/
<p style="color: grey">
Python
recipe 577201
by <a href="/recipes/users/4171677/">John Schulman</a>
(<a href="/recipes/tags/array/">array</a>, <a href="/recipes/tags/infix/">infix</a>, <a href="/recipes/tags/matrix/">matrix</a>, <a href="/recipes/tags/multiplication/">multiplication</a>, <a href="/recipes/tags/numpy/">numpy</a>).
Revision 3.
</p>
<p>This recipe adapts the infix operator trick from <a href="http://code.activestate.com/recipes/384122-infix-operators/" rel="nofollow">http://code.activestate.com/recipes/384122-infix-operators/</a> to give the appropriate behavior with numpy arrays, so you can write A *dot* B for np.dot(A,B)</p>
<p>UPDATE
A solution to the dot problem was recently added to the numpy trunk: the dot method was added to the ndarray class so you can write a.dot(b). See <a href="http://projects.scipy.org/numpy/ticket/1456" rel="nofollow">http://projects.scipy.org/numpy/ticket/1456</a></p>