LCOV - code coverage report
Current view: top level - elsa/operators - Diagonal.cpp (source / functions) Hit Total Coverage
Test: coverage-all.lcov Lines: 12 27 44.4 %
Date: 2024-05-16 04:22:26 Functions: 4 10 40.0 %

          Line data    Source code
       1             : #include "Diagonal.h"
       2             : #include "Timer.h"
       3             : #include "TypeCasts.hpp"
       4             : 
       5             : namespace elsa
       6             : {
       7             :     template <typename data_t>
       8             :     Diagonal<data_t>::Diagonal(const DataDescriptor& domain, const DataDescriptor& range,
       9             :                                const OperatorList& ops)
      10             :         : LinearOperator<data_t>(domain, range)
      11           2 :     {
      12           2 :         ops_.reserve(ops.size());
      13           2 :         for (const auto& op : ops)
      14           6 :             ops_.push_back(op->clone());
      15           2 :     }
      16             : 
      17             :     template <typename data_t>
      18             :     void Diagonal<data_t>::applyImpl(const DataContainer<data_t>& x,
      19             :                                      DataContainer<data_t>& Ax) const
      20           2 :     {
      21           2 :         Timer timeguard("Diagonal", "apply");
      22             : 
      23           8 :         for (std::size_t i = 0; i < ops_.size(); ++i) {
      24           6 :             auto blk = Ax.getBlock(asSigned(i));
      25           6 :             ops_[i]->apply(x.getBlock(asSigned(i)), blk);
      26           6 :         }
      27           2 :     }
      28             : 
      29             :     template <typename data_t>
      30             :     void Diagonal<data_t>::applyAdjointImpl(const DataContainer<data_t>& y,
      31             :                                             DataContainer<data_t>& Aty) const
      32           0 :     {
      33           0 :         Timer timeguard("Diagonal", "applyAdjoint");
      34             : 
      35           0 :         for (std::size_t i = 0; i < ops_.size(); ++i) {
      36           0 :             auto blk = Aty.getBlock(asSigned(i));
      37           0 :             ops_[i]->applyAdjoint(y.getBlock(asSigned(i)), blk);
      38           0 :         }
      39           0 :     }
      40             : 
      41             :     template <typename data_t>
      42             :     Diagonal<data_t>* Diagonal<data_t>::cloneImpl() const
      43           0 :     {
      44           0 :         return new Diagonal(this->getDomainDescriptor(), this->getRangeDescriptor(), ops_);
      45           0 :     }
      46             : 
      47             :     template <typename data_t>
      48             :     bool Diagonal<data_t>::isEqual(const LinearOperator<data_t>& other) const
      49           0 :     {
      50           0 :         if (!LinearOperator<data_t>::isEqual(other))
      51           0 :             return false;
      52             : 
      53           0 :         return is<Diagonal>(other);
      54           0 :     }
      55             : 
      56             :     // ------------------------------------------
      57             :     // explicit template instantiation
      58             :     template class Diagonal<float>;
      59             :     template class Diagonal<double>;
      60             : 
      61             : } // namespace elsa

Generated by: LCOV version 1.14