From 0826f8bfd748b9a97b9efa45ac0cd62ffbcb4af9 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann <christoph.lehmann@ufz.de> Date: Fri, 9 Feb 2024 11:48:41 +0100 Subject: [PATCH] [MaL] Use full precision for Eigen matrix output (fmt/spdlog) --- MathLib/FormattingUtils.cpp | 17 +++++++++++++++++ MathLib/FormattingUtils.h | 13 +++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 MathLib/FormattingUtils.cpp diff --git a/MathLib/FormattingUtils.cpp b/MathLib/FormattingUtils.cpp new file mode 100644 index 00000000000..7123ce449da --- /dev/null +++ b/MathLib/FormattingUtils.cpp @@ -0,0 +1,17 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#include "FormattingUtils.h" + +namespace MathLib +{ +Eigen::IOFormat const EigenIOFormat::full_precision{ + Eigen::FullPrecision, 0, " ", "\n", "", "", "", "", ' '}; +} // namespace MathLib diff --git a/MathLib/FormattingUtils.h b/MathLib/FormattingUtils.h index ba75fc4e6af..8c346d64121 100644 --- a/MathLib/FormattingUtils.h +++ b/MathLib/FormattingUtils.h @@ -15,8 +15,21 @@ #include <Eigen/Core> #include <concepts> +namespace MathLib +{ +struct EigenIOFormat +{ + static const Eigen::IOFormat full_precision; +}; +} // namespace MathLib + template <typename T> requires std::derived_from<T, Eigen::DenseBase<T>> struct fmt::formatter<T> : fmt::ostream_formatter { + auto format(T const& value, fmt::format_context& ctx) const + { + return fmt::ostream_formatter::format( + value.format(MathLib::EigenIOFormat::full_precision), ctx); + } }; -- GitLab