10#include <Eigen/SparseCore>
21template <
typename Derived,
typename CharT>
22 requires std::derived_from<Derived, Eigen::DenseBase<Derived>> ||
23 std::derived_from<Derived, Eigen::SparseCompressedBase<Derived>>
24struct fmt::formatter<Derived, CharT> {
25 template <
typename ParseContext>
26 constexpr auto parse(ParseContext& ctx) {
27 return m_underlying.parse(ctx);
30 template <
typename FmtContext>
31 auto format(
const Derived& mat, FmtContext& ctx)
const {
34 for (
int row = 0; row < mat.rows(); ++row) {
35 for (
int col = 0; col < mat.cols(); ++col) {
36 out = fmt::format_to(out,
" ");
37 out = m_underlying.format(mat.coeff(row, col), ctx);
40 if (row < mat.rows() - 1) {
41 out = fmt::format_to(out,
"\n");
49 fmt::formatter<typename Derived::Scalar, CharT> m_underlying;