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