Line data Source code
1 : #pragma once 2 : 3 : #include "Dictionary.h" 4 : #include "Problem.h" 5 : #include "LinearResidual.h" 6 : #include "L2NormPow2.h" 7 : #include <memory> 8 : 9 : namespace elsa 10 : { 11 : /** 12 : * @brief Class representing a sparse representation problem. 13 : * 14 : * @author Jonas Buerger - initial code 15 : * 16 : * @tparam data_t data type for the domain and range of the problem, defaulting to real_t 17 : * 18 : * This class represents a sparse representation problem, i.e. 19 : * \f$ \min_x \| x \|_0 \f$, s.t. \f$ \| y - Dx \|_2^2 < \epsilon \f$, where \f$ D \f$ is a 20 : * dictionary operator, \f$ y \f$ is the signal that should be represented, \f$ x \f$ is the 21 : * sparse representation vector and \f$ \epsilon \f$ is some error bound. 22 : * The sparsity condition \f$ \min_x \|\| x \|\|_0 \f$ is not inforced by the class but handled 23 : * implicitly, either by using a greedy algorithm that starts with the 0-vector as a 24 : * representation or by creating another problem that explicitly takes sparsity into account and 25 : * relaxes the L0-Norm to the L1-Norm. 26 : */ 27 : template <typename data_t = real_t> 28 : class RepresentationProblem : public Problem<data_t> 29 : { 30 : public: 31 : /** 32 : * @brief Constructor for the representation problem, accepting D and y 33 : * 34 : * @param[in] D dictionary operator 35 : * @param[in] y signal that should be sparsely represented 36 : */ 37 : RepresentationProblem(const Dictionary<data_t>& D, const DataContainer<data_t>& y); 38 : 39 : /// default destructor 40 0 : ~RepresentationProblem() override = default; 41 : 42 : const Dictionary<data_t>& getDictionary() const; 43 : 44 : const DataContainer<data_t>& getSignal() const; 45 : 46 : protected: 47 : /// implement the polymorphic clone operation 48 : RepresentationProblem<data_t>* cloneImpl() const override; 49 : 50 : /// override getGradient and throw exception if called because L0-Norm, even though only 51 : /// enforced implicitly, is not differtiable 52 : void getGradientImpl(DataContainer<data_t>& result) override; 53 : 54 : private: 55 : std::unique_ptr<const Dictionary<data_t>> _dict; 56 : DataContainer<data_t> _signal; 57 : }; 58 : } // namespace elsa