Il n'existe qu'une seule version de tous les ufuncs standard de numpy - en utilisant dot comme exemple
Type: builtin_function_or_method
Base Class: <type 'builtin_function_or_method'>
String Form: <built-in function dot>
Namespace: Interactive
Docstring:
dot(a, b, out=None)
Dot product of two arrays.
For 2-D arrays it is equivalent to matrix multiplication, and for 1-D
arrays to inner product of vectors (without complex conjugation). For
N dimensions it is a sum product over the last axis of `a` and
the second-to-last of `b`::
dot(a, b)[i,j,k,m] = sum(a[i,j,:] * b[k,:,m])
Parameters
----------
a : array_like
First argument.
b : array_like
Second argument.
out : ndarray, optional
Output argument. This must have the exact kind that would be returned
if it was not used. In particular, it must have the right type, must be
C-contiguous, and its dtype must be the dtype that would be returned
for `dot(a,b)`. This is a performance feature. Therefore, if these
conditions are not met, an exception is raised, instead of attempting
to be flexible.
Si vous fournissez le troisième argument optionnel avec le bon dtype et l'ordre de stockage, cela fonctionnera :
In [78]: a=np.array([1.,2.,3.,4.])
In [79]: b=np.diag(a)
In [80]: c=np.empty_like(a)
In [81]: np.dot(a,b,c)
Out[81]: array([ 1., 4., 9., 16.])
In [82]: np.dot(a,b)
Out[82]: array([ 1., 4., 9., 16.])