LCOV - code coverage report
Current view: top level - elsa/storage/reductions - L0.h (source / functions) Hit Total Coverage
Test: coverage-all.lcov Lines: 9 9 100.0 %
Date: 2024-12-21 07:37:52 Functions: 14 14 100.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "functions/Abs.hpp"
       4             : 
       5             : #include <thrust/complex.h>
       6             : #include <thrust/count.h>
       7             : #include <thrust/limits.h>
       8             : 
       9             : namespace elsa
      10             : {
      11             :     namespace detail
      12             :     {
      13             :         struct nonZeroComp {
      14             :             template <class T>
      15             :             __host__ __device__ std::ptrdiff_t operator()(const T& arg) const noexcept
      16       25024 :             {
      17       25024 :                 return elsa::abs(arg) >= thrust::numeric_limits<T>::epsilon();
      18       25024 :             }
      19             : 
      20             :             template <class T>
      21             :             __host__ __device__ std::ptrdiff_t
      22             :                 operator()(const thrust::complex<T>& arg) const noexcept
      23       16508 :             {
      24       16508 :                 return elsa::abs(arg) >= thrust::numeric_limits<T>::epsilon();
      25       16508 :             }
      26             :         };
      27             :     } // namespace detail
      28             : 
      29             :     /// @brief compute the l0-"norm", which counts the number of non-zero elements.
      30             :     ///
      31             :     /// @ingroup reductions
      32             :     template <class InputIter>
      33             :     std::ptrdiff_t l0PseudoNorm(InputIter first, InputIter last)
      34          27 :     {
      35          27 :         return thrust::count_if(first, last, detail::nonZeroComp{});
      36          27 :     }
      37             : } // namespace elsa

Generated by: LCOV version 1.14