]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Provide a default implementation for VectorizedArray::dot_product(). 16837/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 2 Apr 2024 03:23:08 +0000 (21:23 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 2 Apr 2024 15:07:06 +0000 (09:07 -0600)
include/deal.II/base/vectorization.h

index 58ad2e09e76804e3a7dfc0ecc1191b72fccbe807..9511a853a1d4003e46f7e6a63daa0803b2999292 100644 (file)
@@ -334,6 +334,25 @@ public:
     return VectorizedArrayIterator<const VectorizedArrayType>(
       static_cast<const VectorizedArrayType &>(*this), width);
   }
+
+  /**
+   * A default implementation for computing the dot product between two
+   * vectorized arrays. It first forms the lane-by-lane product between
+   * the current object and the argument, and then the across-lanes
+   * sum of the product. The function returns the kind of object that
+   * the VectorizedArray::sum() function returns.
+   *
+   * This function is inherited by all derived classes and provides
+   * the dot product to them unless they override it with their own
+   * implementation (presumably using a more efficient approach).
+   */
+  auto
+  dot_product(const VectorizedArrayType &v) const
+  {
+    VectorizedArrayType p = static_cast<const VectorizedArrayType &>(*this);
+    p *= v;
+    return p.sum();
+  }
 };
 
 

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.