@@ -29,44 +29,29 @@ struct parameter_transporter : actor {
29
29
using bound_matrix_t = bound_matrix<algebra_t >;
30
30
// Matrix type for bound to free jacobian
31
31
using bound_to_free_matrix_t = bound_to_free_matrix<algebra_t >;
32
+ // Matrix type for free to bound jacobian
33
+ using free_to_bound_matrix_t = free_to_bound_matrix<algebra_t >;
32
34
// / @}
33
35
34
- struct get_full_jacobian_kernel {
35
-
36
+ struct get_free_to_bound_jacobian_kernel {
36
37
template <typename mask_group_t , typename index_t ,
37
38
typename stepper_state_t >
38
- DETRAY_HOST_DEVICE inline bound_matrix_t operator ()(
39
+ DETRAY_HOST_DEVICE inline free_to_bound_matrix_t operator ()(
39
40
const mask_group_t & /* mask_group*/ , const index_t & /* index*/ ,
40
41
const transform3_type& trf3,
41
- const bound_to_free_matrix_t & bound_to_free_jacobian,
42
- const material<scalar_type>* vol_mat_ptr,
43
42
const stepper_state_t & stepping) const {
44
-
45
43
using frame_t = typename mask_group_t ::value_type::shape::
46
44
template local_frame_type<algebra_t >;
47
45
48
- using jacobian_engine_t = detail::jacobian_engine<frame_t >;
49
-
50
- using free_matrix_t = free_matrix<algebra_t >;
51
- using free_to_bound_matrix_t =
52
- typename jacobian_engine_t ::free_to_bound_matrix_type;
46
+ // Declare jacobian for bound to free coordinate transform
47
+ free_to_bound_matrix_t jac_to_local =
48
+ matrix::zero<free_to_bound_matrix_t >();
53
49
54
- // Free to bound jacobian at the destination surface
55
- const free_to_bound_matrix_t free_to_bound_jacobian =
56
- jacobian_engine_t::free_to_bound_jacobian ( trf3, stepping ());
50
+ detail::jacobian_engine< algebra_t >::
51
+ template free_to_bound_jacobian_step_1< frame_t >(
52
+ jac_to_local, trf3, stepping (). pos (), stepping (). dir ());
57
53
58
- // Path correction factor
59
- const free_matrix_t path_correction =
60
- jacobian_engine_t::path_correction (
61
- stepping ().pos (), stepping ().dir (), stepping.dtds (),
62
- stepping.dqopds (vol_mat_ptr), trf3);
63
-
64
- const free_matrix_t correction_term =
65
- matrix::identity<free_matrix_t >() + path_correction;
66
-
67
- return free_to_bound_jacobian *
68
- (correction_term *
69
- (stepping.transport_jacobian () * bound_to_free_jacobian));
54
+ return jac_to_local;
70
55
}
71
56
};
72
57
@@ -143,9 +128,30 @@ struct parameter_transporter : actor {
143
128
? vol.material_parameters (stepping ().pos ())
144
129
: nullptr ;
145
130
146
- return sf.template visit_mask <get_full_jacobian_kernel>(
147
- sf.transform (gctx), bound_to_free_jacobian, vol_mat_ptr,
148
- propagation._stepping );
131
+ auto free_to_bound_jacobian =
132
+ sf.template visit_mask <get_free_to_bound_jacobian_kernel>(
133
+ sf.transform (gctx), propagation._stepping );
134
+
135
+ detail::jacobian_engine<algebra_t >::free_to_bound_jacobian_step_2 (
136
+ free_to_bound_jacobian, stepping ().dir ());
137
+
138
+ const auto path_to_free_derivative =
139
+ detail::jacobian_engine<algebra_t >::path_to_free_derivative (
140
+ stepping ().dir (), stepping.dtds (),
141
+ stepping.dqopds (vol_mat_ptr));
142
+
143
+ const auto free_to_path_derivative = sf.free_to_path_derivative (
144
+ gctx, stepping ().pos (), stepping ().dir (), stepping.dtds ());
145
+
146
+ const auto path_correction =
147
+ path_to_free_derivative * free_to_path_derivative;
148
+
149
+ const auto correction_term =
150
+ matrix::identity<free_matrix<algebra_t >>() + path_correction;
151
+
152
+ return free_to_bound_jacobian *
153
+ (correction_term *
154
+ (stepping.transport_jacobian () * bound_to_free_jacobian));
149
155
}
150
156
151
157
}; // namespace detray
0 commit comments