Created
September 8, 2017 17:47
-
-
Save bbbales2/52e3daff2a46d18e152aaac7b3ea913a to your computer and use it in GitHub Desktop.
Forward mode Jacobian
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(int i = 0; i < y.size(); i++) { | |
if(i > 0) | |
y_var[i - 1].d_ = 0.0; | |
y_var[i].d_ = 1.0; | |
vector<fvar<double> > dy_dt_var = f_(t, y_var, thetavar, x_, x_int_, msgs_); | |
if(i == 0) { | |
for(int j = 0; j < y.size(); j++) { | |
dy_dt(j) = dy_dt_var[j].val(); | |
} | |
} | |
for(int j = 0; j < y.size(); j++) | |
Jy(j, i) = dy_dt_var[j].tangent(); | |
} | |
y_var[y.size() - 1].d_ = 0.0; | |
for(int i = 0; i < theta_.size(); i++) { | |
if(i > 0) | |
thetavar[i - 1].d_ = 0.0; | |
thetavar[i].d_ = 1.0; | |
vector<fvar<double> > dy = f_(t, y_var, thetavar, x_, x_int_, msgs_); | |
for(int j = 0; j < dy.size(); j++) | |
Jtheta(j, i) = dy[j].tangent(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This goes in: stan/math/rev/mat/functor/ode_system.hpp in the:
function signature.