diff --git a/src/algebra/ShrinkMatrixView.hpp b/src/algebra/ShrinkMatrixView.hpp
index a93efc07a2dd67103af7ba3bdb133f9fab3f59ec..a41089a0af510c088d57a85c3f4606e1709dc2a6 100644
--- a/src/algebra/ShrinkMatrixView.hpp
+++ b/src/algebra/ShrinkMatrixView.hpp
@@ -5,6 +5,8 @@
 #include <utils/PugsMacros.hpp>
 
 #include <cstddef>
+#include <iostream>
+#include <utils/NaNHelper.hpp>
 
 template <typename MatrixType>
 class ShrinkMatrixView
@@ -18,6 +20,19 @@ class ShrinkMatrixView
   const size_t m_nb_rows;
 
  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
   numberOfRows() const noexcept
   {
diff --git a/src/algebra/ShrinkVectorView.hpp b/src/algebra/ShrinkVectorView.hpp
index dc5faa800a1c0828b0569c33efee95add38f061a..cdf786c5a30970b747b0f540642d5637059198b8 100644
--- a/src/algebra/ShrinkVectorView.hpp
+++ b/src/algebra/ShrinkVectorView.hpp
@@ -5,6 +5,8 @@
 #include <utils/PugsMacros.hpp>
 
 #include <cstddef>
+#include <iostream>
+#include <utils/NaNHelper.hpp>
 
 template <typename VectorType>
 class ShrinkVectorView
@@ -18,6 +20,18 @@ class ShrinkVectorView
   const size_t m_dimension;
 
  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
   dimension() const noexcept
   {