LCOV - code coverage report
Current view: top level - elsa/operators - FourierTransform.cpp (source / functions) Hit Total Coverage
Test: coverage-all.lcov Lines: 26 28 92.9 %
Date: 2024-05-16 04:22:26 Functions: 8 10 80.0 %

          Line data    Source code
       1             : #include "FourierTransform.h"
       2             : 
       3             : #include "Error.h"
       4             : #include "ExpressionPredicates.h"
       5             : #include "Timer.h"
       6             : 
       7             : #include <iostream>
       8             : 
       9             : namespace elsa
      10             : {
      11             :     template <typename data_t>
      12             :     FourierTransform<data_t>::FourierTransform(const DataDescriptor& domainDescriptor, FFTNorm norm)
      13             :         : B(domainDescriptor, domainDescriptor), norm{norm}
      14          27 :     {
      15          27 :     }
      16             : 
      17             :     template <typename data_t>
      18             :     void FourierTransform<data_t>::applyImpl(const DataContainer<data_t>& x,
      19             :                                              DataContainer<data_t>& Ax) const
      20         346 :     {
      21             : 
      22         346 :         Timer timeguard("FourierTransform", "apply()");
      23             : 
      24             :         // TODO: if domain and range descriptors dont match,
      25             :         //       resize the datacontainer appropriately.
      26         346 :         auto x_values = x.getDataDescriptor().getNumberOfCoefficientsPerDimension();
      27         346 :         assert(x_values == this->_domainDescriptor->getNumberOfCoefficientsPerDimension());
      28             : 
      29             :         // copy the input and fouriertransform it
      30         346 :         Ax = x;
      31         346 :         Ax.fft(this->norm);
      32         346 :     }
      33             : 
      34             :     template <typename data_t>
      35             :     void FourierTransform<data_t>::applyAdjointImpl(const DataContainer<data_t>& x,
      36             :                                                     DataContainer<data_t>& Atx) const
      37         450 :     {
      38         450 :         Timer timeguard("FourierTransform", "applyAdjoint()");
      39             : 
      40             :         // TODO: same as applyImpl
      41         450 :         auto x_values = x.getDataDescriptor().getNumberOfCoefficientsPerDimension();
      42         450 :         assert(x_values == this->_domainDescriptor->getNumberOfCoefficientsPerDimension());
      43             : 
      44             :         // copy the input and inverse-fouriertransform it
      45         450 :         Atx = x;
      46         450 :         Atx.ifft(this->norm);
      47         450 :     }
      48             : 
      49             :     template <typename data_t>
      50             :     FourierTransform<data_t>* FourierTransform<data_t>::cloneImpl() const
      51           2 :     {
      52           2 :         auto& domainDescriptor = static_cast<const DataDescriptor&>(*this->_domainDescriptor);
      53             : 
      54           2 :         return new FourierTransform(domainDescriptor);
      55           2 :     }
      56             : 
      57             :     template <typename data_t>
      58             :     bool FourierTransform<data_t>::isEqual(const B& other) const
      59           2 :     {
      60           2 :         if (!B::isEqual(other))
      61           0 :             return false;
      62             : 
      63           2 :         auto otherOP = dynamic_cast<const FourierTransform*>(&other);
      64           2 :         if (!otherOP)
      65           0 :             return false;
      66             : 
      67             :         // fourier transforms have no configuration yet
      68           2 :         return true;
      69           2 :     }
      70             : 
      71             :     template class FourierTransform<complex<float>>;
      72             :     template class FourierTransform<complex<double>>;
      73             : } // namespace elsa

Generated by: LCOV version 1.14