diff --git a/src/algebra/Vector.hpp b/src/algebra/Vector.hpp index 6950df9d74f6478c0c3346c9fa6c96aaff65781d..c918ed409746a3c212720ad8ae6769cfb0882ba9 100644 --- a/src/algebra/Vector.hpp +++ b/src/algebra/Vector.hpp @@ -2,7 +2,6 @@ #define VECTOR_HPP #include <utils/Array.hpp> -#include <utils/NaNHelper.hpp> #include <utils/PugsAssert.hpp> #include <utils/PugsMacros.hpp> #include <utils/PugsUtils.hpp> @@ -29,13 +28,7 @@ class Vector // LCOV_EXCL_LINE friend std::ostream& operator<<(std::ostream& os, const Vector& x) { - if (x.size() > 0) { - os << 0 << ':' << NaNHelper(x[0]); - } - for (size_t i = 1; i < x.size(); ++i) { - os << ' ' << i << ':' << NaNHelper(x[i]); - } - return os; + return os << x.m_values; } friend Vector<std::remove_const_t<DataType>> diff --git a/src/utils/Array.hpp b/src/utils/Array.hpp index e2a4e5c71c6938e96a2d2cf63318b1f7ed9c8f4c..bae84f1147f54c18aee9b81220cc42c12d9bdf17 100644 --- a/src/utils/Array.hpp +++ b/src/utils/Array.hpp @@ -2,6 +2,7 @@ #define ARRAY_HPP #include <utils/InvalidData.hpp> +#include <utils/NaNHelper.hpp> #include <utils/PugsAssert.hpp> #include <utils/PugsMacros.hpp> #include <utils/PugsUtils.hpp> @@ -23,6 +24,17 @@ class [[nodiscard]] Array friend Array<std::add_const_t<DataType>>; public: + friend std::ostream& operator<<(std::ostream& os, const Array& x) + { + if (x.size() > 0) { + os << 0 << ':' << NaNHelper(x[0]); + } + for (size_t i = 1; i < x.size(); ++i) { + os << ' ' << i << ':' << NaNHelper(x[i]); + } + return os; + } + PUGS_INLINE size_t size() const noexcept { return m_values.extent(0);