I want to do some quantum mechanics calculations with PyTorch, where the quantities are sometimes complex. I would like to know how can I cast an existing real tensor to complex
type.
PyTorch does have complex number support.
Try this:
import torch
a = torch.tensor([1.0, 2.0], dtype=torch.double)
b = a.type(torch.complex64)