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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <thrust/transform.h>
       4             : 
       5             : namespace elsa
       6             : {
       7             :     namespace detail
       8             :     {
       9             :         template <class data_t>
      10             :         struct LincombFunctor {
      11             :             data_t a_;
      12             :             data_t b_;
      13             : 
      14        5178 :             LincombFunctor(data_t a, data_t b) : a_(a), b_(b) {}
      15             : 
      16             :             __host__ __device__ data_t operator()(const data_t& x, const data_t& y) const
      17      237089 :             {
      18      237089 :                 return a_ * x + b_ * y;
      19      237089 :             }
      20             :         };
      21             :     } // namespace detail
      22             : 
      23             :     /// @brief Compute the linear combination of \f$a * x + b * y\f$, where
      24             :     /// \f$x\f$ and \f$y\f$ are vectors given as iterators, and written to the output
      25             :     /// iterator
      26             :     ///
      27             :     /// @ingroup transforms
      28             :     template <class data_t, class InputIter1, class InputIter2, class OutIter>
      29             :     void lincomb(data_t a, InputIter1 first1, InputIter1 last1, data_t b, InputIter2 first2,
      30             :                  OutIter out)
      31        5178 :     {
      32        5178 :         thrust::transform(first1, last1, first2, out, detail::LincombFunctor<data_t>{a, b});
      33        5178 :     }
      34             : } // namespace elsa

Generated by: LCOV version 1.14