Skip to content

Commit

Permalink
[filter] auto type parameter on predict and update for API simplicity
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoisCarouge committed Oct 6, 2024
1 parent 9f08e18 commit 222abe1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 21 deletions.
4 changes: 1 addition & 3 deletions include/fcarouge/internal/x_z_p_q_r_h_f.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ template <typename State, typename Output> struct x_z_p_q_r_h_f {
output z{zero_v<output>};
transpose t{};

template <typename Output0, typename... OutputN>
inline constexpr void update(const Output0 &output_z,
const OutputN &...outputs_z) {
inline constexpr void update(const auto &output_z, const auto &...outputs_z) {
z = output{output_z, outputs_z...};
s = innovation_uncertainty{h * p * t(h) + r};
k = p * t(h) / s;
Expand Down
4 changes: 1 addition & 3 deletions include/fcarouge/internal/x_z_p_q_r_hh_us_ps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,8 @@ struct x_z_p_q_r_hh_us_ps<State, Output, pack<UpdateTypes...>,
prediction_types prediction_arguments{};
transpose t{};

template <typename Output0, typename... OutputN>
inline constexpr void update(const UpdateTypes &...update_pack,
const Output0 &output_z,
const OutputN &...outputs_z) {
const auto &output_z, const auto &...outputs_z) {
update_arguments = {update_pack...};
z = output{output_z, outputs_z...};
h = observation_state_h(x, update_pack...);
Expand Down
4 changes: 1 addition & 3 deletions include/fcarouge/internal/x_z_p_qq_rr_f.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ template <typename State, typename Output> struct x_z_p_qq_rr_f {
output z{zero_v<output>};
transpose t{};

template <typename Output0, typename... OutputN>
inline constexpr void update(const Output0 &output_z,
const OutputN &...outputs_z) {
inline constexpr void update(const auto &output_z, const auto &...outputs_z) {
z = output{output_z, outputs_z...};
r = noise_observation_r(x, z);
s = innovation_uncertainty{h * p * t(h) + r};
Expand Down
8 changes: 2 additions & 6 deletions include/fcarouge/internal/x_z_u_p_q_r_f_g_ps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ struct x_z_u_p_q_r_f_g_ps<State, Output, Input, pack<UpdateTypes...>,
prediction_types prediction_arguments{};
transpose t{};

template <typename Output0, typename... OutputN>
inline constexpr void update(const Output0 &output_z,
const OutputN &...outputs_z) {
inline constexpr void update(const auto &output_z, const auto &...outputs_z) {
z = output{output_z, outputs_z...};
s = h * p * t(h) + r;
k = p * t(h) / s;
Expand All @@ -106,10 +104,8 @@ struct x_z_u_p_q_r_f_g_ps<State, Output, Input, pack<UpdateTypes...>,
p = estimate_uncertainty{(i - k * h) * p * t(i - k * h) + k * r * t(k)};
}

template <typename Input0, typename... InputN>
inline constexpr void predict(const PredictionTypes &...prediction_pack,
const Input0 &input_u,
const InputN &...inputs_u) {
const auto &input_u, const auto &...inputs_u) {
prediction_arguments = {prediction_pack...};
u = input{input_u, inputs_u...};
f = transition_state_f(x, u, prediction_pack...);
Expand Down
9 changes: 3 additions & 6 deletions include/fcarouge/internal/x_z_u_p_q_r_us_ps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ struct x_z_u_p_q_r_us_ps<State, Output, Input, pack<UpdateTypes...>,
prediction_types prediction_arguments{};
transpose t{};

template <typename Output0, typename... OutputN>
inline constexpr void update(const UpdateTypes &...update_pack,
const Output0 &output_z,
const OutputN &...outputs_z) {
const auto &output_z, const auto &...outputs_z) {
update_arguments = {update_pack...};
z = output{output_z, outputs_z...};
s = h * p * t(h) + r;
Expand All @@ -99,10 +97,9 @@ struct x_z_u_p_q_r_us_ps<State, Output, Input, pack<UpdateTypes...>,
p = (i - k * h) * p * t(i - k * h) + k * r * t(k);
}

template <typename Input0, typename... InputN>
//! @todo Add convertible requirements on input and output packs?
inline constexpr void predict(const PredictionTypes &...prediction_pack,
const Input0 &input_u,
const InputN &...inputs_u) {
const auto &input_u, const auto &...inputs_u) {
prediction_arguments = {prediction_pack...};
u = input{input_u, inputs_u...};
x = f * x + g * u;
Expand Down

0 comments on commit 222abe1

Please sign in to comment.