mathutilslib 0.0.1__tar.gz → 0.0.2a0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mathutilslib-0.0.2a0/PKG-INFO +5 -0
- mathutilslib-0.0.2a0/mathutilslib/__init__.py +120 -0
- mathutilslib-0.0.2a0/mathutilslib.egg-info/PKG-INFO +5 -0
- {mathutilslib-0.0.1 → mathutilslib-0.0.2a0}/pyproject.toml +3 -2
- mathutilslib-0.0.1/PKG-INFO +0 -4
- mathutilslib-0.0.1/mathutilslib/__init__.py +0 -13
- mathutilslib-0.0.1/mathutilslib.egg-info/PKG-INFO +0 -4
- {mathutilslib-0.0.1 → mathutilslib-0.0.2a0}/README.md +0 -0
- {mathutilslib-0.0.1 → mathutilslib-0.0.2a0}/mathutilslib.egg-info/SOURCES.txt +0 -0
- {mathutilslib-0.0.1 → mathutilslib-0.0.2a0}/mathutilslib.egg-info/dependency_links.txt +0 -0
- {mathutilslib-0.0.1 → mathutilslib-0.0.2a0}/mathutilslib.egg-info/top_level.txt +0 -0
- {mathutilslib-0.0.1 → mathutilslib-0.0.2a0}/setup.cfg +0 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
__version__ = "0.0.1"
|
|
2
|
+
|
|
3
|
+
def Unimplemented():
|
|
4
|
+
raise RuntimeError("Unimplemented yet!")
|
|
5
|
+
def factorial(n):
|
|
6
|
+
if n < 0:
|
|
7
|
+
raise ValueError("factorial is only defined for n >= 0")
|
|
8
|
+
|
|
9
|
+
result = 1
|
|
10
|
+
|
|
11
|
+
while n > 1:
|
|
12
|
+
result *= n
|
|
13
|
+
n -= 1
|
|
14
|
+
|
|
15
|
+
return result
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def double_factorial(n):
|
|
19
|
+
if n < 0:
|
|
20
|
+
raise ValueError("double factorial is only defined for n >= 0")
|
|
21
|
+
|
|
22
|
+
result = 1
|
|
23
|
+
|
|
24
|
+
while n > 1:
|
|
25
|
+
result *= n
|
|
26
|
+
n -= 2
|
|
27
|
+
|
|
28
|
+
return result
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def subfactorial(n):
|
|
32
|
+
if n < 0:
|
|
33
|
+
raise ValueError("subfactorial is only defined for n >= 0")
|
|
34
|
+
|
|
35
|
+
if n == 0:
|
|
36
|
+
return 1
|
|
37
|
+
|
|
38
|
+
if n == 1:
|
|
39
|
+
return 0
|
|
40
|
+
|
|
41
|
+
a = 1 # !0
|
|
42
|
+
b = 0 # !1
|
|
43
|
+
|
|
44
|
+
i = 2
|
|
45
|
+
|
|
46
|
+
while i <= n:
|
|
47
|
+
c = (i - 1) * (a + b)
|
|
48
|
+
a = b
|
|
49
|
+
b = c
|
|
50
|
+
i += 1
|
|
51
|
+
|
|
52
|
+
return b
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def tetration(a, n):
|
|
56
|
+
if n < 0:
|
|
57
|
+
raise ValueError("tetration height must be >= 0")
|
|
58
|
+
|
|
59
|
+
if n == 0:
|
|
60
|
+
return 1
|
|
61
|
+
|
|
62
|
+
result = a
|
|
63
|
+
|
|
64
|
+
i = 1
|
|
65
|
+
|
|
66
|
+
while i < n:
|
|
67
|
+
result = a ** result
|
|
68
|
+
i += 1
|
|
69
|
+
|
|
70
|
+
return result
|
|
71
|
+
|
|
72
|
+
def isNegative(a):
|
|
73
|
+
return a<0
|
|
74
|
+
|
|
75
|
+
def SwapPolarity(a):
|
|
76
|
+
return a*-1
|
|
77
|
+
|
|
78
|
+
def abs(a):
|
|
79
|
+
if a < 0:
|
|
80
|
+
return a*-1
|
|
81
|
+
return a
|
|
82
|
+
|
|
83
|
+
def DoNegative(a):
|
|
84
|
+
return eval("((a * -1) " + op + " b) * -1")
|
|
85
|
+
|
|
86
|
+
def DoNegativeFunc(a, f):
|
|
87
|
+
if isNegative(a):
|
|
88
|
+
return f(a*-1)*-1
|
|
89
|
+
return f(a)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def abs_add(a,b):
|
|
93
|
+
if a < 0:
|
|
94
|
+
return a - b
|
|
95
|
+
return a + b
|
|
96
|
+
|
|
97
|
+
def abs_sub(a,b):
|
|
98
|
+
if a < 0:
|
|
99
|
+
return a + b
|
|
100
|
+
return a - b
|
|
101
|
+
|
|
102
|
+
def abs_mul(a,b):
|
|
103
|
+
if a < 0:
|
|
104
|
+
return ((a*-1)*b)*-1
|
|
105
|
+
return a*b
|
|
106
|
+
|
|
107
|
+
def abs_div(a,b):
|
|
108
|
+
if isNegative(a):
|
|
109
|
+
return ((a*-1)*b)*-1
|
|
110
|
+
return a/b
|
|
111
|
+
|
|
112
|
+
def abs_pow(a,b):
|
|
113
|
+
if isNegative(a):
|
|
114
|
+
return DoNegative(a,b,"**")
|
|
115
|
+
return a**b
|
|
116
|
+
|
|
117
|
+
def abs_factorial(a):
|
|
118
|
+
if isNegative(a):
|
|
119
|
+
return DoNegativeFunc(a, factorial)
|
|
120
|
+
return factorial(a)
|
mathutilslib-0.0.1/PKG-INFO
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|