fn
cross
→Tensorcross(x: Tensor, y: Tensor, dim: int = -1)Compute the cross product of two 3-D vectors.
Returns the standard 3-D vector cross product
Parameters
xTensorFirst operand. Must have size 3 along
dim.yTensorSecond operand. Same shape as
x.dimint= -1Axis along which the 3 components are stored. Default
-1.Returns
TensorCross product, same shape as inputs.
Notes
Implemented via gather + element-wise products so that
autograd flows through naturally. Recall that
is orthogonal to both and ,
with magnitude .
Examples
>>> import lucid
>>> from lucid.linalg import cross
>>> cross(lucid.tensor([1.0, 0.0, 0.0]), lucid.tensor([0.0, 1.0, 0.0]))
Tensor([0.0000, 0.0000, 1.0000])