diff options
author | Pauli Virtanen <pav@iki.fi> | 2010-10-14 11:04:51 +0200 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2010-10-14 11:05:01 +0200 |
commit | eca8f94e294003336d901b7e718375fad0c2619c (patch) | |
tree | 63fe3e1fe1ab35298f993f56f70560a9b88d35d7 /numpy | |
parent | 1ee71d93fd069a51f45b4fa91e9e91d083a9334e (diff) | |
download | numpy-eca8f94e294003336d901b7e718375fad0c2619c.tar.gz |
BUG: DOC: fix invalid vdot documentation
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/add_newdocs.py | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index cf57c031b..3557c00a3 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -1295,12 +1295,9 @@ add_newdoc('numpy.core', 'vdot', dot(`a`, `b`). If the first argument is complex the complex conjugate of the first argument is used for the calculation of the dot product. - For 2-D arrays it is equivalent to matrix multiplication, and for 1-D - arrays to inner product of vectors (with complex conjugation of `a`). - 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]) + Note that `vdot` handles multidimensional arrays differently than `dot`: + it does *not* perform a matrix product, but flattens input arguments + to 1-D vectors first. Consequently, it should only be used for vectors. Parameters ---------- @@ -1313,7 +1310,7 @@ add_newdoc('numpy.core', 'vdot', Returns ------- output : ndarray - Returns dot product of `a` and `b`. Can be an int, float, or + Dot product of `a` and `b`. Can be an int, float, or complex depending on the types of `a` and `b`. See Also @@ -1321,13 +1318,6 @@ add_newdoc('numpy.core', 'vdot', dot : Return the dot product without using the complex conjugate of the first argument. - Notes - ----- - The dot product is the summation of element wise multiplication. - - .. math:: - a \\cdot b = \\sum_{i=1}^n a_i^*b_i = a_1^*b_1+a_2^*b_2+\\cdots+a_n^*b_n - Examples -------- >>> a = np.array([1+2j,3+4j]) @@ -1336,12 +1326,17 @@ add_newdoc('numpy.core', 'vdot', (70-8j) >>> np.vdot(b, a) (70+8j) + + Note that higher-dimensional arrays are flattened! + >>> a = np.array([[1, 4], [5, 6]]) >>> b = np.array([[4, 1], [2, 2]]) >>> np.vdot(a, b) 30 >>> np.vdot(b, a) 30 + >>> 1*4 + 4*1 + 5*2 + 6*2 + 30 """) |