-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathABCD.py
More file actions
167 lines (122 loc) · 4.25 KB
/
ABCD.py
File metadata and controls
167 lines (122 loc) · 4.25 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import time
import numba
# from sympy import factorial2 as _factorial2
from sympy.abc import s
from scipy.special import zeta
import itertools
from numpy import linalg as LA
from fractions import Fraction
import numpy as np
import functools
from scipy.special import factorial2 as _factorial2
factorial = np.math.factorial
factorial2 = functools.partial(_factorial2, exact=True)
# def factorial2(x: int) -> int:
# return _factorial2(x) # type: ignore
@numba.jit(nopython=True)
def KroneckerDelta(x, y):
if x == y:
return 1.0
return 0.0
# Initial data for Kontsevich volumes
@numba.jit(nopython=True)
def awk(i, j, k):
if 0 == i == j == k:
return 1
return 0
def bwk(k, a, b):
return (
KroneckerDelta(k + a, b + 1)
* factorial2(2 * b + 1)
/ (factorial2(2 * k + 1) * factorial2(2 * a + 1))
* (2 * a + 1)
)
def cwk(k, a, b):
return KroneckerDelta(k, a + b + 2) * factorial2(2 * a + 1) * factorial2(2 * b + 1) / factorial2(2 * k + 1)
@numba.jit(nopython=True)
def dwk(k):
if k == 1:
return 1 / 24.0
return 0.0
# Initial data for multicurve count
@numba.jit()
def amv(i, j, k):
if 0 == i == j == k:
return 1
return 0
@numba.jit(nopython=False)
def bmv(k, a, b):
return (2 * a + 1) * KroneckerDelta(k + a, b + 1) + KroneckerDelta(k, 0) * KroneckerDelta(a, 0) * zeta(
2 * b + 2
) / s ** (2 * b + 2)
@numba.jit()
def cmv(k, a, b):
p1 = 0
if b - k + 1 >= 0:
p1 = (
factorial(2 * a + 2 * b - 2 * k + 3)
/ (factorial(2 * a + 1) * factorial(2 * b - 2 * k + 2))
* zeta(2 * a + 2 * b - 2 * k + 4)
/ s ** (2 * a + 2 * b - 2 * k + 4)
)
p2 = 0
if a - k + 1 >= 0:
p2 = (
factorial(2 * a + 2 * b - 2 * k + 3)
/ (factorial(2 * b + 1) * factorial(2 * a - 2 * k + 2))
* zeta(2 * a + 2 * b - 2 * k + 4)
/ s ** (2 * a + 2 * b - 2 * k + 4)
)
return (
KroneckerDelta(k, a + b + 2)
+ KroneckerDelta(k, 0) * KroneckerDelta(k, 0) * zeta(2 * a + 2) * zeta(2 * b + 2) / s ** (2 * a + 2 * b + 4)
+ p1
+ p2
)
@numba.jit()
def dmv(k):
return 1 / (2 * s**2) * zeta(2) * KroneckerDelta(k, 0) + 1 / 8 * KroneckerDelta(k, 1)
# Intermediate functions
# given a natural number n, this function return a list, whose element are the partitions of {2, ... , n}
def partition(lst):
import more_itertools as mit
return [part for k in range(1, len(lst) + 1) for part in mit.set_partitions(lst, k)]
# given a natural number n, this function return a list, whose element are the partitions of {2, ... , n}
# of the form {J_1, J_2}, with J_i nonempty
def bipartitions(n):
collection = list(range(2, n + 1))
#print(collection)
return list(sorted(elem) for elem in partition(collection) if len(elem) == 2)
# given natural numbers h and n, this function return a list, whose element are the partitions of {2, ..., n} of
# the form {J_1, J_2}, with J_i nonempty if h=0.
def specialbipartitions(h, n):
if h > 0:
return bipartitions(n) + [[[], list(range(2, n))]]
else:
return bipartitions(n)
# given natural numbers n and d, this function return a list, whose element are the multiindices \[Mu] \[Element] \
# [DoubleStruckCapitalN]^n such that | \[Mu] | = d
def multiindex(n, d):
a = [range(0, d + 1)] * n
return list(vector for vector in list(itertools.product(*a)) if LA.linalg.norm(vector, ord=1) <= d)
def noduplicate(myList):
return sorted(set(myList))
@numba.jit(nopython=True)
def dim(g, n):
return 3 * g - 3 + n
#Create ABCD tensors
def AC(g,n, fun_b, fun_c):
vc=np.vectorize(fun_c)
vb=np.vectorize(fun_b)
float_formatter = "{:.5f}".format
np.set_printoptions(formatter={'float_kind':float_formatter})
size = dim(g, n)
c = np.zeros((size,size,size))
b = np.zeros((size,size,size))
for i in range(size):
for j in range(size):
for k in range(size):
c[i,j,k] = vc(i, j, k)
b[i,j,k] = vb(i, j, k)
return b,c
AC(2, 3, bwk, cwk)