# complex

Ops working with complex types.

We don't have a formal complex type yet, so we represent complex numbers as having a final dimension of size 2, representing the real and complex parts respectively.

## as_complex​

as_complex(owned real: Symbol, owned imag: Symbol) -> Symbol

Creates a complex-valued tensor from two real-valued tensors.

Args:

• real (Symbol): A symbolic tensor representing the real part of the complex value.
• imag (Symbol): A symbolic tensor representing the imaginary part of the complex value. Must have the same shape and dtype as real.

Returns:

A new symbolic tensor representing the complex valued tensor comprised from real and imag. Each element is paired elementwise.

## as_interleaved_complex​

as_interleaved_complex(owned interleaved: Symbol) -> Symbol

Reshapes the input symbolic tensor as complex from alternating (real, imag).

Args:

• interleaved (Symbol): A symbolic tensor representing complex numbers as alternating pairs of (real, imag) real-valued numbers. Its last dimension must have an even size.

Returns:

A symbolic tensor representing the complex-valued tensor, but with the values pulled out as complex numbers. The result will have the same dimensions for all dimensions except the last, which will be halved, and then a final dimension of size 2 representing the complex value.

## as_real​

as_real(owned complex: Symbol) -> SymbolTuple

Splits out the real and imaginary components of a symbolic tensor.

Args:

• complex (Symbol): The input complex-valued symbolic tensor.

Returns:

A pair of real-valued symbolic tensors, each with the same shape and rank as the input tensor, except the last dim of size 2 is removed. The first represents the real part of the input tensor, and the the second represents the imaginary part.

## mul_complex​

mul_complex(owned lhs: Symbol, owned rhs: Symbol) -> Symbol

Multiplies two complex-valued symbolic tensors elementwise.

Args:

• lhs (Symbol): A complex-valued symbolic tensor.
• rhs (Symbol): A complex-valued symbolic tensor.

Returns:

A new complex-valued symbolic tensor. Each element represents the elementwize complex multiplication of the element at that location in the two input tensors. Type promotion and broadcasting rules are applied as described in elementwise.