@@ -44,7 +44,7 @@ def add_newdoc(place, name, doc):
44
44
45
45
skip = (
46
46
# gufuncs do not use the OUT_SCALAR replacement strings
47
- 'matmul' , 'vecdot' ,
47
+ 'matmul' , 'vecdot' , 'matvec' , 'vecmat' ,
48
48
# clip has 3 inputs, which is not handled by this
49
49
'clip' ,
50
50
)
@@ -2793,7 +2793,9 @@ def add_newdoc(place, name, doc):
2793
2793
2794
2794
See Also
2795
2795
--------
2796
- vdot : Complex-conjugating dot product.
2796
+ vecdot : Complex-conjugating dot product for stacks of vectors.
2797
+ matvec : Matrix-vector product for stacks of matrices and vectors.
2798
+ vecmat : Vector-matrix product for stacks of vectors and matrices.
2797
2799
tensordot : Sum products over arbitrary axes.
2798
2800
einsum : Einstein summation convention.
2799
2801
dot : alternative matrix product with different broadcasting rules.
@@ -2808,10 +2810,10 @@ def add_newdoc(place, name, doc):
2808
2810
matrices residing in the last two indexes and broadcast accordingly.
2809
2811
- If the first argument is 1-D, it is promoted to a matrix by
2810
2812
prepending a 1 to its dimensions. After matrix multiplication
2811
- the prepended 1 is removed.
2813
+ the prepended 1 is removed. (For stacks of vectors, use ``vecmat``.)
2812
2814
- If the second argument is 1-D, it is promoted to a matrix by
2813
2815
appending a 1 to its dimensions. After matrix multiplication
2814
- the appended 1 is removed.
2816
+ the appended 1 is removed. (For stacks of vectors, use ``matvec``.)
2815
2817
2816
2818
``matmul`` differs from ``dot`` in two important ways:
2817
2819
@@ -2910,8 +2912,8 @@ def add_newdoc(place, name, doc):
2910
2912
Input arrays, scalars not allowed.
2911
2913
out : ndarray, optional
2912
2914
A location into which the result is stored. If provided, it must have
2913
- a shape that the broadcasted shape of `x1` and `x2` with the last axis
2914
- removed. If not provided or None, a freshly-allocated array is used.
2915
+ the broadcasted shape of `x1` and `x2` with the last axis removed.
2916
+ If not provided or None, a freshly-allocated array is used.
2915
2917
**kwargs
2916
2918
For other keyword-only arguments, see the
2917
2919
:ref:`ufunc docs <ufuncs.kwargs>`.
@@ -2933,6 +2935,9 @@ def add_newdoc(place, name, doc):
2933
2935
See Also
2934
2936
--------
2935
2937
vdot : same but flattens arguments first
2938
+ matmul : Matrix-matrix product.
2939
+ vecmat : Vector-matrix product.
2940
+ matvec : Matrix-vector product.
2936
2941
einsum : Einstein summation convention.
2937
2942
2938
2943
Examples
@@ -2949,6 +2954,135 @@ def add_newdoc(place, name, doc):
2949
2954
.. versionadded:: 2.0.0
2950
2955
""" )
2951
2956
2957
+ add_newdoc ('numpy._core.umath' , 'matvec' ,
2958
+ """
2959
+ Matrix-vector dot product of two arrays.
2960
+
2961
+ Given a matrix (or stack of matrices) :math:`\\ mathbf{A}` in ``x1`` and
2962
+ a vector (or stack of vectors) :math:`\\ mathbf{v}` in ``x2``, the
2963
+ matrix-vector product is defined as:
2964
+
2965
+ .. math::
2966
+ \\ mathbf{A} \\ cdot \\ mathbf{b} = \\ sum_{j=0}^{n-1} A_{ij} v_j
2967
+
2968
+ where the sum is over the last dimensions in ``x1`` and ``x2``
2969
+ (unless ``axes`` is specified). (For a matrix-vector product with the
2970
+ vector conjugated, use ``np.vecmat(x2, x1.mT)``.)
2971
+
2972
+ Parameters
2973
+ ----------
2974
+ x1, x2 : array_like
2975
+ Input arrays, scalars not allowed.
2976
+ out : ndarray, optional
2977
+ A location into which the result is stored. If provided, it must have
2978
+ the broadcasted shape of ``x1`` and ``x2`` with the summation axis
2979
+ removed. If not provided or None, a freshly-allocated array is used.
2980
+ **kwargs
2981
+ For other keyword-only arguments, see the
2982
+ :ref:`ufunc docs <ufuncs.kwargs>`.
2983
+
2984
+ Returns
2985
+ -------
2986
+ y : ndarray
2987
+ The matrix-vector product of the inputs.
2988
+
2989
+ Raises
2990
+ ------
2991
+ ValueError
2992
+ If the last dimensions of ``x1`` and ``x2`` are not the same size.
2993
+
2994
+ If a scalar value is passed in.
2995
+
2996
+ See Also
2997
+ --------
2998
+ vecdot : Vector-vector product.
2999
+ vecmat : Vector-matrix product.
3000
+ matmul : Matrix-matrix product.
3001
+ einsum : Einstein summation convention.
3002
+
3003
+ Examples
3004
+ --------
3005
+ Rotate a set of vectors from Y to X along Z.
3006
+
3007
+ >>> a = np.array([[0., 1., 0.],
3008
+ ... [-1., 0., 0.],
3009
+ ... [0., 0., 1.]])
3010
+ >>> v = np.array([[1., 0., 0.],
3011
+ ... [0., 1., 0.],
3012
+ ... [0., 0., 1.],
3013
+ ... [0., 6., 8.]])
3014
+ <
10000
span class=pl-s> >>> np.matvec(a, v)
3015
+ array([[ 0., -1., 0.],
3016
+ [ 1., 0., 0.],
3017
+ [ 0., 0., 1.],
3018
+ [ 6., 0., 8.]])
3019
+
3020
+ .. versionadded:: 2.1.0
3021
+ """ )
3022
+
3023
+ add_newdoc ('numpy._core.umath' , 'vecmat' ,
3024
+ """
3025
+ Vector-matrix dot product of two arrays.
3026
+
3027
+ Given a vector (or stack of vector) :math:`\\ mathbf{v}` in ``x1`` and
3028
+ a matrix (or stack of matrices) :math:`\\ mathbf{A}` in ``x2``, the
3029
+ vector-matrix product is defined as:
3030
+
3031
+ .. math::
3032
+ \\ mathbf{b} \\ cdot \\ mathbf{A} = \\ sum_{i=0}^{n-1} \\ overline{v_i}A_{ij}
3033
+
3034
+ where the sum is over the last dimension of ``x1`` and the one-but-last
3035
+ dimensions in ``x2`` (unless `axes` is specified) and where
3036
+ :math:`\\ overline{v_i}` denotes the complex conjugate if :math:`v`
3037
+ is complex and the identity otherwise. (For a non-conjugated vector-matrix
3038
+ product, use ``np.matvec(x2.mT, x1)``.)
3039
+
3040
+ Parameters
3041
+ ----------
3042
+ x1, x2 : array_like
3043
+ Input arrays, scalars not allowed.
3044
+ out : ndarray, optional
3045
+ A location into which the result is stored. If provided, it must have
3046
+ the broadcasted shape of ``x1`` and ``x2`` with the summation axis
3047
+ removed. If not provided or None, a freshly-allocated array is used.
3048
+ **kwargs
3049
+ For other keyword-only arguments, see the
3050
+ :ref:`ufunc docs <ufuncs.kwargs>`.
3051
+
3052
+ Returns
3053
+ -------
3054
+ y : ndarray
3055
+ The vector-matrix product of the inputs.
3056
+
3057
+ Raises
3058
+ ------
3059
+ ValueError
3060
+ If the last dimensions of ``x1`` and the one-but-last dimension of
3061
+ ``x2`` are not the same size.
3062
+
3063
+ If a scalar value is passed in.
3064
+
3065
+ See Also
3066
+ --------
3067
+ vecdot : Vector-vector product.
3068
+ matvec : Matrix-vector product.
3069
+ matmul : Matrix-matrix product.
3070
+ einsum : Einstein summation convention.
3071
+
3072
+ Examples
3073
+ --------
3074
+ Project a vector along X and Y.
3075
+
3076
+ >>> v = np.array([0., 4., 2.])
3077
+ >>> a = np.array([[1., 0., 0.],
3078
+ ... [0., 1., 0.],
3079
+ ... [0., 0., 0.]])
3080
+ >>> np.vecmat(v, a)
3081
+ array([ 0., 4., 0.])
3082
+
3083
+ .. versionadded:: 2.1.0
3084
+ """ )
3085
+
2952
3086
add_newdoc ('numpy._core.umath' , 'modf' ,
2953
3087
"""
2954
3088
Return the fractional and integral parts of an array, element-wise.
0 commit comments