Line data Source code
1 : #pragma once 2 : 3 : #include "DataDescriptor.h" 4 : #include "LinearOperator.h" 5 : 6 : namespace elsa 7 : { 8 : /** 9 : * @brief Operator representing the block diagonal operator. 10 : * 11 : * This class represents a class of the form: 12 : * @f[ 13 : * A = \begin{bmatrix} 14 : * A_1 & & \\ 15 : * & \ddots & \\ 16 : * & & A_n 17 : * \end{bmatrix} 18 : * @f] 19 : * where @f$n@f$ operators are used in the diagonal of the operator. 20 : * 21 : * @tparam data_t data type for the domain and range of the operator, defaulting to real_t 22 : */ 23 : template <typename data_t = real_t> 24 : class Diagonal : public LinearOperator<data_t> 25 : { 26 : public: 27 : using OperatorList = typename std::vector<std::unique_ptr<LinearOperator<data_t>>>; 28 : /** 29 : * @brief Constructor for the block diagional operator, specifying the domain (= range). 30 : * 31 : * @param[in] descriptor DataDescriptor describing the domain and range of the operator 32 : */ 33 : Diagonal(const DataDescriptor& domain, const DataDescriptor& range, 34 : const OperatorList& ops); 35 : 36 : /// default destructor 37 2 : ~Diagonal() override = default; 38 : 39 : protected: 40 : /// default copy constructor, hidden from non-derived classes to prevent potential slicing 41 : Diagonal(const Diagonal<data_t>&) = default; 42 : 43 : /** 44 : * @brief apply the block diagional operator 45 : * 46 : * @param[in] x input DataContainer (in the domain of the operator) 47 : * @param[out] Ax output DataContainer (in the range of the operator) 48 : */ 49 : void applyImpl(const DataContainer<data_t>& x, DataContainer<data_t>& Ax) const override; 50 : 51 : /** 52 : * @brief apply the adjoint of the block diagional operator 53 : * 54 : * @param[in] y input DataContainer (in the range of the operator) 55 : * @param[out] Aty output DataContainer (in the domain of the operator) 56 : */ 57 : void applyAdjointImpl(const DataContainer<data_t>& y, 58 : DataContainer<data_t>& Aty) const override; 59 : 60 : /// implement the polymorphic clone operation 61 : Diagonal<data_t>* cloneImpl() const override; 62 : 63 : /// implement the polymorphic comparison operation 64 : bool isEqual(const LinearOperator<data_t>& other) const override; 65 : 66 : private: 67 : OperatorList ops_; 68 : }; 69 : } // namespace elsa