fn
view_as_real
→Tensorview_as_real(input: Tensor)Reinterpret a complex tensor as a real tensor with a trailing pair axis.
Given an input of shape and dtype complex64,
returns an F32 tensor of shape where the trailing
axis carries [real, imag] pairs.
Parameters
inputTensorComplex-valued tensor (dtype
complex64).Returns
TensorReal F32 tensor of shape input.shape + (2,).
Notes
Conceptually this is the map
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.]])