Skip to Content

imag_op

View the code on GitHub

Structs

Struct: Imag

Fields

Methods

compute_shape(mut curr: ArrayShape, args: List[ArrayShape])
Computes the shape of the imaginary part of a complex array.
Args
  • curr: ArrayShape The ArrayShape to store the result of the computation.

  • args: List[ArrayShape] The ArrayShape to compute the imaginary part of.

jvp(primals: List[Array], tangents: List[Array]) -> Array
more details
Args
  • primals: List[Array]

  • tangents: List[Array]

Returns
  • Array
vjp(primals: List[Array], grad: Array, out: Array) -> List[Array]
more details
Args
  • primals: List[Array]

  • grad: Array

  • out: Array

Returns
  • List[Array]
__call__(mut curr: Array, args: List[Array])
Performs the forward pass for the imag operation. It sets the base of the argument to be the base of the current array and computes the shape of the current array via its dedicated ArraySahpe fwd fucntion.
Args
  • curr: Array The current array to store the result (modified in-place).

  • args: List[Array] The array on which the imag view is created.

Note: The information of the shape computation is stored in the ArrayShape object of the curr array.

fwd(arg0: Array) -> Array
Creates a view of the input array as an imaginary array.
Args
  • arg0: Array The input array.
Returns
  • Array - A view of the input array as an imaginary array.

Note: This function is non-differentiable.

Functions

imag

imag(arg0: Array) -> Array
Computes the imaginary part of the input array.
Args
  • arg0: Array The input array.
Returns
  • Array - An array containing the imaginary part of the input array.

Examples:

a = Array([[1, 2], [3, 4]]) result = imag(a) print(result)

Note: This function supports:

  • Complex input arrays.
  • Non-differentiable operation.
Last updated on