MCPcopy Index your code
hub / github.com/numpy/numpy / dot

Function dot

numpy/_core/multiarray.py:752–843  ·  view source on GitHub ↗

dot(a, b, out=None) Dot product of two arrays. Specifically, - If both `a` and `b` are 1-D arrays, it is inner product of vectors (without complex conjugation). - If both `a` and `b` are 2-D arrays, it is matrix multiplication, but using :func:`matmul` or ``a @ b`` is

(a, b, out=None)

Source from the content-addressed store, hash-verified

750
751@array_function_from_c_func_and_dispatcher(_multiarray_umath.dot)
752def dot(a, b, out=None):
753 """
754 dot(a, b, out=None)
755
756 Dot product of two arrays. Specifically,
757
758 - If both `a` and `b` are 1-D arrays, it is inner product of vectors
759 (without complex conjugation).
760
761 - If both `a` and `b` are 2-D arrays, it is matrix multiplication,
762 but using :func:`matmul` or ``a @ b`` is preferred.
763
764 - If either `a` or `b` is 0-D (scalar), it is equivalent to
765 :func:`multiply` and using ``numpy.multiply(a, b)`` or ``a * b`` is
766 preferred.
767
768 - If `a` is an N-D array and `b` is a 1-D array, it is a sum product over
769 the last axis of `a` and `b`.
770
771 - If `a` is an N-D array and `b` is an M-D array (where ``M>=2``), it is a
772 sum product over the last axis of `a` and the second-to-last axis of
773 `b`::
774
775 dot(a, b)[i,j,k,m] = sum(a[i,j,:] * b[k,:,m])
776
777 It uses an optimized BLAS library when possible (see `numpy.linalg`).
778
779 Parameters
780 ----------
781 a : array_like
782 First argument.
783 b : array_like
784 Second argument.
785 out : ndarray, optional
786 Output argument. This must have the exact kind that would be returned
787 if it was not used. In particular, it must have the right type, must be
788 C-contiguous, and its dtype must be the dtype that would be returned
789 for `dot(a,b)`. This is a performance feature. Therefore, if these
790 conditions are not met, an exception is raised, instead of attempting
791 to be flexible.
792
793 Returns
794 -------
795 output : ndarray
796 Returns the dot product of `a` and `b`. If `a` and `b` are both
797 scalars or both 1-D arrays then a scalar is returned; otherwise
798 an array is returned.
799 If `out` is given, then it is returned.
800
801 Raises
802 ------
803 ValueError
804 If the last dimension of `a` is not the same size as
805 the second-to-last dimension of `b`.
806
807 See Also
808 --------
809 vdot : Complex-conjugating dot product.

Callers 7

test_dot_2argsMethod · 0.90
test_dot_3argsMethod · 0.90
polyfitFunction · 0.90
multi_dotFunction · 0.90
_multi_dot_threeFunction · 0.90
_multi_dotFunction · 0.90
tensordotFunction · 0.70

Calls

no outgoing calls

Tested by 2

test_dot_2argsMethod · 0.72
test_dot_3argsMethod · 0.72