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

kwargs requirement for jit (coefficient) functions #29

Open
flowerthrower opened this issue Nov 21, 2023 · 0 comments
Open

kwargs requirement for jit (coefficient) functions #29

flowerthrower opened this issue Nov 21, 2023 · 0 comments

Comments

@flowerthrower
Copy link

flowerthrower commented Nov 21, 2023

Minor thing, but if its not too much work I think it would be cool if one could define multiple jax functions (w different parameters) without the need for **kwargs -- as already possible with (non-jit) regular python functions.
The following example does not work if we drop **kwargs.

def sin(t, p):
    return p[0] * jnp.sin(p[1] * t + p[2])

@jax.jit
def sin_x(t, p, **kwargs): return sin(t, p)

@jax.jit
def sin_y(t, q, **kwargs): return sin(t, q)

H = [[qt.sigmax(), sin_x],
     [qt.sigmay(), sin_y]]

evo = qt.mesolve(H, qt.basis(2, 0), tlist=[0, 1], 
                 args={'p': [ 1, 1, 0], 'q': [ 1, 1, 0]}, 
                 options={'method': 'diffrax'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant