Skip to content

Commit

Permalink
[filter] zero matrix type erasure support Eigen independence (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoisCarouge authored Oct 21, 2022
1 parent c0e9e24 commit 8d869bb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
22 changes: 11 additions & 11 deletions include/fcarouge/internal/kalman.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ struct kalman<State, Output, void, Transpose, Divide, pack<UpdateTypes...>,
inline static const auto i{identity_v<matrix<state, state>>};

//! @todo Is there a simpler way to initialize to the zero matrix?
state x{0 * identity_v<state>};
state x{zero_v<state>};
estimate_uncertainty p{identity_v<estimate_uncertainty>};
process_uncertainty q{0 * identity_v<process_uncertainty>};
output_uncertainty r{0 * identity_v<output_uncertainty>};
process_uncertainty q{zero_v<process_uncertainty>};
output_uncertainty r{zero_v<output_uncertainty>};
output_model h{identity_v<output_model>};
state_transition f{identity_v<state_transition>};
gain k{identity_v<gain>};
innovation y{0 * identity_v<innovation>};
innovation y{zero_v<innovation>};
innovation_uncertainty s{identity_v<innovation_uncertainty>};
output z{0 * identity_v<output>};
output z{zero_v<output>};
update_types update_arguments{};
prediction_types prediction_arguments{};

Expand Down Expand Up @@ -223,18 +223,18 @@ struct kalman<State, Output, Input, Transpose, Divide, pack<UpdateTypes...>,
inline static const auto i{identity_v<matrix<state, state>>};

//! @todo Is there a simpler way to initialize to the zero matrix?
state x{0 * identity_v<state>};
state x{zero_v<state>};
estimate_uncertainty p{identity_v<estimate_uncertainty>};
process_uncertainty q{0 * identity_v<process_uncertainty>};
output_uncertainty r{0 * identity_v<output_uncertainty>};
process_uncertainty q{zero_v<process_uncertainty>};
output_uncertainty r{zero_v<output_uncertainty>};
output_model h{identity_v<output_model>};
state_transition f{identity_v<state_transition>};
input_control g{identity_v<input_control>};
gain k{identity_v<gain>};
innovation y{0 * identity_v<innovation>};
innovation y{zero_v<innovation>};
innovation_uncertainty s{identity_v<innovation_uncertainty>};
output z{0 * identity_v<output>};
input u{0 * identity_v<input>};
output z{zero_v<output>};
input u{zero_v<input>};
update_types update_arguments{};
prediction_types prediction_arguments{};

Expand Down
11 changes: 11 additions & 0 deletions include/fcarouge/internal/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ template <typename Matrix>
requires requires(Matrix value) { value.Identity(); }
inline const auto identity_v<Matrix>{Matrix::Identity()};

template <typename Type>
inline const Type zero_v{
//! @todo Implement standard, default form.
};

template <arithmetic Arithmetic> inline const Arithmetic zero_v<Arithmetic>{0};

template <typename Matrix>
requires requires(Matrix value) { value.Zero(); }
inline const auto zero_v<Matrix>{Matrix::Zero()};

} // namespace fcarouge::internal

#endif // FCAROUGE_INTERNAL_UTILITY_HPP

0 comments on commit 8d869bb

Please sign in to comment.