1 #ifndef CPPAD_CG_TIME_DIFF_INCLUDED
2 #define CPPAD_CG_TIME_DIFF_INCLUDED
25 bool time_diff_forward(
size_t id,
33 CPPADCG_ASSERT_UNKNOWN(n == 3);
34 CPPADCG_ASSERT_UNKNOWN(m == 1);
35 CPPADCG_ASSERT_UNKNOWN(tx.size() >= (order + 1) * n);
36 CPPADCG_ASSERT_UNKNOWN(tzy.size() >= (order + 1) * m);
38 size_t n_order = order + 1;
39 const size_t xIndex = 0;
40 const size_t dxdtIndex = 1;
41 const size_t timeIndex = 2;
45 CPPADCG_ASSERT_UNKNOWN(vx.size() >= n);
46 CPPADCG_ASSERT_UNKNOWN(vzy.size() >= m);
48 vzy[0] = vx[0] || vx[1] || vx[2];
53 }
else if (order == 1) {
54 const CG<Base>& ttime = tx[timeIndex * n_order + order];
55 const CG<Base>& txx = tx[xIndex * n_order + order];
56 CPPADCG_ASSERT_UNKNOWN(ttime.isParameter());
57 CPPADCG_ASSERT_UNKNOWN(txx.isParameter());
58 if (ttime.getValue() > 0) {
59 CPPADCG_ASSERT_UNKNOWN(txx.getValue() == 0);
60 tzy[1] = ttime * tx[dxdtIndex * n_order + 0];
76 bool time_diff_reverse(
size_t id,
85 CPPADCG_ASSERT_UNKNOWN(n == 3);
86 CPPADCG_ASSERT_UNKNOWN(m == 1);
87 CPPADCG_ASSERT_UNKNOWN(tx.size() >= (order + 1) * n);
88 CPPADCG_ASSERT_UNKNOWN(tzy.size() >= (order + 1) * m);
89 CPPADCG_ASSERT_UNKNOWN(px.size() >= (order + 1) * n);
91 CG<Base>* pxx = &px[0];
92 CG<Base>* pdxdt = &px[order + 1];
93 CG<Base>* pt = &px[2 * (order + 1)];
96 const CG<Base>* tdxdt = &tx[order + 1];
100 pxx[0] = pzy[0] * 1.0;
102 pt[0] = pzy[0] * tdxdt[0];
112 bool time_diff_for_jac_sparse(
size_t id,
118 CPPADCG_ASSERT_UNKNOWN(n == 3);
119 CPPADCG_ASSERT_UNKNOWN(m == 1);
120 CPPADCG_ASSERT_UNKNOWN(r.size() >= n);
121 CPPADCG_ASSERT_UNKNOWN(s.size() >= m);
125 s[0].insert(r[1].begin(), r[1].end());
126 s[0].insert(r[2].begin(), r[2].end());
134 bool time_diff_rev_jac_sparse(
size_t id,
140 CPPADCG_ASSERT_UNKNOWN(n == 3);
141 CPPADCG_ASSERT_UNKNOWN(m == 1);
142 CPPADCG_ASSERT_UNKNOWN(r.size() >= n);
143 CPPADCG_ASSERT_UNKNOWN(s.size() >= m);
154 bool time_diff_rev_hes_sparse(
size_t id,
168 CPPAD_USER_ATOMIC(time_var,
171 CppAD::cg::time_diff_forward<Base>,
172 CppAD::cg::time_diff_reverse<Base>,
173 CppAD::cg::time_diff_for_jac_sparse<Base>,
174 CppAD::cg::time_diff_rev_jac_sparse<Base>,
175 CppAD::cg::time_diff_rev_hes_sparse<Base>)