Line data Source code
1 : #pragma once 2 : 3 : #include "DataContainer.h" 4 : #include "Functional.h" 5 : #include "Scaling.h" 6 : 7 : namespace elsa 8 : { 9 : /** 10 : * @brief Class representing a weighted, squared l2 norm functional. 11 : * 12 : * The weighted, squared l2 norm functional evaluates to \f$ 0.5 * \| x \|_{W,2} = 0.5 * \langle 13 : * x, Wx \rangle \f$ using the standard scalar product, and where W is a diagonal scaling 14 : * operator. 15 : * 16 : * @tparam data_t data type for the domain of the functional, defaulting to real_t 17 : * 18 : * @author 19 : * * Matthias Wieczorek - initial code 20 : * * Maximilian Hornung - modularization 21 : * * Tobias Lasser - modernization 22 : */ 23 : template <typename data_t = real_t> 24 : class WeightedL2Squared : public Functional<data_t> 25 : { 26 : public: 27 : /** 28 : * @brief Constructor for the weighted, squared l2 norm, mapping domain vector to a scalar 29 : * (without a residual) 30 : * 31 : * @param[in] weightingOp diagonal scaling operator used for weights 32 : */ 33 : explicit WeightedL2Squared(const DataContainer<data_t>& weights); 34 : 35 : /// make copy constructor deletion explicit 36 : WeightedL2Squared(const WeightedL2Squared<data_t>&) = delete; 37 : 38 : /// default destructor 39 24 : ~WeightedL2Squared() override = default; 40 : 41 : bool isDifferentiable() const override; 42 : 43 : /// returns the weighting operator 44 : Scaling<data_t> getWeightingOperator() const; 45 : 46 : protected: 47 : /// the evaluation of the weighted, squared l2 norm 48 : data_t evaluateImpl(const DataContainer<data_t>& Rx) const override; 49 : 50 : /// the computation of the gradient (in place) 51 : void getGradientImpl(const DataContainer<data_t>& Rx, 52 : DataContainer<data_t>& out) const override; 53 : 54 : /// the computation of the Hessian 55 : LinearOperator<data_t> getHessianImpl(const DataContainer<data_t>& Rx) const override; 56 : 57 : /// implement the polymorphic clone operation 58 : WeightedL2Squared<data_t>* cloneImpl() const override; 59 : 60 : /// implement the polymorphic comparison operation 61 : bool isEqual(const Functional<data_t>& other) const override; 62 : 63 : private: 64 : /// the weighting operator 65 : DataContainer<data_t> weights_; 66 : }; 67 : 68 : } // namespace elsa