Line data Source code
1 : #pragma once 2 : 3 : #include "Functional.h" 4 : 5 : namespace elsa 6 : { 7 : /** 8 : * @brief Class representing the maximum norm functional (l infinity). 9 : * 10 : * @author Matthias Wieczorek - initial code 11 : * @author Maximilian Hornung - modularization 12 : * @author Tobias Lasser - modernization 13 : * 14 : * @tparam data_t data type for the domain of the residual of the functional, defaulting to 15 : * real_t 16 : * 17 : * The linf / max norm functional evaluates to \f$ \max_{i=1,\ldots,n} |x_i| \f$ for \f$ 18 : * x=(x_i)_{i=1}^n \f$. Please note that it is not differentiable, hence getGradient and 19 : * getHessian will throw exceptions. 20 : */ 21 : template <typename data_t = real_t> 22 : class LInfNorm : public Functional<data_t> 23 : { 24 : public: 25 : /** 26 : * @brief Constructor for the linf norm functional, mapping domain vector to scalar (without 27 : * a residual) 28 : * 29 : * @param[in] domainDescriptor describing the domain of the functional 30 : */ 31 : explicit LInfNorm(const DataDescriptor& domainDescriptor); 32 : 33 : /** 34 : * @brief Constructor for the linf norm functional, using a residual as input to map to a 35 : * scalar 36 : * 37 : * @param[in] residual to be used when evaluating the functional (or its derivative) 38 : */ 39 : explicit LInfNorm(const Residual<data_t>& residual); 40 : 41 : /// make copy constructor deletion explicit 42 : LInfNorm(const LInfNorm<data_t>&) = delete; 43 : 44 : /// default destructor 45 32 : ~LInfNorm() override = default; 46 : 47 : protected: 48 : /// the evaluation of the linf norm 49 : data_t evaluateImpl(const DataContainer<data_t>& Rx) override; 50 : 51 : /// the computation of the gradient (in place) 52 : void getGradientInPlaceImpl(DataContainer<data_t>& Rx) override; 53 : 54 : /// the computation of the Hessian 55 : LinearOperator<data_t> getHessianImpl(const DataContainer<data_t>& Rx) override; 56 : 57 : /// implement the polymorphic clone operation 58 : LInfNorm<data_t>* cloneImpl() const override; 59 : 60 : /// implement the polymorphic comparison operation 61 : bool isEqual(const Functional<data_t>& other) const override; 62 : }; 63 : 64 : } // namespace elsa