From fe5d2f90204878df388f8b497b03c89f097615c4 Mon Sep 17 00:00:00 2001
From: Pauli Virtanen <pauli.t.virtanen@jyu.fi>
Date: Thu, 4 Aug 2022 15:14:33 +0300
Subject: [PATCH] array: add .fill()

---
 src/array.hpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/array.hpp b/src/array.hpp
index 8df3b36..f3710a1 100644
--- a/src/array.hpp
+++ b/src/array.hpp
@@ -419,6 +419,15 @@ public:
             static_assert(Shape::size == detail::ShapeType<Dims...>::size, "incompatible shapes");
             return {data(), Base::size(), shape};
         }
+
+    /** Fill with value */
+    void fill(const Scalar& value)
+        {
+            const size_t n = Base::size();
+
+            for (size_t i = 0; i < n; ++i)
+                data_[i] = value;
+        }
 };
 
 /**
-- 
GitLab