MCPcopy Create free account
hub / github.com/numpy/numpy / cross

Function cross

numpy/array_api/linalg.py:64–80  ·  view source on GitHub ↗

Array API compatible wrapper for :py:func:`np.cross `. See its docstring for more information.

(x1: Array, x2: Array, /, *, axis: int = -1)

Source from the content-addressed store, hash-verified

62
63# Note: cross is the numpy top-level namespace, not np.linalg
64def cross(x1: Array, x2: Array, /, *, axis: int = -1) -> Array:
65 """
66 Array API compatible wrapper for :py:func:`np.cross <numpy.cross>`.
67
68 See its docstring for more information.
69 """
70 if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes:
71 raise TypeError('Only numeric dtypes are allowed in cross')
72 # Note: this is different from np.cross(), which broadcasts
73 if x1.shape != x2.shape:
74 raise ValueError('x1 and x2 must have the same shape')
75 if x1.ndim == 0:
76 raise ValueError('cross() requires arrays of dimension at least 1')
77 # Note: this is different from np.cross(), which allows dimension 2
78 if x1.shape[axis] != 3:
79 raise ValueError('cross() dimension must equal 3')
80 return Array._new(np.cross(x1._array, x2._array, axis=axis))
81
82def det(x: Array, /) -> Array:
83 """

Callers

nothing calls this directly

Calls 1

_newMethod · 0.80

Tested by

no test coverage detected