mlx.core.linalg.cross#

cross(a: array, b: array, axis: int = -1, *, stream: None | Stream | Device = None) array#

Compute the cross product of two arrays along a specified axis.

The cross product is defined for arrays with size 2 or 3 in the specified axis. If the size is 2 then the third value is assumed to be zero.

Parameters:
  • a (array) – Input array.

  • b (array) – Input array.

  • axis (int, optional) – Axis along which to compute the cross product. Default: -1.

  • stream (Stream, optional) – Stream or device. Defaults to None in which case the default stream of the default device is used.

Returns:

The cross product of a and b along the specified axis.

Return type:

array