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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "DataDescriptor.h"
       4             : #include "Functional.h"
       5             : #include "DataContainer.h"
       6             : #include "LinearOperator.h"
       7             : 
       8             : namespace elsa
       9             : {
      10             :     /**
      11             :      * @brief Class representing a L2 regularization term with an optional linear operator
      12             :      *
      13             :      * This functional evaluates to \f$ 0.5 * || A(x) ||_2^2 \f$. The L2Reg should be used
      14             :      * if an L2Squared norm is not sufficient as an linear operator is necessary.
      15             :      *
      16             :      * Note, that the proximal operator is not analytically computable in this case.
      17             :      *
      18             :      * @tparam data_t data type for the domain of the residual of the functional, defaulting to
      19             :      * real_t
      20             :      *
      21             :      * @see L2Squared
      22             :      */
      23             :     template <typename data_t = real_t>
      24             :     class L2Reg : public Functional<data_t>
      25             :     {
      26             :     public:
      27             :         /**
      28             :          * @brief Constructor the l2 regularization functional without data and linear operator,
      29             :          * i.e. \f$A = I\f$ and \f$b = 0\f$.
      30             :          *
      31             :          * @param[in] domainDescriptor describing the domain of the functional
      32             :          */
      33             :         explicit L2Reg(const DataDescriptor& domain);
      34             : 
      35             :         /**
      36             :          * @brief Constructor the l2 regularization functional with an linear operator
      37             :          *
      38             :          * @param[in] A linear operator to be used
      39             :          */
      40             :         explicit L2Reg(const LinearOperator<data_t>& A);
      41             : 
      42             :         /// make copy constructor deletion explicit
      43             :         L2Reg(const L2Reg<data_t>&) = delete;
      44             : 
      45             :         /// default destructor
      46          48 :         ~L2Reg() override = default;
      47             : 
      48             :         bool hasOperator() const;
      49             : 
      50             :         const LinearOperator<data_t>& getOperator() const;
      51             : 
      52             :         bool isDifferentiable() const override;
      53             : 
      54             :     protected:
      55             :         /// the evaluation of the l2 norm (squared)
      56             :         data_t evaluateImpl(const DataContainer<data_t>& Rx) const override;
      57             : 
      58             :         /// the computation of the gradient (in place)
      59             :         void getGradientImpl(const DataContainer<data_t>& Rx,
      60             :                              DataContainer<data_t>& out) const override;
      61             : 
      62             :         /// the computation of the Hessian
      63             :         LinearOperator<data_t> getHessianImpl(const DataContainer<data_t>& Rx) const override;
      64             : 
      65             :         /// implement the polymorphic clone operation
      66             :         L2Reg<data_t>* cloneImpl() const override;
      67             : 
      68             :         /// implement the polymorphic comparison operation
      69             :         bool isEqual(const Functional<data_t>& other) const override;
      70             : 
      71             :     private:
      72             :         std::unique_ptr<LinearOperator<data_t>> A_{};
      73             :     };
      74             : 
      75             : } // namespace elsa

Generated by: LCOV version 1.14