Skip to content

Commit

Permalink
Merge pull request #16837 from bangerth/vec-array-2
Browse files Browse the repository at this point in the history
Provide an implementation for VectorizedArray::dot_product().
  • Loading branch information
kronbichler committed Apr 3, 2024
2 parents 8849960 + a86d623 commit c76154b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions include/deal.II/base/vectorization.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,25 @@ class VectorizedArrayBase
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();
}
};


Expand Down

0 comments on commit c76154b

Please sign in to comment.