Skip to Content
DocumentationFunctionalBinary Opsdiv_op

div_op

View the code on GitHub

Structs

Struct: Div

Fields

Methods

fwd(arg0: Array, arg1: Array) -> Array
Divides two arrays element-wise.
Args
  • arg0: Array The first input array.

  • arg1: Array The second input array.

Returns
  • Array - The element-wise division of arg0 and arg1.

Examples:

a = Array([[1, 2], [3, 4]]) b = Array([[5, 6], [7, 8]]) result = div(a, b) print(result)

This function supports

  • Broadcasting.
  • Automatic differentiation (forward and reverse modes).
  • Complex valued arguments.
jvp(primals: List[Array], tangents: List[Array]) -> Array
Compute Jacobian-vector product for array division.
Args
  • primals: List[Array] Primal input arrays.

  • tangents: List[Array] Tangent vectors.

Returns
  • Array - Array: Jacobian-vector product.

Note: Implements forward-mode automatic differentiation for division. The result represents how the output changes with respect to infinitesimal changes in the inputs along the directions specified by the tangents.

See Also:

div_vjp: Reverse-mode autodiff for division.

vjp(primals: List[Array], grad: Array, out: Array) -> List[Array]
Compute vector-Jacobian product for array division.
Args
  • primals: List[Array] Primal input arrays.

  • grad: Array Gradient of the output with respect to some scalar function.

  • out: Array The output of the forward pass.

Returns
  • List[Array] - List[Array]: Gradients with respect to each input.

Note: Implements reverse-mode automatic differentiation for division. Returns arrays with shape zero for inputs that do not require gradients.

See Also:

div_jvp: Forward-mode autodiff for division.

binary_simd_op(arg0_real: SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)], arg1_real: SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)], arg0_imag: SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)], arg1_imag: SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)]) -> Tuple[SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)], SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)]]
Low-level function to divide two complex numbers represented as SIMD vectors.
Args
  • arg0_real: SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)] The real part of the first complex number.

  • arg1_real: SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)] The real part of the second complex number.

  • arg0_imag: SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)] The imaginary part of the first complex number.

  • arg1_imag: SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)] The imaginary part of the second complex number.

Returns
  • Tuple[SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)], SIMD[float32, nelts[::DType]().__mul__(2).__floordiv__(2)]] - The real and imaginary parts of the division of the two complex numbers as a tuple.
__call__(mut curr: Array, args: List[Array])
Divides two arrays element-wise and stores the result in the current array (curr). The function assumes that the shape and data of the args are already set up. If the shape and data of the current array (curr) is not set up, the function will compute the shape based on the shapes of the args and set up the data accordingly.
Args
  • curr: Array The current array, must be mutable.

  • args: List[Array] The two arrays to divide.

Functions

div

div(arg0: Array, arg1: Array) -> Array
Divides two arrays element-wise.
Args
  • arg0: Array The first input array.

  • arg1: Array The second input array.

Returns
  • Array - The element-wise division of the two input arrays.

Examples:

a = Array([[1, 2], [3, 4]]) b = Array([[5, 6], [7, 8]]) result = div([a, b]) print(result)

This function supports

  • Broadcasting.
  • Automatic differentiation (forward and reverse modes).
  • Complex valued arguments.
Last updated on