Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does the odeint method support complex tensors? #177

Open
pierreguilmin opened this issue Jan 30, 2023 · 0 comments
Open

Does the odeint method support complex tensors? #177

pierreguilmin opened this issue Jan 30, 2023 · 0 comments
Labels
question Further information is requested

Comments

@pierreguilmin
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant