thk686 / odeintr

An R package for integrating differential equations in C++
18 stars 3 forks source link

add forcing #7

Closed jywang2016 closed 6 years ago

jywang2016 commented 6 years ago

Hi Thanks for your great work! It really speeds up the computation. However, there is a question about how to add a variable passed from R vector in the system. For example,

dxdt[0] = sigma*(x[1] - x[0]) + u

the u is a variable which changes over the time. Is it possible to deal with this system in odeintr?

Thanks JY Wang

thk686 commented 6 years ago

When you write your derivatives in C++ or R, the variable 't' will be assigned the current time, so you can use that for any time-dependent function you need.

THK

On Fri, Jul 20, 2018 at 1:06 AM Jiangyu Wang notifications@github.com wrote:

Hi I'm sorry. I just find how to use a dynamic parameters at the github Readme page. It offers a convenient way to introduce a dynamic variable. But , is there other way to avoid for loop in R while using dynamic parameters. For example, pass a linear interpolation function u[t] from R to C?

Thanks JY Wang

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/thk686/odeintr/issues/7#issuecomment-406498328, or mute the thread https://github.com/notifications/unsubscribe-auth/AAkLyYX_8oPWHejYVXoAEg7WNiXIp2Owks5uIXNdgaJpZM4VXVeb .

-- http://www.keittlab.org/

jywang2016 commented 6 years ago

Thanks! It works for me.