00001 __copyright__ = """
00002 Copyright 2008 Sean Ross-Ross
00003 """
00004 __license__ = """
00005 This file is part of SLIMpy .
00006
00007 SLIMpy is free software: you can redistribute it and/or modify
00008 it under the terms of the GNU Lesser General Public License as published by
00009 the Free Software Foundation, either version 3 of the License, or
00010 (at your option) any later version.
00011
00012 SLIMpy is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015 GNU Lesser General Public License for more details.
00016
00017 You should have received a copy of the GNU Lesser General Public License
00018 along with SLIMpy . If not, see <http://www.gnu.org/licenses/>.
00019 """
00020
00021 from slimpy_base.Core.User.linop.linear_operator import LinearOperator
00022 from slimpy_base.Core.User.Structures.VectorSpace import VectorAddition
00023
00024
00025
00026 class ArithmaticOperator( LinearOperator ):
00027 """
00028 ArithmaticOperator( '-', I, T ) * x <-> (I - T) *x
00029 """
00030
00031
00032
00033
00034
00035 def __init__(self, arithop, oper1, oper2):
00036 self.oper1 = oper1
00037 self.oper2 = oper2
00038 self.arithop = arithop
00039
00040 domain = VectorAddition( [self.oper1.domain() ,self.oper2.domain()] )
00041 range = VectorAddition( [self.oper1.range() ,self.oper2.range()] )
00042 LinearOperator.__init__( self, domain, range )
00043
00044 def __str__(self):
00045 return "( %(oper1)s %(arithop)s %(oper2)s )" %self.__dict__
00046
00047
00048 def applyop(self,other):
00049 """
00050 A.applyop(other) -> vector
00051 """
00052 res1 = self.oper1 * other
00053 res2 = self.oper2 * other
00054
00055 if self.arithop == '+':
00056 res = res1 + res2
00057
00058 elif self.arithop == '-':
00059 res = res1 - res2
00060
00061 return res
00062