endomorphic_operator.py 3.74 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# NIFTy
# Copyright (C) 2017  Theo Steininger
#
# Author: Theo Steininger
#
# 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/>.
18
19
20
21
22
23
24

import abc

from nifty.operators.linear_operator import LinearOperator


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

    Parameters
    ----------
33
34
35
    default_spaces : tuple of ints *optional*
        Defines on which space(s) of a given field the Operator acts by
        default (default: None)
36
37
38

    Attributes
    ----------
Theo Steininger's avatar
Theo Steininger committed
39
40
41
42
43
    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.
44
45
    unitary : boolean
        Indicates whether the Operator is unitary or not.
46
    self_adjoint : boolean
47
        Indicates whether the operator is self_adjoint or not.
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

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

    Notes
    -----

    Examples
    --------


    See Also
    --------
    DiagonalOperator, SmoothingOperator,
65
    PropagatorOperator, ProjectionOperator
66
67
68

    """

69
70
    # ---Overwritten properties and methods---

71
    def inverse_times(self, x, spaces=None):
Martin Reinecke's avatar
Martin Reinecke committed
72
        if self.self_adjoint and self.unitary:
73
            return self.times(x, spaces)
74
75
76
        else:
            return super(EndomorphicOperator, self).inverse_times(
                                                              x=x,
77
                                                              spaces=spaces)
78

79
    def adjoint_times(self, x, spaces=None):
Martin Reinecke's avatar
Martin Reinecke committed
80
        if self.self_adjoint:
81
            return self.times(x, spaces)
82
83
84
        else:
            return super(EndomorphicOperator, self).adjoint_times(
                                                                x=x,
85
                                                                spaces=spaces)
86

87
    def adjoint_inverse_times(self, x, spaces=None):
Martin Reinecke's avatar
Martin Reinecke committed
88
        if self.self_adjoint:
89
            return self.inverse_times(x, spaces)
90
91
92
        else:
            return super(EndomorphicOperator, self).adjoint_inverse_times(
                                                                x=x,
93
                                                                spaces=spaces)
94

95
    def inverse_adjoint_times(self, x, spaces=None):
Martin Reinecke's avatar
Martin Reinecke committed
96
        if self.self_adjoint:
97
            return self.inverse_times(x, spaces)
98
99
100
        else:
            return super(EndomorphicOperator, self).inverse_adjoint_times(
                                                                x=x,
101
                                                                spaces=spaces)
102
103
104
105
106
107
108
109
110
111

    # ---Mandatory properties and methods---

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

    # ---Added properties and methods---

    @abc.abstractproperty
Martin Reinecke's avatar
Martin Reinecke committed
112
    def self_adjoint(self):
Theo Steininger's avatar
Theo Steininger committed
113
        """ States whether the Operator is self_adjoint or not.
114
        """
Theo Steininger's avatar
Theo Steininger committed
115

116
        raise NotImplementedError