torchdyn
torchdyn copied to clipboard
Does the odeint method support complex tensors?
Is it safe to use the ODE solvers with a complex tensor?
For example
def f(t, x):
print(t)
return 3 * x
x0 = torch.from_numpy(np.array([1 + 1j, 2 + 2j, 3 + 3j]))
print(x0.dtype)
t_span = torch.linspace(0, 1, 3)
t, x = odeint(f, x0, t_span, 'rk4')
returns
torch.complex128
tensor(0.)
tensor(0.+0.j, dtype=torch.complex128)
tensor(0.2500+0.j, dtype=torch.complex128)
tensor(0.2500+0.j, dtype=torch.complex128)
tensor(0.5000)
tensor(0.5000+0.j, dtype=torch.complex128)
tensor(0.7500+0.j, dtype=torch.complex128)
tensor(0.7500+0.j, dtype=torch.complex128)
I'm not sure why the time gets converted to a complex value and thus wonder about the complex support of the various solvers.