divide(input: Tensor, other: Tensor | Scalar, rounding_mode: str | None = ...)Element-wise division — lucid.div under its longer name.
rounding_mode=None is the / operator: integer operands are
promoted to a floating dtype. "trunc" rounds the quotient toward
zero and "floor" toward negative infinity, keeping an integer dtype.
Parameters
Returns
TensorElement-wise quotient of the broadcast shape of input and other.
Notes
Division by zero gives (NaN for 0/0). The gradients
are and , and zero for a rounded quotient.
Examples
>>> import lucid
>>> lucid.divide(lucid.tensor([6.0, 9.0]), 3.0)
tensor([2., 3.])
>>> lucid.divide(lucid.tensor([7, -7]), 2, rounding_mode="trunc")
tensor([3, -3], dtype=lucid.int64)