Do dot product using lambda functions

What is the new feature

Reduce dot product code using lambda functions.

How is it implemented

This solution uses a lambda function so that the inner for-loops can be reused. Tthe outer layer is unrolled manually like the Fortran implementation.

The advantage is

  1. For all dot products, we just have to redefine the lambda function and register it.
  2. Without using mdspan, we don't have to use c++23.

The original idea of three layers of lambda functions was given up because of low maintainability. See here for an example. We can reconsider the solution if we need more performance.

Here are some extra references of lambda functions, parameter pack(...), std::forward, and std::integer_sequence.

Mandatory steps before review

  • Gitlab CI passes (Hint: use make format for linting)
  • New feature is covered by additional unit tests
  • Mark the merge request as ready by removing Draft:

Mandatory steps before merge

  • Reviewed by a maintainer
  • Incorporate review suggestions
  • Remember to edit the commit message and select the proper changelog category (feature/bugfix/other)
  • Prior to merging, please remove any boilerplate from the MR description, retaining only the Please describe your feature in a couple of words and describe important implementation details of the feature section to maintain

You are not supposed to merge this request by yourself, the maintainers of libiconmath take care of this action!

Edited by Pradipta Samanta

Merge request reports

Loading