endomorphic_operator.py 1.82 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
# -*- coding: utf-8 -*-

import abc

from nifty.operators.linear_operator import LinearOperator


class EndomorphicOperator(LinearOperator):

    # ---Overwritten properties and methods---

12
    def inverse_times(self, x, spaces=None):
13
        if self.symmetric and self.unitary:
14
            return self.times(x, spaces)
15
16
17
        else:
            return super(EndomorphicOperator, self).inverse_times(
                                                              x=x,
18
                                                              spaces=spaces)
19

20
    def adjoint_times(self, x, spaces=None):
21
        if self.symmetric:
22
            return self.times(x, spaces)
23
24
25
        else:
            return super(EndomorphicOperator, self).adjoint_times(
                                                                x=x,
26
                                                                spaces=spaces)
27

28
    def adjoint_inverse_times(self, x, spaces=None):
29
        if self.symmetric:
30
            return self.inverse_times(x, spaces)
31
32
33
        else:
            return super(EndomorphicOperator, self).adjoint_inverse_times(
                                                                x=x,
34
                                                                spaces=spaces)
35

36
    def inverse_adjoint_times(self, x, spaces=None):
37
        if self.symmetric:
38
            return self.inverse_times(x, spaces)
39
40
41
        else:
            return super(EndomorphicOperator, self).inverse_adjoint_times(
                                                                x=x,
42
                                                                spaces=spaces)
43
44
45
46
47
48
49
50
51
52
53
54

    # ---Mandatory properties and methods---

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

    # ---Added properties and methods---

    @abc.abstractproperty
    def symmetric(self):
        raise NotImplementedError