[Numpy-discussion] matmul as a ufunc
matti.picus at gmail.com
Mon May 21 20:42:33 EDT 2018
I have made progress with resolving the issue that matmul, the operation
which implements `a @ b`, is not a ufunc . Discussion on the issue,
which prevents the __array_ufunc__ mechanism for overriding matmul on
subclasses of ndarray, yeilded two approaches:
- create a wrapper that can convince the ufunc mechanism to call
__array_ufunc__ even on functions that are not true ufuncs
- expand the semantics of core signatures so that a single matmul ufunc
can implement matrix-matrix, vector-matrix, matrix-vector, and
I have put up prototypes of both approaches as pr 11061  and 11133
, they are WIP to prove the concept and are a bit rough. Either
approach can be made to work.
Which is preferable?
What are the criteria we should use to judge the relative merits
(backward compatibility, efficiency, code clarity, enabling further
enhancements, ...) of the approaches?
More information about the NumPy-Discussion