4

You don't actually need co-routines for this -- you can achieve the same by just using regular callbacks into user code. For example, in the C programming language, the ODE solver routine would have an extra argument that denotes a pointer to a function. User code would call the integrator with a pointer-to-function for a user function that the ODE ...


3

There are integrators which expose a more fine-grained control to the user, e.g., scipy.integrate.ode: from scipy.integrate import ode def f(t,y): return y[0] initial = [1] ODE = ode(f) ODE.set_integrator("dopri5") ODE.set_initial_value(initial) for time in range(1,10): print(ODE.integrate(time)) Instead of coroutines, this provides the ...


2

Not quite a package but the example at the end of the Revised6 Report on the Algorithmic Language Scheme implements a classical Runge-Kutta integrator as a function that returns 'an infinite stream of states'. This is done in a few lines of code and is easy to port to for example Python using its coroutines, generators, itertools, &c. I think that ...


1

ArrayFire has a C++ API as well as a Python API. You can switch between several backends including CPU, CUDA, and OpenCL. It will also handle memory movement and kernel fusion for you. An example: /******************************************************* * Copyright (c) 2014, ArrayFire * All rights reserved. * * This file is distributed under 3-clause ...


1

One way to do this is to use Julia. Julia's CUDAnative.jl allows for automated recompilation of pretty general code to GPUs using the LLVM PTX backend. It just works on standard Julia code, so types, dispatches, etc. are all fine: most cases you shouldn't have to alter your code from the original to make it work. This has demonstrated to be performance ...


Only top voted, non community-wiki answers of a minimum length are eligible