LCOV - code coverage report
Current view: top level - Dynamic - GainFilter.cpp (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 21 21 100.0 %
Date: 2021-02-18 20:07:22 Functions: 6 6 100.0 %

          Line data    Source code
       1             : /**
       2             :  * \file GainFilter.cpp
       3             :  */
       4             : 
       5             : #include "GainFilter.h"
       6             : #include <ATK/Core/Utilities.h>
       7             : 
       8             : #include <cassert>
       9             : #include <cmath>
      10             : #include <cstdint>
      11             : 
      12             : namespace ATK
      13             : {
      14             :   template<typename DataType_>
      15          90 :   ParentGainFilter<DataType_>::ParentGainFilter(gsl::index nb_channels, size_t LUTsize, size_t LUTprecision)
      16          90 :   :Parent(nb_channels, nb_channels), LUTsize(LUTsize), LUTprecision(LUTprecision), gainLUT(LUTsize, 0)
      17             :   {
      18          90 :   }
      19             :   
      20             :   template<typename DataType_>
      21          42 :   void ParentGainFilter<DataType_>::set_threshold(DataType_ threshold)
      22             :   {
      23          42 :     if (threshold <= 0)
      24             :     {
      25           1 :       throw ATK::RuntimeError("Threshold factor must be strictly positive value");
      26             :     }
      27          41 :     this->threshold = 1 / threshold;
      28          41 :   }
      29             : 
      30             :   template<typename DataType_>
      31           1 :   void ParentGainFilter<DataType_>::set_threshold_db(DataType_ threshold_db)
      32             :   {
      33           1 :     this->threshold = static_cast<DataType_>(std::pow(10, - threshold_db / 10));
      34           1 :   }
      35             : 
      36             :   template<typename DataType_>
      37           2 :   DataType_ ParentGainFilter<DataType_>::get_threshold() const
      38             :   {
      39           2 :     return 1 / threshold;
      40             :   }
      41             : 
      42             :   template<typename DataType_>
      43          27 :   void ParentGainFilter<DataType_>::set_ratio(DataType_ ratio)
      44             :   {
      45          27 :     if (ratio <= 0)
      46             :     {
      47           1 :       throw ATK::RuntimeError("Ratio factor must be higher than 0");
      48             :     }
      49          26 :     this->ratio = ratio;
      50          26 :     start_recomputeLUT();
      51          26 :   }
      52             : 
      53             :   template<typename DataType_>
      54           1 :   DataType_ ParentGainFilter<DataType_>::get_ratio() const
      55             :   {
      56           1 :     return ratio;
      57             :   }
      58             : 
      59             : #if ATK_ENABLE_INSTANTIATION
      60             :   template class ParentGainFilter<float>;
      61             : #endif
      62             :   template class ParentGainFilter<double>;
      63             : }

Generated by: LCOV version TK-3.3.0-4-gdba42eea