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