fn
view_as_complex
→Tensorview_as_complex(input: Tensor)Reinterpret a real tensor with a trailing pair axis as a complex tensor.
Inverse of view_as_real. Given an F32 input of shape
, returns a complex64 tensor of shape
whose last axis is consumed.
Parameters
inputTensorReal F32 tensor whose final dimension has size 2; the two
components are interpreted as
(real, imag).Returns
Tensorcomplex64 tensor of shape input.shape[:-1].
Raises
ValueErrorIf
input.ndim < 1 or the last axis does not have size 2.Notes
Conceptually:
Same copy / aliasing caveat as view_as_real — implemented as
a materialised gather, not a zero-copy reinterpret.
Examples
>>> import lucid
>>> r = lucid.tensor([[1.0, 2.0], [3.0, 4.0]])
>>> lucid.view_as_complex(r)
Tensor([1.+2.j, 3.+4.j])