-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction_library.py
54 lines (38 loc) · 1.27 KB
/
function_library.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# This file is part of the UFO.
#
# This file contains definitions for functions that
# are extensions of the cmath library, and correspond
# either to functions that are in cmath, but inconvenient
# to access from there (e.g. z.conjugate()),
# or functions that are simply not defined.
#
#
__date__ = "22 July 2010"
__author__ = "[email protected]"
import cmath
from object_library import all_functions, Function
#
# shortcuts for functions from cmath
#
complexconjugate = Function(name = 'complexconjugate',
arguments = ('z',),
expression = 'z.conjugate()')
re = Function(name = 're',
arguments = ('z',),
expression = 'z.real')
im = Function(name = 'im',
arguments = ('z',),
expression = 'z.imag')
# New functions (trigonometric)
sec = Function(name = 'sec',
arguments = ('z',),
expression = '1./cmath.cos(z)')
asec = Function(name = 'asec',
arguments = ('z',),
expression = 'cmath.acos(1./z)')
csc = Function(name = 'csc',
arguments = ('z',),
expression = '1./cmath.sin(z)')
acsc = Function(name = 'acsc',
arguments = ('z',),
expression = 'cmath.asin(1./z)')