LCOV - code coverage report
Current view: top level - operators - Scaling.cpp (source / functions) Hit Total Coverage
Test: test_coverage.info.cleaned Lines: 0 47 0.0 %
Date: 2022-08-04 03:43:28 Functions: 0 36 0.0 %

          Line data    Source code
       1             : #include "Scaling.h"
       2             : #include "Timer.h"
       3             : #include "TypeCasts.hpp"
       4             : 
       5             : namespace elsa
       6             : {
       7             :     template <typename data_t>
       8           0 :     Scaling<data_t>::Scaling(const DataDescriptor& descriptor, data_t scaleFactor)
       9             :         : LinearOperator<data_t>(descriptor, descriptor),
      10           0 :           _isIsotropic{true},
      11           0 :           _scaleFactor{scaleFactor}
      12             :     {
      13           0 :     }
      14             : 
      15             :     template <typename data_t>
      16           0 :     Scaling<data_t>::Scaling(const DataDescriptor& descriptor,
      17             :                              const DataContainer<data_t>& scaleFactors)
      18             :         : LinearOperator<data_t>(descriptor, descriptor),
      19           0 :           _isIsotropic{false},
      20           0 :           _scaleFactors{std::make_unique<DataContainer<data_t>>(scaleFactors)}
      21             :     {
      22           0 :     }
      23             : 
      24             :     template <typename data_t>
      25           0 :     bool Scaling<data_t>::isIsotropic() const
      26             :     {
      27           0 :         return _isIsotropic;
      28             :     }
      29             : 
      30             :     template <typename data_t>
      31           0 :     data_t Scaling<data_t>::getScaleFactor() const
      32             :     {
      33           0 :         if (!_isIsotropic)
      34           0 :             throw LogicError("Scaling: scaling is not isotropic");
      35             : 
      36           0 :         return _scaleFactor;
      37             :     }
      38             : 
      39             :     template <typename data_t>
      40           0 :     const DataContainer<data_t>& Scaling<data_t>::getScaleFactors() const
      41             :     {
      42           0 :         if (_isIsotropic)
      43           0 :             throw LogicError("Scaling: scaling is isotropic");
      44             : 
      45           0 :         return *_scaleFactors;
      46             :     }
      47             : 
      48             :     template <typename data_t>
      49           0 :     void Scaling<data_t>::applyImpl(const DataContainer<data_t>& x, DataContainer<data_t>& Ax) const
      50             :     {
      51           0 :         Timer timeguard("Scaling", "apply");
      52             : 
      53           0 :         if (_isIsotropic)
      54           0 :             Ax = _scaleFactor * x;
      55             :         else
      56           0 :             Ax = *_scaleFactors * x;
      57           0 :     }
      58             : 
      59             :     template <typename data_t>
      60           0 :     void Scaling<data_t>::applyAdjointImpl(const DataContainer<data_t>& y,
      61             :                                            DataContainer<data_t>& Aty) const
      62             :     {
      63           0 :         Timer timeguard("Scaling", "applyAdjoint");
      64             : 
      65           0 :         if (_isIsotropic)
      66           0 :             Aty = _scaleFactor * y;
      67             :         else
      68           0 :             Aty = *_scaleFactors * y;
      69           0 :     }
      70             : 
      71             :     template <typename data_t>
      72           0 :     Scaling<data_t>* Scaling<data_t>::cloneImpl() const
      73             :     {
      74           0 :         if (_isIsotropic)
      75           0 :             return new Scaling(this->getDomainDescriptor(), _scaleFactor);
      76             :         else
      77           0 :             return new Scaling(this->getDomainDescriptor(), *_scaleFactors);
      78             :     }
      79             : 
      80             :     template <typename data_t>
      81           0 :     bool Scaling<data_t>::isEqual(const LinearOperator<data_t>& other) const
      82             :     {
      83           0 :         if (!LinearOperator<data_t>::isEqual(other))
      84           0 :             return false;
      85             : 
      86           0 :         auto otherScaling = downcast_safe<Scaling>(&other);
      87           0 :         if (!otherScaling)
      88           0 :             return false;
      89             : 
      90           0 :         if (_isIsotropic != otherScaling->_isIsotropic)
      91           0 :             return false;
      92             : 
      93           0 :         if (_isIsotropic && _scaleFactor != otherScaling->_scaleFactor)
      94           0 :             return false;
      95             : 
      96           0 :         if (!_isIsotropic && *_scaleFactors != *otherScaling->_scaleFactors)
      97           0 :             return false;
      98             : 
      99           0 :         return true;
     100             :     }
     101             : 
     102             :     // ------------------------------------------
     103             :     // explicit template instantiation
     104             :     template class Scaling<float>;
     105             :     template class Scaling<complex<float>>;
     106             :     template class Scaling<double>;
     107             :     template class Scaling<complex<double>>;
     108             : 
     109             : } // namespace elsa

Generated by: LCOV version 1.14