LCOV - code coverage report
Current view: top level - elsa/storage/reductions - Sum.h (source / functions) Hit Total Coverage
Test: coverage-all.lcov Lines: 6 6 100.0 %
Date: 2024-05-16 04:22:26 Functions: 18 18 100.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "Functions.hpp"
       4             : 
       5             : #include <thrust/transform_reduce.h>
       6             : 
       7             : namespace elsa
       8             : {
       9             :     /// @brief Compute the sum of the vector (\f$\sum_i x_i\f$.)
      10             :     ///
      11             :     /// @ingroup reductions
      12             :     template <class InputIter>
      13             :     auto sum(InputIter first, InputIter last) -> thrust::iterator_value_t<InputIter>
      14          79 :     {
      15          79 :         using data_t = thrust::iterator_value_t<InputIter>;
      16             : 
      17          79 :         return thrust::transform_reduce(
      18       37407 :             first, last, [] __host__ __device__(const data_t& val) { return val; }, data_t(0),
      19          79 :             thrust::plus{});
      20          79 :     }
      21             : } // namespace elsa

Generated by: LCOV version 1.14