summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2009-03-21 21:58:16 +0000
committerPauli Virtanen <pav@iki.fi>2009-03-21 21:58:16 +0000
commit6d7e43e5fccae9914eaefee26781a6c4669afebf (patch)
treeaa1aa35ad5f3d2d60c026b4112f9d92a381fe205 /numpy/core/numeric.py
parentbab64b897064cfdf8cf86fcc62b44e21df1153ee (diff)
downloadnumpy-6d7e43e5fccae9914eaefee26781a6c4669afebf.tar.gz
Ensure that documentation for dot, vdot, inner, alterdot, restoredot is the same, independent of whether these functions come from _dotblas or multiarray/numeric.py
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r--numpy/core/numeric.py101
1 files changed, 5 insertions, 96 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index ff2eb6ca9..57f36cfad 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -608,9 +608,6 @@ def convolve(a,v,mode='full'):
mode = _mode_from_name(mode)
return multiarray.correlate(a, v[::-1], mode)
-inner = multiarray.inner
-dot = multiarray.dot
-
def outer(a,b):
"""
Returns the outer product of two vectors.
@@ -654,110 +651,22 @@ def outer(a,b):
b = asarray(b)
return a.ravel()[:,newaxis]*b.ravel()[newaxis,:]
-def vdot(a, b):
- """
- Return the dot product of two vectors.
-
- The vdot(`a`, `b`) function handles complex numbers differently than
- 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])
-
- Parameters
- ----------
- a : array_like
- If `a` is complex the complex conjugate is taken before calculation
- of the dot product.
- b : array_like
- Second argument to the dot product.
-
- Returns
- -------
- output : ndarray
- Returns dot product of `a` and `b`. Can be an int, float, or
- complex depending on the types of `a` and `b`.
-
- See Also
- --------
- 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])
- >>> b = np.array([5+6j,7+8j])
- >>> np.vdot(a, b)
- (70-8j)
- >>> np.vdot(b, a)
- (70+8j)
- >>> a = np.array([[1, 4], [5, 6]])
- >>> b = np.array([[4, 1], [2, 2]])
- >>> np.vdot(a, b)
- 30
- >>> np.vdot(b, a)
- 30
-
- """
- return dot(asarray(a).ravel().conj(), asarray(b).ravel())
-
# try to import blas optimized dot if available
try:
# importing this changes the dot function for basic 4 types
# to blas-optimized versions.
from _dotblas import dot, vdot, inner, alterdot, restoredot
except ImportError:
+ # docstrings are in add_newdocs.py
+ inner = multiarray.inner
+ dot = multiarray.dot
+ def vdot(a, b):
+ return dot(asarray(a).ravel().conj(), asarray(b).ravel())
def alterdot():
- """
- Change `dot`, `vdot`, and `innerproduct` to use accelerated BLAS functions.
-
- Typically, as a user of Numpy, you do not explicitly call this function. If
- Numpy is built with an accelerated BLAS, this function is automatically
- called when Numpy is imported.
-
- When Numpy is built with an accelerated BLAS like ATLAS, these functions
- are replaced to make use of the faster implementations. The faster
- implementations only affect float32, float64, complex64, and complex128
- arrays. Furthermore, the BLAS API only includes matrix-matrix,
- matrix-vector, and vector-vector products. Products of arrays with larger
- dimensionalities use the built in functions and are not accelerated.
-
- See Also
- --------
- restoredot : `restoredot` undoes the effects of `alterdot`.
-
- """
pass
def restoredot():
- """
- Restore `dot`, `vdot`, and `innerproduct` to the default non-BLAS
- implementations.
-
- Typically, the user will only need to call this when troubleshooting and
- installation problem, reproducing the conditions of a build without an
- accelerated BLAS, or when being very careful about benchmarking linear
- algebra operations.
-
- See Also
- --------
- alterdot : `restoredot` undoes the effects of `alterdot`.
-
- """
pass
-
def tensordot(a, b, axes=2):
"""
Returns the tensor dot product for (ndim >= 1) arrays along an axes.