endomorphic_operator.py 2.86 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Theo Steininger's avatar
Theo Steininger committed
13
14
15
16
17
#
# Copyright(C) 2013-2017 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
18
19
20

import abc

Martin Reinecke's avatar
Martin Reinecke committed
21
from ..linear_operator import LinearOperator
22
23
24


class EndomorphicOperator(LinearOperator):
Theo Steininger's avatar
Theo Steininger committed
25
    """ NIFTY class for endomorphic operators.
26

27
    The  NIFTY EndomorphicOperator class is a class derived from the
Theo Steininger's avatar
Theo Steininger committed
28
29
    LinearOperator. By definition, domain and target are the same in
    EndomorphicOperator.
30
31
32

    Attributes
    ----------
Theo Steininger's avatar
Theo Steininger committed
33
34
35
36
37
    domain : tuple of DomainObjects, i.e. Spaces and FieldTypes
        The domain on which the Operator's input Field lives.
    target : tuple of DomainObjects, i.e. Spaces and FieldTypes
        The domain in which the outcome of the operator lives. As the Operator
        is endomorphic this is the same as its domain.
38
39
    unitary : boolean
        Indicates whether the Operator is unitary or not.
40
    self_adjoint : boolean
41
        Indicates whether the operator is self_adjoint or not.
42
43
44
45
46
47
48
49
50

    Raises
    ------
    NotImplementedError
        Raised if
            * self_adjoint is not defined

    """

51
52
    # ---Overwritten properties and methods---

53
    def inverse_times(self, x):
Martin Reinecke's avatar
Martin Reinecke committed
54
        if self.self_adjoint and self.unitary:
55
            return self.times(x)
56
        else:
57
            return super(EndomorphicOperator, self).inverse_times(x)
58

59
    def adjoint_times(self, x):
Martin Reinecke's avatar
Martin Reinecke committed
60
        if self.self_adjoint:
61
            return self.times(x)
62
        else:
63
            return super(EndomorphicOperator, self).adjoint_times(x)
64

65
    def adjoint_inverse_times(self, x):
Martin Reinecke's avatar
Martin Reinecke committed
66
        if self.self_adjoint:
67
            return self.inverse_times(x)
68
        else:
69
            return super(EndomorphicOperator, self).adjoint_inverse_times(x)
70

71
    def inverse_adjoint_times(self, x):
Martin Reinecke's avatar
Martin Reinecke committed
72
        if self.self_adjoint:
73
            return self.inverse_times(x)
74
        else:
75
            return super(EndomorphicOperator, self).inverse_adjoint_times(x)
76
77
78
79
80
81
82
83
84
85

    # ---Mandatory properties and methods---

    @property
    def target(self):
        return self.domain

    # ---Added properties and methods---

    @abc.abstractproperty
Martin Reinecke's avatar
Martin Reinecke committed
86
    def self_adjoint(self):
Theo Steininger's avatar
Theo Steininger committed
87
        """ States whether the Operator is self_adjoint or not.
88
        """
Theo Steininger's avatar
Theo Steininger committed
89

90
        raise NotImplementedError