Line data Source code
1 : #pragma once 2 : 3 : #include "DataContainer.h" 4 : #include "Functional.h" 5 : 6 : namespace elsa 7 : { 8 : /** 9 : * @brief Class representing the Pseudohuber norm. 10 : * 11 : * @author Matthias Wieczorek - initial code 12 : * @author Maximilian Hornung - modularization 13 : * @author Tobias Lasser - modernization, fixes 14 : * 15 : * @tparam data_t data type for the domain of the residual of the functional, defaulting to 16 : * real_t 17 : * 18 : * The Pseudohuber norm evaluates to \f$ \sum_{i=1}^n \delta \left( \sqrt{1 + (x_i / \delta)^2} 19 : * - 1 \right) \f$ for \f$ x=(x_i)_{i=1}^n \f$ and a slope parameter \f$ \delta \f$. 20 : * 21 : * Reference: https://doi.org/10.1109%2F83.551699 22 : */ 23 : template <typename data_t = real_t> 24 : class PseudoHuber : public Functional<data_t> 25 : { 26 : public: 27 : /** 28 : * @brief Constructor for the Pseudohuber functional, mapping domain vector to scalar 29 : * (without a residual) 30 : * 31 : * @param[in] domainDescriptor describing the domain of the functional 32 : * @param[in] delta parameter for linear slope (defaults to 1) 33 : */ 34 : explicit PseudoHuber(const DataDescriptor& domainDescriptor, 35 : real_t delta = static_cast<real_t>(1)); 36 : 37 : /// make copy constructor deletion explicit 38 : PseudoHuber(const PseudoHuber<data_t>&) = delete; 39 : 40 : /// default destructor 41 8 : ~PseudoHuber() override = default; 42 : 43 : bool isDifferentiable() const override; 44 : 45 : protected: 46 : /// the evaluation of the Huber norm 47 : data_t evaluateImpl(const DataContainer<data_t>& Rx) const override; 48 : 49 : /// the computation of the gradient (in place) 50 : void getGradientImpl(const DataContainer<data_t>& Rx, 51 : DataContainer<data_t>& out) const override; 52 : 53 : /// the computation of the Hessian 54 : LinearOperator<data_t> getHessianImpl(const DataContainer<data_t>& Rx) const override; 55 : 56 : /// implement the polymorphic clone operation 57 : PseudoHuber<data_t>* cloneImpl() const override; 58 : 59 : /// implement the polymorphic comparison operation 60 : bool isEqual(const Functional<data_t>& other) const override; 61 : 62 : private: 63 : /// the slope delta 64 : data_t delta_; 65 : }; 66 : 67 : } // namespace elsa