endomorphic_operator.py 2.5 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
25
26
27

import abc

from nifty.operators.linear_operator import LinearOperator


class EndomorphicOperator(LinearOperator):

    # ---Overwritten properties and methods---

28
    def inverse_times(self, x, spaces=None):
Martin Reinecke's avatar
Martin Reinecke committed
29
        if self.self_adjoint and self.unitary:
30
            return self.times(x, spaces)
31
32
33
        else:
            return super(EndomorphicOperator, self).inverse_times(
                                                              x=x,
34
                                                              spaces=spaces)
35

36
    def adjoint_times(self, x, spaces=None):
Martin Reinecke's avatar
Martin Reinecke committed
37
        if self.self_adjoint:
38
            return self.times(x, spaces)
39
40
41
        else:
            return super(EndomorphicOperator, self).adjoint_times(
                                                                x=x,
42
                                                                spaces=spaces)
43

44
    def adjoint_inverse_times(self, x, spaces=None):
Martin Reinecke's avatar
Martin Reinecke committed
45
        if self.self_adjoint:
46
            return self.inverse_times(x, spaces)
47
48
49
        else:
            return super(EndomorphicOperator, self).adjoint_inverse_times(
                                                                x=x,
50
                                                                spaces=spaces)
51

52
    def inverse_adjoint_times(self, x, spaces=None):
Martin Reinecke's avatar
Martin Reinecke committed
53
        if self.self_adjoint:
54
            return self.inverse_times(x, spaces)
55
56
57
        else:
            return super(EndomorphicOperator, self).inverse_adjoint_times(
                                                                x=x,
58
                                                                spaces=spaces)
59
60
61
62
63
64
65
66
67
68

    # ---Mandatory properties and methods---

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

    # ---Added properties and methods---

    @abc.abstractproperty
Martin Reinecke's avatar
Martin Reinecke committed
69
    def self_adjoint(self):
70
        raise NotImplementedError