Skip to content
Snippets Groups Projects
Commit 41ddf658 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Allow output of ShrinkVectorView and ShrinkMatrixView

parent e00336ad
No related branches found
No related tags found
1 merge request!205High-order polynomial reconstruction
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include <utils/PugsMacros.hpp> #include <utils/PugsMacros.hpp>
#include <cstddef> #include <cstddef>
#include <iostream>
#include <utils/NaNHelper.hpp>
template <typename MatrixType> template <typename MatrixType>
class ShrinkMatrixView class ShrinkMatrixView
...@@ -18,6 +20,19 @@ class ShrinkMatrixView ...@@ -18,6 +20,19 @@ class ShrinkMatrixView
const size_t m_nb_rows; const size_t m_nb_rows;
public: public:
friend std::ostream&
operator<<(std::ostream& os, const ShrinkMatrixView& A)
{
for (size_t i = 0; i < A.numberOfRows(); ++i) {
os << i << '|';
for (size_t j = 0; j < A.numberOfColumns(); ++j) {
os << ' ' << j << ':' << NaNHelper(A(i, j));
}
os << '\n';
}
return os;
}
PUGS_INLINE size_t PUGS_INLINE size_t
numberOfRows() const noexcept numberOfRows() const noexcept
{ {
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include <utils/PugsMacros.hpp> #include <utils/PugsMacros.hpp>
#include <cstddef> #include <cstddef>
#include <iostream>
#include <utils/NaNHelper.hpp>
template <typename VectorType> template <typename VectorType>
class ShrinkVectorView class ShrinkVectorView
...@@ -18,6 +20,18 @@ class ShrinkVectorView ...@@ -18,6 +20,18 @@ class ShrinkVectorView
const size_t m_dimension; const size_t m_dimension;
public: public:
friend std::ostream&
operator<<(std::ostream& os, const ShrinkVectorView& 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 PUGS_INLINE size_t
dimension() const noexcept dimension() const noexcept
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment