preCICE v3.1.2
Loading...
Searching...
No Matches
fmtEigen.hpp
Go to the documentation of this file.
1#include <Eigen/Core>
2#include <algorithm>
3#include <fmt/format.h>
4#include <sstream>
5#include <utils/EigenIO.hpp>
6
7// Register the result of EigenDenseBase::format() as usable type
8template <typename ExpressionType>
9struct fmt::formatter<Eigen::WithFormat<ExpressionType>> : ostream_formatter {
10};
11
12// Register Eigen::Matrix as formattable type.
13// We should use Eigen::DenseBase here, but this doesn't seem to work as expected.
14// Maybe C++17 deduction guides will help with this?
15template <typename Scalar, int RowsAtCompileTime, int ColsAtCompileTime>
16struct fmt::formatter<Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime>> : formatter<string_view> {
17 template <typename FormatContext>
18 auto format(const Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime> &v, FormatContext &ctx) const
19 {
20 return format_to(ctx.out(), "{}", v.format(precice::utils::eigenio::wkt()));
21 }
22};
Eigen::IOFormat wkt()
Definition EigenIO.hpp:9
auto format(const Eigen::Matrix< Scalar, RowsAtCompileTime, ColsAtCompileTime > &v, FormatContext &ctx) const
Definition fmtEigen.hpp:18