LCOV - code coverage report
Current view: top level - elsa/proximal_operators - CombinedProximal.cpp (source / functions) Hit Total Coverage
Test: coverage-all.lcov Lines: 23 35 65.7 %
Date: 2024-05-16 04:22:26 Functions: 12 16 75.0 %

          Line data    Source code
       1             : #include "CombinedProximal.h"
       2             : 
       3             : #include "BlockDescriptor.h"
       4             : #include "DataContainer.h"
       5             : #include "Error.h"
       6             : #include "ProximalOperator.h"
       7             : #include "TypeCasts.hpp"
       8             : #include "StrongTypes.h"
       9             : #include "elsaDefines.h"
      10             : 
      11             : namespace elsa
      12             : {
      13             :     template <class data_t>
      14             :     CombinedProximal<data_t>::CombinedProximal(ProximalOperator<data_t> prox) : proxs_({prox})
      15           2 :     {
      16           2 :     }
      17             : 
      18             :     template <class data_t>
      19             :     CombinedProximal<data_t>::CombinedProximal(ProximalOperator<data_t> prox1,
      20             :                                                ProximalOperator<data_t> prox2)
      21             :         : proxs_({prox1, prox2})
      22           2 :     {
      23           2 :     }
      24             : 
      25             :     template <class data_t>
      26             :     CombinedProximal<data_t>::CombinedProximal(ProximalOperator<data_t> prox1,
      27             :                                                ProximalOperator<data_t> prox2,
      28             :                                                ProximalOperator<data_t> prox3)
      29             :         : proxs_({prox1, prox2, prox3})
      30           2 :     {
      31           2 :     }
      32             : 
      33             :     template <class data_t>
      34             :     CombinedProximal<data_t>::CombinedProximal(ProximalOperator<data_t> prox1,
      35             :                                                ProximalOperator<data_t> prox2,
      36             :                                                ProximalOperator<data_t> prox3,
      37             :                                                ProximalOperator<data_t> prox4)
      38             :         : proxs_({prox1, prox2, prox3, prox4})
      39           2 :     {
      40           2 :     }
      41             : 
      42             :     template <class data_t>
      43             :     DataContainer<data_t> CombinedProximal<data_t>::apply(const DataContainer<data_t>& v,
      44             :                                                           SelfType_t<data_t> t) const
      45           8 :     {
      46           8 :         DataContainer<data_t> out(v.getDataDescriptor());
      47           8 :         apply(v, t, out);
      48           8 :         return out;
      49           8 :     }
      50             : 
      51             :     template <class data_t>
      52             :     void CombinedProximal<data_t>::apply(const DataContainer<data_t>& v, SelfType_t<data_t> t,
      53             :                                          DataContainer<data_t>& prox) const
      54           8 :     {
      55           8 :         if (!is<BlockDescriptor>(v.getDataDescriptor())) {
      56           0 :             throw Error("CombinedProximal: Proximal needs to be blocked");
      57           0 :         }
      58             : 
      59           8 :         auto& blockedDesc = downcast_safe<BlockDescriptor>(v.getDataDescriptor());
      60             : 
      61           8 :         if (blockedDesc.getNumberOfBlocks() != asSigned(proxs_.size())) {
      62           0 :             throw Error("CombinedProximal: number of blocks ({}) and number of proximals ({}) "
      63           0 :                         "do not fit",
      64           0 :                         blockedDesc.getNumberOfBlocks(), proxs_.size());
      65           0 :         }
      66             : 
      67          28 :         for (int i = 0; i < blockedDesc.getNumberOfBlocks(); ++i) {
      68          20 :             auto outview = prox.getBlock(i);
      69          20 :             auto inview = v.getBlock(i);
      70             : 
      71          20 :             proxs_[i].apply(inview, t, outview);
      72          20 :         }
      73           8 :     }
      74             : 
      75             :     template <class data_t>
      76             :     ProximalOperator<data_t> CombinedProximal<data_t>::getIthProximal(index_t i)
      77           0 :     {
      78           0 :         return proxs_.at(i);
      79           0 :     }
      80             : 
      81             :     template <class data_t>
      82             :     void CombinedProximal<data_t>::addProximal(ProximalOperator<data_t> prox)
      83           0 :     {
      84           0 :         proxs_.push_back(prox);
      85           0 :     }
      86             : 
      87             :     // ------------------------------------------
      88             :     // explicit template instantiation
      89             :     template class CombinedProximal<float>;
      90             :     template class CombinedProximal<double>;
      91             : } // namespace elsa

Generated by: LCOV version 1.14