Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[format] add 1x1x0 filter support #86

Merged
merged 1 commit into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions include/fcarouge/internal/format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,33 @@ struct std::formatter<
}
};

template <typename Type, std::size_t State, std::size_t Output,
typename Transpose, typename Symmetrize, typename Divide,
typename Identity, typename UpdateTypes, typename PredictionTypes,
typename Char>
struct std::formatter<
fcarouge::kalman<Type, State, Output, 0, Transpose, Symmetrize, Divide,
Identity, UpdateTypes, PredictionTypes>,
Char> {
//! @todo Support parsing arguments.
constexpr auto parse(std::basic_format_parse_context<Char> &parse_context)
{
return parse_context.begin();
}

template <typename OutputIt>
auto format(const fcarouge::kalman<Type, State, Output, 0, Transpose,
Symmetrize, Divide, Identity, UpdateTypes,
PredictionTypes> &filter,
std::basic_format_context<OutputIt, Char> &format_context)
-> OutputIt
{
return format_to(format_context.out(),
"{{f:{},h:{},k:{},p:{},q:{},r:{},s:{},x:{},y:{},z:{}}}",
filter.f(), filter.h(), filter.k(), filter.p(), filter.q(),
filter.r(), filter.s(), filter.x(), filter.y(),
filter.z());
}
};

#endif // FCAROUGE_INTERNAL_FORMAT_HPP
10 changes: 10 additions & 0 deletions test/format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ namespace fcarouge::test
namespace
{

//! @test Verifies formatting filters for single-dimension filters without input
//! control.
[[maybe_unused]] auto format110{ [] {
kalman k;

assert(std::format("{}", k) == "{f:1,h:1,k:1,p:1,q:0,r:0,s:1,x:0,y:0,z:0}");

return 0;
}() };

//! @test Verifies formatting filters for single-dimension filters with input
//! control.
[[maybe_unused]] auto format111{ [] {
Expand Down