Author: bugman Date: Mon Aug 9 10:39:16 2010 New Revision: 11439 URL: http://svn.gna.org/viewcvs/relax?rev=11439&view=rev Log: Implemented the sinc() function. Modified: 1.3/maths_fns/pseudo_ellipse.py Modified: 1.3/maths_fns/pseudo_ellipse.py URL: http://svn.gna.org/viewcvs/relax/1.3/maths_fns/pseudo_ellipse.py?rev=11439&r1=11438&r2=11439&view=diff ============================================================================== --- 1.3/maths_fns/pseudo_ellipse.py (original) +++ 1.3/maths_fns/pseudo_ellipse.py Mon Aug 9 10:39:16 2010 @@ -24,7 +24,7 @@ """Module for the pseudo-elliptical functions.""" # Python module import. -from math import pi +from math import pi, sin def factorial(n): @@ -204,3 +204,28 @@ # Return the approximate function value. return fn + + +def sinc(x): + """Implementation of the sinc() function. + + The formula is:: + + / 1, for x = 0, + sinc(x) = < + \ sin(x)/x, otherwise. + + + @param x: The angle x in rad. + @type x: float + @return: The value of sinc(x). + @rtype: float + """ + + # Limit condition. + if x == 0: + return 1.0 + + # All other values. + else: + return sin(x) / x