Belle II Software  release-06-02-00
function_library.py
1 # This file is part of the UFO.
2 #
3 # This file contains definitions for functions that
4 # are extensions of the cmath library, and correspond
5 # either to functions that are in cmath, but inconvenient
6 # to access from there (e.g. z.conjugate()),
7 # or functions that are simply not defined.
8 #
9 #
10 
11 __date__ = "22 July 2010"
12 __author__ = "claude.duhr@durham.ac.uk"
13 
14 import cmath
15 from object_library import all_functions, Function
16 
17 #
18 # shortcuts for functions from cmath
19 #
20 
21 complexconjugate = Function(name = 'complexconjugate',
22  arguments = ('z',),
23  expression = 'z.conjugate()')
24 
25 
26 re = Function(name = 're',
27  arguments = ('z',),
28  expression = 'z.real')
29 
30 im = Function(name = 'im',
31  arguments = ('z',),
32  expression = 'z.imag')
33 
34 # New functions (trigonometric)
35 
36 sec = Function(name = 'sec',
37  arguments = ('z',),
38  expression = '1./cmath.cos(z)')
39 
40 asec = Function(name = 'asec',
41  arguments = ('z',),
42  expression = 'cmath.acos(1./z)')
43 
44 csc = Function(name = 'csc',
45  arguments = ('z',),
46  expression = '1./cmath.sin(z)')
47 
48 acsc = Function(name = 'acsc',
49  arguments = ('z',),
50  expression = 'cmath.asin(1./z)')
51 
52 cot = Function(name = 'cot',
53  arguments = ('z',),
54  expression = '1./cmath.tan(z)')
55 
56 # Heaviside theta function
57 
58 theta_function = Function(name = 'theta_function',
59  arguments = ('x','y','z'),
60  expression = 'y if x else z')
61 
62 # Auxiliary functions for NLO
63 
64 cond = Function(name = 'cond',
65  arguments = ('condition','ExprTrue','ExprFalse'),
66  expression = '(ExprTrue if condition==0.0 else ExprFalse)')
67 
68 reglog = Function(name = 'reglog',
69  arguments = ('z'),
70  expression = '(0.0 if z==0.0 else cmath.log(z))')
71