fn

view_as_real

Tensor
view_as_real(input: Tensor)
source

Reinterpret a complex tensor as a real tensor with a trailing pair axis.

Given an input of shape ()(\dots) and dtype complex64, returns an F32 tensor of shape (,2)(\dots, 2) where the trailing axis carries [real, imag] pairs.

Parameters

inputTensor
Complex-valued tensor (dtype complex64).

Returns

Tensor

Real F32 tensor of shape input.shape + (2,).

Notes

Conceptually this is the map

zi=ai+ibi    (ai,bi).z_i = a_i + i\,b_i \;\mapsto\; (a_i, b_i).

Currently implemented as a copy via lucid.stack, not a zero-copy storage reinterpret. Apple Silicon's GPU memory model makes a genuine zero-copy alias tricky, and Lucid's view contract intentionally enforces value semantics. Use freely for shape round-trips; do not rely on aliasing for in-place writes.

Examples

>>> import lucid
>>> z = lucid.tensor([1+2j, 3+4j])
>>> lucid.view_as_real(z)
Tensor([[1., 2.],
        [3., 4.]])