Line data Source code
1 : #pragma once 2 : 3 : #include "LinearOperator.h" 4 : 5 : namespace elsa 6 : { 7 : /** 8 : * @brief Operator representing the identity operation. 9 : * 10 : * @author Matthias Wieczorek - initial code 11 : * @author Tobias Lasser - modularization, rewrite 12 : * 13 : * @tparam data_t data type for the domain and range of the operator, defaulting to real_t 14 : * 15 : * This class represents a linear operator A that is the identity, i.e. Ax = x. 16 : */ 17 : template <typename data_t = real_t> 18 : class Identity : public LinearOperator<data_t> 19 : { 20 : public: 21 : /** 22 : * @brief Constructor for the identity operator, specifying the domain (= range). 23 : * 24 : * @param[in] descriptor DataDescriptor describing the domain and range of the operator 25 : */ 26 : explicit Identity(const DataDescriptor& descriptor); 27 : 28 : /// default destructor 29 1834 : ~Identity() override = default; 30 : 31 : protected: 32 : /// default copy constructor, hidden from non-derived classes to prevent potential slicing 33 : Identity(const Identity<data_t>&) = default; 34 : 35 : /** 36 : * @brief apply the identity operator A to x, i.e. Ax = x 37 : * 38 : * @param[in] x input DataContainer (in the domain of the operator) 39 : * @param[out] Ax output DataContainer (in the range of the operator) 40 : */ 41 : void applyImpl(const DataContainer<data_t>& x, DataContainer<data_t>& Ax) const override; 42 : 43 : /** 44 : * @brief apply the adjoint of the identity operator A to y, i.e. A^ty = y 45 : * 46 : * @param[in] y input DataContainer (in the range of the operator) 47 : * @param[out] Aty output DataContainer (in the domain of the operator) 48 : */ 49 : void applyAdjointImpl(const DataContainer<data_t>& y, 50 : DataContainer<data_t>& Aty) const override; 51 : 52 : /// implement the polymorphic clone operation 53 : Identity<data_t>* cloneImpl() const override; 54 : 55 : /// implement the polymorphic comparison operation 56 : bool isEqual(const LinearOperator<data_t>& other) const override; 57 : }; 58 : } // namespace elsa