16 #include <autodiff/forward/dual.hpp>
17 #include <autodiff/forward/dual/eigen.hpp>
22 template <
template <
typename>
typename basic_extension_t>
32 Eigen::Matrix<AutodiffScalar, eFreeSize, eFreeSize>;
43 template <
typename propagator_state_t,
typename stepper_t,
45 int bid(
const propagator_state_t&
ps,
const stepper_t& st,
46 const navigator_t& na)
const {
51 template <
typename propagator_state_t,
typename stepper_t,
55 std::array<double, 4>& kQoP,
const int i = 0,
const double h = 0.,
56 const Vector3& kprev = Vector3::Zero()) {
62 template <
typename propagator_state_t,
typename stepper_t,
64 bool finalize(propagator_state_t& state,
const stepper_t& stepper,
65 const navigator_t& navigator,
const double h)
const {
70 template <
typename propagator_state_t,
typename stepper_t,
72 bool finalize(propagator_state_t& state,
const stepper_t& stepper,
73 const navigator_t& navigator,
const double h,
75 #if defined(__GNUC__) && __GNUC__ == 12 && !defined(__clang__)
76 #pragma GCC diagnostic push
77 #pragma GCC diagnostic ignored "-Wuse-after-free"
81 #if defined(__GNUC__) && __GNUC__ == 12 && !defined(__clang__)
82 #pragma GCC diagnostic pop
97 template <
class options_t,
class navigation_t>
125 template <
typename propagator_state_t,
typename stepper_t,
126 typename navigator_t>
128 const navigator_t& navigator,
const double h,
131 using ThisFakePropState =
132 FakePropState<decltype(state.options), decltype(state.navigation)>;
138 stepper.particleHypothesis(state.stepping);
142 initial_params.segment<3>(
eFreePos0) = stepper.position(state.stepping);
143 initial_params(
eFreeTime) = stepper.time(state.stepping);
144 initial_params.segment<3>(
eFreeDir0) = stepper.direction(state.stepping);
145 initial_params(
eFreeQOverP) = stepper.qOverP(state.stepping);
147 const auto& sd = state.stepping.stepData;
151 [&](
const auto&
in) {
152 return RKN4step(
in, sd, fstate, navigator, h);
154 wrt(initial_params),
at(initial_params))
155 .
template cast<double>();
160 template <
typename step_data_t,
typename fake_state_t,
typename navigator_t>
162 fake_state_t state,
const navigator_t& navigator,
163 const double h)
const {
168 state.stepping.pars =
in;
170 std::array<AutodiffScalar, 4> kQoP;
171 std::array<AutodiffVector3, 4>
k;
174 basic_extension_t<AutodiffScalar> ext;
178 ext.k(state, stepper, navigator, k[0], sd.B_first, kQoP);
179 ext.k(state, stepper, navigator, k[1], sd.B_middle, kQoP, 1, h * 0.5, k[0]);
180 ext.k(state, stepper, navigator, k[2], sd.B_middle, kQoP, 2, h * 0.5, k[1]);
181 ext.k(state, stepper, navigator, k[3], sd.B_last, kQoP, 3, h, k[2]);
184 ext.finalize(state, stepper, navigator, h);
192 h * h / 6. * (k[0] + k[1] + k[2]);
196 in.segment<3>(
eFreeDir0) + h / 6. * (k[0] + 2. * (k[1] + k[2]) + k[3]);
198 out.segment<3>(
eFreeDir0) = final_dir / final_dir.norm();