Line data Source code
1 : #pragma once 2 : 3 : #include "LinearOperator.h" 4 : #include "Scaling.h" 5 : 6 : namespace elsa 7 : { 8 : /** 9 : * @brief Class representing a Jacobi Preconditioner 10 : * 11 : * @author Michael Loipführer - initial code 12 : * 13 : * @tparam data_t data type for the domain and range of the problem, defaulting to real_t 14 : * 15 : * This class represents a Jacobi Precontion Operator for a given LinearOperator. 16 : */ 17 : template <typename data_t = real_t> 18 : class JacobiPreconditioner : public LinearOperator<data_t> 19 : { 20 : public: 21 : /** 22 : * @brief Constructor for a Jacobi Preconditioner 23 : * 24 : * @param[in] op the LinearOperator for which to compute a Jacobi Preconditioner for 25 : * each subset 26 : * @param[in] inverse whether or not to invert the computed preconditioner 27 : */ 28 : JacobiPreconditioner(const LinearOperator<data_t>& op, bool inverse); 29 : 30 : /// default destructor 31 18 : ~JacobiPreconditioner() override = default; 32 : 33 : protected: 34 : /// protected copy constructor; used for cloning 35 : JacobiPreconditioner(const JacobiPreconditioner& other); 36 : 37 : /// implement the polymorphic clone operation 38 : JacobiPreconditioner<data_t>* cloneImpl() const override; 39 : 40 : /// implement the polymorphic comparison operation 41 : bool isEqual(const LinearOperator<data_t>& other) const override; 42 : 43 : /// apply the block linear operator 44 : void applyImpl(const DataContainer<data_t>& x, DataContainer<data_t>& Ax) const override; 45 : 46 : /// apply the adjoint of the block linear operator 47 : void applyAdjointImpl(const DataContainer<data_t>& y, 48 : DataContainer<data_t>& Aty) const override; 49 : 50 : private: 51 : /// the actual inverse diagonal representing a Jacobi Preconditioner for the given problem 52 : Scaling<data_t> _inverseDiagonal; 53 : 54 : /// lift from base class 55 : using LinearOperator<data_t>::_domainDescriptor; 56 : using LinearOperator<data_t>::_rangeDescriptor; 57 : 58 : /// utility to get the diagonal of a linear operator 59 : static DataContainer<data_t> diagonalFromOperator(const LinearOperator<data_t>& op); 60 : }; 61 : 62 : } // namespace elsa