fn
vecdot
→Tensorvecdot(x: Tensor, y: Tensor, dim: int = -1)Compute a batched vector dot product along an axis.
Reduces the chosen axis with a sum of element-wise products:
Parameters
xTensorFirst operand.
yTensorSecond operand, broadcast-compatible with
x.dimint= -1Axis to contract. Default
-1.Returns
TensorReduced tensor with dim removed.
Notes
Equivalent to (x * y).sum(dim=dim). Useful for computing many
independent dot products in one shot (e.g., per-row inner products
of two matrices).
Examples
>>> import lucid
>>> from lucid.linalg import vecdot
>>> x = lucid.tensor([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
>>> y = lucid.tensor([[1.0, 0.0, -1.0], [0.0, 1.0, 0.0]])
>>> vecdot(x, y)
Tensor([-2.0000, 5.0000])