How can I cast a tensor to the complex type in Pytorch?
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 the 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)

