Fork me on GitHub

src/arraymancer/tensor/complex

  Source Edit

Procs

proc complex[T: SomeNumber](re: Tensor[T]): auto {.inline, noinit.}

Create a new, complex Tensor from a single real Tensor

The input Tensor is copied into the real part of the output Tensor, while the imaginary part is set to all zeros.

If the input is an integer Tensor, the output will be a Tensor of Complex64 to avoid any loss of precision. If you want to convert it into a Tensor of Complex32, you can use .asType(Complex32) instead.

Note that you can also convert a real tensor into a complex tensor by means of the asType procedure. However, this has the advantage that you can use the same function to combine a real and imaginary tensor or a single real tensor into a complex tensor. Another advantage is that this function will automatically use the right Complex type for the output tensor, leading to more generic code. Use asType only when you want to control the type of the Complex tensor.

  Source Edit
proc complex[T: SomeNumber](re: Tensor[T]; im: Tensor[T]): auto {.inline, noinit.}

Create a new, complex Tensor by combining two real Tensors

The first input Tensor is copied into the real part of the output Tensor, while the second input Tensor is copied into the imaginary part.

If the inputs are integer Tensors, the output will be a Tensor of Complex64 to avoid any loss of precision.

  Source Edit
proc complex_imag[T: SomeNumber](im: Tensor[T]): auto {.inline, noinit.}

Create a new, imaginary Tensor from a single real Tensor

The input Tensor is copied into the imaginary part of the output Tensor, while the real part is set to all zeros.

If the input is an integer Tensor, the output will be a Tensor of Complex64 to avoid any loss of precision. If you want to convert it into a Tensor of Complex32, you must convert the input to float32 first by using .asType(float32).

  Source Edit
proc conjugate[T: Complex32 | Complex64](t: Tensor[T]): Tensor[T]
Return the element-wise complex conjugate of a tensor of complex numbers. The complex conjugate of a complex number is obtained by changing the sign of its imaginary part.   Source Edit
proc cswap[T: Complex32 | Complex64](t: Tensor[T]): Tensor[T] {.inline, noinit.}
Swap the real and imaginary components of the elements of a complex Tensor   Source Edit
proc imag[T: SomeFloat](t: Tensor[Complex[T]]): Tensor[T] {.inline, noinit.}
Get the imaginary part of a complex Tensor (as a float Tensor)   Source Edit
proc imag=[T: SomeFloat](t: var Tensor[Complex[T]]; val: T) {.inline.}
Set the imaginary part of all the items of a complex Tensor to a certain floating point value   Source Edit
proc imag=[T: SomeFloat](t: var Tensor[Complex[T]]; val: Tensor[T]) {.inline.}
Copy a real Tensor into the imaginary part of an existing complex Tensor The source and target Tensor sizes must match, but the shapes might differ   Source Edit
proc real[T: SomeFloat](t: Tensor[Complex[T]]): Tensor[T] {.inline, noinit.}
Get the real part of a complex Tensor (as a float Tensor)   Source Edit
proc real=[T: SomeFloat](t: var Tensor[Complex[T]]; val: T) {.inline.}
Set the real part of all the items of a complex Tensor to a certain floating point value   Source Edit
proc real=[T: SomeFloat](t: var Tensor[Complex[T]]; val: Tensor[T]) {.inline.}
Copy a real Tensor into the real part of an existing complex Tensor The source and target Tensor sizes must match, but the shapes might differ   Source Edit
Arraymancer Technical reference Tutorial Spellbook (How-To's) Under the hood