From: Wolfgang Bangerth Date: Tue, 2 Apr 2024 03:23:08 +0000 (-0600) Subject: Provide a default implementation for VectorizedArray::dot_product(). X-Git-Tag: v9.6.0-rc1~416^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a86d6237351f4890f72144bedc03a808e4008938;p=dealii.git Provide a default implementation for VectorizedArray::dot_product(). --- diff --git a/include/deal.II/base/vectorization.h b/include/deal.II/base/vectorization.h index 58ad2e09e7..9511a853a1 100644 --- a/include/deal.II/base/vectorization.h +++ b/include/deal.II/base/vectorization.h @@ -334,6 +334,25 @@ public: return VectorizedArrayIterator( static_cast(*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(*this); + p *= v; + return p.sum(); + } };