Identity.h 2.06 KB
Newer Older
Tobias Lasser's avatar
Tobias Lasser committed
1
2
3
4
5
6
7
8
9
10
11
12
#pragma once

#include "LinearOperator.h"

namespace elsa
{
    /**
     * \brief Operator representing the identity operation.
     *
     * \author Matthias Wieczorek - initial code
     * \author Tobias Lasser - modularization, rewrite
     *
13
14
     * \tparam data_t data type for the domain and range of the operator, defaulting to real_t
     *
Tobias Lasser's avatar
Tobias Lasser committed
15
16
     * This class represents a linear operator A that is the identity, i.e. Ax = x.
     */
Jens Petit's avatar
Jens Petit committed
17
18
19
20
21
22
23
24
25
26
    template <typename data_t = real_t>
    class Identity : public LinearOperator<data_t>
    {
    public:
        /**
         * \brief Constructor for the identity operator, specifying the domain (= range).
         *
         * \param[in] descriptor DataDescriptor describing the domain and range of the operator
         */
        explicit Identity(const DataDescriptor& descriptor);
Tobias Lasser's avatar
Tobias Lasser committed
27

Jens Petit's avatar
Jens Petit committed
28
29
        /// default destructor
        ~Identity() override = default;
Tobias Lasser's avatar
Tobias Lasser committed
30

Jens Petit's avatar
Jens Petit committed
31
    protected:
32
33
34
        /// default copy constructor, hidden from non-derived classes to prevent potential slicing
        Identity(const Identity<data_t>&) = default;

Jens Petit's avatar
Jens Petit committed
35
36
37
38
39
40
        /**
         * \brief apply the identity operator A to x, i.e. Ax = x
         *
         * \param[in] x input DataContainer (in the domain of the operator)
         * \param[out] Ax output DataContainer (in the range of the operator)
         */
41
        void applyImpl(const DataContainer<data_t>& x, DataContainer<data_t>& Ax) const override;
Tobias Lasser's avatar
Tobias Lasser committed
42

Jens Petit's avatar
Jens Petit committed
43
44
45
46
47
48
        /**
         * \brief apply the adjoint of the identity operator A to y, i.e. A^ty = y
         *
         * \param[in] y input DataContainer (in the range of the operator)
         * \param[out] Aty output DataContainer (in the domain of the operator)
         */
49
50
        void applyAdjointImpl(const DataContainer<data_t>& y,
                              DataContainer<data_t>& Aty) const override;
Tobias Lasser's avatar
Tobias Lasser committed
51

Jens Petit's avatar
Jens Petit committed
52
53
        /// implement the polymorphic clone operation
        Identity<data_t>* cloneImpl() const override;
Tobias Lasser's avatar
Tobias Lasser committed
54

Jens Petit's avatar
Jens Petit committed
55
56
57
        /// implement the polymorphic comparison operation
        bool isEqual(const LinearOperator<data_t>& other) const override;
    };
Tobias Lasser's avatar
Tobias Lasser committed
58
} // namespace elsa