You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for broadcasting to linalg.cross (#417)
* Make explicit that broadcasting only applies to non-compute dimensions in vecdot
* Add support for broadcasting to `linalg.cross`
* Update copy
* Update copy
* Fix spacing
Returns the cross product of 3-element vectors. If ``x1`` and ``x2`` are multi-dimensional arrays (i.e., both have a rank greater than ``1``), then the cross-product of each pair of corresponding 3-element vectors is independently computed.
44
+
Returns the cross product of 3-element vectors.
45
+
46
+
If ``x1`` and/or ``x2`` are multi-dimensional arrays (i.e., the broadcasted result has a rank greater than ``1``), then the cross-product of each pair of corresponding 3-element vectors is independently computed.
45
47
46
48
Parameters
47
49
----------
48
50
x1: array
49
51
first input array. Should have a real-valued data type.
50
52
x2: array
51
-
second input array. Must have the same shape as ``x1``. Should have a real-valued data type.
53
+
second input array. Must be compatible with ``x1`` for all non-compute axes (see :ref:`broadcasting`). The size of the axis over which to compute the cross product must be the same size as the respective axis in ``x1``. Should have a real-valued data type.
54
+
55
+
.. note::
56
+
The compute axis (dimension) must not be broadcasted.
57
+
52
58
axis: int
53
-
the axis (dimension) of ``x1`` and ``x2`` containing the vectors for which to compute the cross product. If set to ``-1``, the function computes the cross product for vectors defined by the last axis (dimension). Default: ``-1``.
59
+
the axis (dimension) of ``x1`` and ``x2`` containing the vectors for which to compute the cross product. Must be an integer on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of the shape determined according to :ref:`broadcasting`. If specified as a negative integer, the function must determine the axis along which to compute the cross product by counting backward from the last dimension (where ``-1`` refers to the last dimension). By default, the function must compute the cross product over the last axis. Default: ``-1``.
54
60
55
61
Returns
56
62
-------
57
63
out: array
58
64
an array containing the cross products. The returned array must have a data type determined by :ref:`type-promotion`.
65
+
66
+
67
+
**Raises**
68
+
69
+
- if provided an invalid ``axis``.
70
+
- if the size of the axis over which to compute the cross product is not equal to ``3``.
71
+
- if the size of the axis over which to compute the cross product is not the same (before broadcasting) for both ``x1`` and ``x2``.
first input array. Should have a real-valued data type.
94
94
x2: array
95
-
second input array. Should have a real-valued data type. Corresponding contracted axes of ``x1`` and ``x2`` must be equal.
95
+
second input array. Must be compatible with ``x1`` for all non-contracted axes (see :ref:`broadcasting`). The size of the axis over which to compute the dot product must be the same size as the respective axis in ``x1``. Should have a real-valued data type.
96
96
97
97
.. note::
98
-
Contracted axes (dimensions) must not be broadcasted.
98
+
The contracted axis (dimension) must not be broadcasted.
99
99
100
-
axis:int
100
+
axis:int
101
101
axis over which to compute the dot product. Must be an integer on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of the shape determined according to :ref:`broadcasting`. If specified as a negative integer, the function must determine the axis along which to compute the dot product by counting backward from the last dimension (where ``-1`` refers to the last dimension). By default, the function must compute the dot product over the last axis. Default: ``-1``.
0 commit comments