Line data Source code
1 : #pragma once 2 : 3 : #include "ContiguousStorage.h" 4 : #include "DataDescriptor.h" 5 : #include "LinearOperator.h" 6 : #include "elsaDefines.h" 7 : #include <Eigen/src/Core/Map.h> 8 : #include <Eigen/src/Core/Matrix.h> 9 : #include <Eigen/src/Core/util/Constants.h> 10 : 11 : namespace elsa 12 : { 13 : /** 14 : */ 15 : template <typename data_t = real_t> 16 : class MatrixOperator : public LinearOperator<data_t> 17 : { 18 : public: 19 : /** 20 : * @brief Constructor for the identity operator, specifying the domain (= range). 21 : * 22 : * @param[in] descriptor DataDescriptor describing the domain and range of the operator 23 : */ 24 : explicit MatrixOperator(const Matrix_t<data_t>& mat); 25 : 26 : MatrixOperator(const DataDescriptor& domain, const DataDescriptor& range, 27 : const Matrix_t<data_t>& mat); 28 : 29 : /// default destructor 30 304 : ~MatrixOperator() override = default; 31 : 32 : protected: 33 : /// default copy constructor, hidden from non-derived classes to prevent potential slicing 34 : MatrixOperator(const MatrixOperator<data_t>&) = default; 35 : 36 : /** 37 : * @brief apply the identity operator A to x, i.e. Ax = x 38 : * 39 : * @param[in] x input DataContainer (in the domain of the operator) 40 : * @param[out] Ax output DataContainer (in the range of the operator) 41 : */ 42 : void applyImpl(const DataContainer<data_t>& x, DataContainer<data_t>& Ax) const override; 43 : 44 : /** 45 : * @brief apply the adjoint of the identity operator A to y, i.e. A^ty = y 46 : * 47 : * @param[in] y input DataContainer (in the range of the operator) 48 : * @param[out] Aty output DataContainer (in the domain of the operator) 49 : */ 50 : void applyAdjointImpl(const DataContainer<data_t>& y, 51 : DataContainer<data_t>& Aty) const override; 52 : 53 : /// implement the polymorphic clone operation 54 : MatrixOperator<data_t>* cloneImpl() const override; 55 : 56 : /// implement the polymorphic comparison operation 57 : bool isEqual(const LinearOperator<data_t>& other) const override; 58 : 59 : private: 60 : ContiguousStorage<data_t> storage_; 61 : 62 : Eigen::Map<Matrix_t<data_t>> mat_; 63 : }; 64 : } // namespace elsa