endomorphic_operator.py 3.03 KB
 theos committed Aug 22, 2016 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 ``````# -*- coding: utf-8 -*- import abc from nifty.operators.linear_operator import LinearOperator class EndomorphicOperator(LinearOperator): __metaclass__ = abc.ABCMeta # ---Overwritten properties and methods--- def inverse_times(self, x, spaces=None, types=None): if self.paradict['symmetric'] and self.paradict['unitary']: return self.times(x, spaces, types) else: return super(EndomorphicOperator, self).inverse_times( x=x, spaces=spaces, types=types) def adjoint_times(self, x, spaces=None, types=None): if self.paradict['symmetric']: return self.times(x, spaces, types) elif self.paradict['unitary']: return self.inverse_times(x, spaces, types) else: return super(EndomorphicOperator, self).adjoint_times( x=x, spaces=spaces, types=types) def adjoint_inverse_times(self, x, spaces=None, types=None): if self.paradict['symmetric']: return self.inverse_times(x, spaces, types) elif self.paradict['unitary']: return self.times(x, spaces, types) else: return super(EndomorphicOperator, self).adjoint_inverse_times( x=x, spaces=spaces, types=types) def inverse_adjoint_times(self, x, spaces=None, types=None): if self.paradict['symmetric']: return self.inverse_times(x, spaces, types) elif self.paradict['unitary']: return self.times(x, spaces, types) else: return super(EndomorphicOperator, self).inverse_adjoint_times( x=x, spaces=spaces, types=types) # ---Mandatory properties and methods--- @property def target(self): return self.domain @property def field_type_target(self): return self.field_type # ---Added properties and methods--- @abc.abstractproperty def symmetric(self): raise NotImplementedError @abc.abstractproperty def unitary(self): raise NotImplementedError def trace(self): pass def inverse_trace(self): pass def diagonal(self): pass def inverse_diagonal(self): pass def determinant(self): pass def inverse_determinant(self): pass def log_determinant(self): pass def trace_log(self): pass``````