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. Note that
(a, b)
| 833 | |
| 834 | @array_function_from_c_func_and_dispatcher(_multiarray_umath.vdot) |
| 835 | def vdot(a, b): |
| 836 | """ |
| 837 | vdot(a, b, /) |
| 838 | |
| 839 | Return the dot product of two vectors. |
| 840 | |
| 841 | The vdot(`a`, `b`) function handles complex numbers differently than |
| 842 | dot(`a`, `b`). If the first argument is complex the complex conjugate |
| 843 | of the first argument is used for the calculation of the dot product. |
| 844 | |
| 845 | Note that `vdot` handles multidimensional arrays differently than `dot`: |
| 846 | it does *not* perform a matrix product, but flattens input arguments |
| 847 | to 1-D vectors first. Consequently, it should only be used for vectors. |
| 848 | |
| 849 | Parameters |
| 850 | ---------- |
| 851 | a : array_like |
| 852 | If `a` is complex the complex conjugate is taken before calculation |
| 853 | of the dot product. |
| 854 | b : array_like |
| 855 | Second argument to the dot product. |
| 856 | |
| 857 | Returns |
| 858 | ------- |
| 859 | output : ndarray |
| 860 | Dot product of `a` and `b`. Can be an int, float, or |
| 861 | complex depending on the types of `a` and `b`. |
| 862 | |
| 863 | See Also |
| 864 | -------- |
| 865 | dot : Return the dot product without using the complex conjugate of the |
| 866 | first argument. |
| 867 | |
| 868 | Examples |
| 869 | -------- |
| 870 | >>> a = np.array([1+2j,3+4j]) |
| 871 | >>> b = np.array([5+6j,7+8j]) |
| 872 | >>> np.vdot(a, b) |
| 873 | (70-8j) |
| 874 | >>> np.vdot(b, a) |
| 875 | (70+8j) |
| 876 | |
| 877 | Note that higher-dimensional arrays are flattened! |
| 878 | |
| 879 | >>> a = np.array([[1, 4], [5, 6]]) |
| 880 | >>> b = np.array([[4, 1], [2, 2]]) |
| 881 | >>> np.vdot(a, b) |
| 882 | 30 |
| 883 | >>> np.vdot(b, a) |
| 884 | 30 |
| 885 | >>> 1*4 + 4*1 + 5*2 + 6*2 |
| 886 | 30 |
| 887 | |
| 888 | """ |
| 889 | return (a, b) |
| 890 | |
| 891 | |
| 892 | @array_function_from_c_func_and_dispatcher(_multiarray_umath.bincount) |