Package fuzzy :: Package norm :: Module HamacherSum
[hide private]
[frames] | no frames]

Source Code for Module fuzzy.norm.HamacherSum

 1  # -*- coding: utf-8 -*- 
 2  # 
 3  # Copyright (C) 2009  Rene Liebscher 
 4  # 
 5  # This program is free software; you can redistribute it and/or modify it under 
 6  # the terms of the GNU Lesser General Public License as published by the Free  
 7  # Software Foundation; either version 3 of the License, or (at your option) any 
 8  # later version. 
 9  # 
10  # This program is distributed in the hope that it will be useful, but WITHOUT  
11  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
12  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 
13  # details. 
14  #  
15  # You should have received a copy of the GNU Lesser General Public License 
16  # along with this program; if not, see <http://www.gnu.org/licenses/>.  
17  # 
18   
19  __revision__ = "$Id: HamacherSum.py,v 1.7 2009-10-27 20:06:27 rliebscher Exp $" 
20   
21  from fuzzy.norm.Norm import Norm 
22   
23 -class HamacherSum(Norm):
24
25 - def __init__(self):
26 super(HamacherSum, self).__init__(Norm.S_NORM)
27
28 - def __call__(self, *args):
29 x, y = self.checkArgs2(args) 30 if x*y == 1.: 31 return 1. 32 return (x+y-2.0*x*y)/(1.0-x*y)
33