]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Extend VectorizedArrayTrait 14293/head
authorPeter Munch <peterrmuench@gmail.com>
Tue, 20 Sep 2022 17:39:05 +0000 (19:39 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Tue, 20 Sep 2022 17:39:05 +0000 (19:39 +0200)
include/deal.II/base/vectorization.h

index 9f586379115c9e41efcaa9da0ed3331c9bb0e697..6c9c43575fe88b23a14584844451db6ad59be02f 100644 (file)
@@ -5359,13 +5359,49 @@ namespace internal
   template <typename T>
   struct VectorizedArrayTrait
   {
-    using value_type = T;
+    using value_type                   = T;
+    static constexpr std::size_t width = 1;
+
+    static T &
+    get(T &value, unsigned int c)
+    {
+      AssertDimension(c, 0);
+      (void)c;
+
+      return value;
+    }
+
+    static const T &
+    get(const T &value, unsigned int c)
+    {
+      AssertDimension(c, 0);
+      (void)c;
+
+      return value;
+    }
   };
 
-  template <typename T, std::size_t width>
-  struct VectorizedArrayTrait<VectorizedArray<T, width>>
+  template <typename T, std::size_t width_>
+  struct VectorizedArrayTrait<VectorizedArray<T, width_>>
   {
-    using value_type = T;
+    using value_type                   = T;
+    static constexpr std::size_t width = width_;
+
+    static T &
+    get(VectorizedArray<T, width_> &values, unsigned int c)
+    {
+      AssertIndexRange(c, width_);
+
+      return values[c];
+    }
+
+    static const T &
+    get(const VectorizedArray<T, width_> &values, unsigned int c)
+    {
+      AssertIndexRange(c, width_);
+
+      return values[c];
+    }
   };
 } // namespace internal
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.