bundles / numpy 2.4.4 / numpy / linalg / cross
_ArrayFunctionDispatcher
numpy.linalg:cross
source: /numpy/linalg/_linalg.py :3246
Signature
def cross ( x1 , x2 , / , axis = -1 ) Summary
Returns the cross product of 3-element vectors.
Extended Summary
If x1 and/or x2 are multi-dimensional arrays, then the cross-product of each pair of corresponding 3-element vectors is independently computed.
This function is Array API compatible, contrary to numpy.cross.
Parameters
x1: array_likeThe first input array.
x2: array_likeThe second input array. Must be compatible with
x1for all non-compute axes. The size of the axis over which to compute the cross-product must be the same size as the respective axis inx1.axis: int, optionalThe axis (dimension) of
x1andx2containing the vectors for which to compute the cross-product. Default:-1.
Returns
out: ndarrayAn array containing the cross products.
Examples
Vector cross-product.x = np.array([1, 2, 3]) y = np.array([4, 5, 6]) np.linalg.cross(x, y)✓
x = np.array([[1,2,3], [4,5,6]]) y = np.array([[4,5,6], [1,2,3]]) np.linalg.cross(x, y)✓
x = np.array([[1, 2], [3, 4], [5, 6]]) y = np.array([[4, 5], [6, 1], [2, 3]])✓
np.linalg.cross(x, y, axis=0)
✗See also
Aliases
-
numpy.linalg.cross