LCOV - code coverage report
Current view: top level - elsa/proximal_operators - ProximalL0.cpp (source / functions) Hit Total Coverage
Test: coverage-all.lcov Lines: 19 19 100.0 %
Date: 2024-05-16 04:22:26 Functions: 4 4 100.0 %

          Line data    Source code
       1             : #include "ProximalL0.h"
       2             : #include "DataContainer.h"
       3             : #include "Error.h"
       4             : #include "TypeCasts.hpp"
       5             : #include "elsaDefines.h"
       6             : 
       7             : namespace elsa
       8             : {
       9             :     template <typename data_t>
      10             :     DataContainer<data_t> ProximalL0<data_t>::apply(const DataContainer<data_t>& v,
      11             :                                                     SelfType_t<data_t> t) const
      12          16 :     {
      13          16 :         DataContainer<data_t> out{v.getDataDescriptor()};
      14          16 :         apply(v, t, out);
      15          16 :         return out;
      16          16 :     }
      17             : 
      18             :     template <typename data_t>
      19             :     void ProximalL0<data_t>::apply(const DataContainer<data_t>& v, SelfType_t<data_t> t,
      20             :                                    DataContainer<data_t>& prox) const
      21          26 :     {
      22          26 :         if (v.getSize() != prox.getSize()) {
      23           2 :             throw LogicError("ProximalL0: sizes of v and prox must match");
      24           2 :         }
      25             : 
      26          24 :         auto vIter = v.begin();
      27          24 :         auto proxIter = prox.begin();
      28             : 
      29         236 :         for (; vIter != v.end() && proxIter != prox.end(); vIter++, proxIter++) {
      30         212 :             if ((*vIter > t) || (*vIter < -t)) {
      31          96 :                 *proxIter = *vIter;
      32         116 :             } else {
      33         116 :                 *proxIter = 0;
      34         116 :             }
      35         212 :         }
      36          24 :     }
      37             : 
      38             :     // ------------------------------------------
      39             :     // explicit template instantiation
      40             :     template class ProximalL0<float>;
      41             :     template class ProximalL0<double>;
      42             : } // namespace elsa

Generated by: LCOV version 1.14