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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "TypeTraits.hpp"
       4             : #include "functions/Abs.hpp"
       5             : #include "DisableWarnings.h"
       6             : 
       7             : DISABLE_WARNING_PUSH
       8             : DISABLE_WARNING_SIGN_CONVERSION
       9             : #include <thrust/iterator/transform_iterator.h>
      10             : #include <thrust/extrema.h>
      11             : DISABLE_WARNING_POP
      12             : 
      13             : namespace elsa
      14             : {
      15             :     /// @brief Compute the max of the vector (\f$\sup_i |x_i|\f$.)
      16             :     ///
      17             :     /// @ingroup reductions
      18             :     template <class InputIter>
      19             :     auto lInf(InputIter first, InputIter last)
      20             :         -> value_type_of_t<thrust::iterator_value_t<InputIter>>
      21          29 :     {
      22          29 :         using data_t = value_type_of_t<thrust::iterator_value_t<InputIter>>;
      23             : 
      24          29 :         auto zipfirst = thrust::make_transform_iterator(first, elsa::abs);
      25          29 :         auto ziplast = thrust::make_transform_iterator(last, elsa::abs);
      26             : 
      27          29 :         auto iter = thrust::max_element(zipfirst, ziplast);
      28             : 
      29          29 :         return iter == ziplast ? data_t() : *iter;
      30          29 :     }
      31             : } // namespace elsa

Generated by: LCOV version 1.14