Add files via upload
This commit is contained in:
parent
e12ca47cbe
commit
d779c357b7
20 changed files with 3068 additions and 0 deletions
60
fractal_dimension/mcmullen_stuff/cubenode.py
Normal file
60
fractal_dimension/mcmullen_stuff/cubenode.py
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
import numpy as np
|
||||||
|
import math
|
||||||
|
|
||||||
|
class Node:
|
||||||
|
def __init__(self, tuple, word, words, infertile):
|
||||||
|
self.tuple = tuple
|
||||||
|
self.children = []
|
||||||
|
self.word = word
|
||||||
|
self.infertile = infertile
|
||||||
|
words[str(word)] = self
|
||||||
|
|
||||||
|
def dc_not_too_big(self, g, generator, dual_curvature):
|
||||||
|
temp = np.matmul(generator, self.tuple)
|
||||||
|
if g == 0:
|
||||||
|
temp = [temp[i] for i in (0,1,2,4)]
|
||||||
|
elif g == 1:
|
||||||
|
temp = [temp[i] for i in (0,2,3,6)]
|
||||||
|
elif g == 2:
|
||||||
|
temp = [temp[i] for i in (0,1,3,5)]
|
||||||
|
elif g == 3:
|
||||||
|
temp = [temp[i] for i in (1,4,5,7)]
|
||||||
|
elif g == 4:
|
||||||
|
temp = [temp[i] for i in (3,5,6,7)]
|
||||||
|
elif g == 5:
|
||||||
|
temp = [temp[i] for i in (2,4,6,7)]
|
||||||
|
if temp[0] < 0:
|
||||||
|
return math.sqrt(-temp[0]*temp[1]*temp[2] - temp[0]*temp[1]*temp[3] - temp[0]*temp[2]*temp[3] + temp[1]*temp[2]*temp[3])/math.sqrt(-temp[0] + temp[1] + temp[2] + temp[3]) < dual_curvature
|
||||||
|
else:
|
||||||
|
return math.sqrt(temp[0]*temp[1]*temp[2] + temp[0]*temp[1]*temp[3] + temp[0]*temp[2]*temp[3] + temp[1]*temp[2]*temp[3])/math.sqrt(temp[0] + temp[1] + temp[2] + temp[3]) < dual_curvature
|
||||||
|
|
||||||
|
|
||||||
|
def next_generation(self, words, dual_curvature, generators):
|
||||||
|
if self.infertile:
|
||||||
|
return [self]
|
||||||
|
if self.children == []:
|
||||||
|
for g,generator in enumerate(generators):
|
||||||
|
if len(self.word) == 0 or g != self.word[-1]:
|
||||||
|
self.children.append(Node(np.matmul(generator,self.tuple), self.word[:] + [g], words, not self.dc_not_too_big(g, generator, dual_curvature)))
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def leaves(self):
|
||||||
|
current_leaves = [self]
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
new_leaves += leaf.next()
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
return current_leaves
|
||||||
174
fractal_dimension/mcmullen_stuff/cubetree.py
Normal file
174
fractal_dimension/mcmullen_stuff/cubetree.py
Normal file
|
|
@ -0,0 +1,174 @@
|
||||||
|
#https://www.desmos.com/calculator/vaskxmhoxh
|
||||||
|
|
||||||
|
from cubenode import Node
|
||||||
|
import math
|
||||||
|
import numpy as np
|
||||||
|
import time
|
||||||
|
from scipy.sparse import csr_matrix
|
||||||
|
|
||||||
|
def functions(n, z):
|
||||||
|
if n == 0:
|
||||||
|
return -1.732050808 + 1j + np.conj(3./(1.732050808 - 1.000000000j + z))
|
||||||
|
elif n == 1:
|
||||||
|
return -2.000000000j + np.conj(3./(2.000000000j + z))
|
||||||
|
elif n == 2:
|
||||||
|
return 1.732050808 + 1j + np.conj(3./(-1.732050808 - 1.000000000j + z))
|
||||||
|
elif n == 3:
|
||||||
|
return 0.202041j + np.conj(0.0306154/(-0.202041j + z))
|
||||||
|
elif n == 4:
|
||||||
|
return 0.174973 - 0.101021j + np.conj(0.0306154/(-0.174973 + 0.101021j + z))
|
||||||
|
elif n == 5:
|
||||||
|
return -0.174973 - 0.101021j + np.conj(0.0306154/(0.174973 + 0.101021j + z))
|
||||||
|
|
||||||
|
def derivatives(n, z):
|
||||||
|
if n == 0:
|
||||||
|
return abs(-0.333333*(1.732050808 - 1.000000000j + z)**2)
|
||||||
|
elif n == 1:
|
||||||
|
return abs(-0.333333*(2.000000000j + z)**2)
|
||||||
|
elif n == 2:
|
||||||
|
return abs(-0.333333*(-1.732050808 - 1.000000000j + z)**2)
|
||||||
|
elif n == 3:
|
||||||
|
return abs(-32.6633*(-0.202041j + z)**2)
|
||||||
|
elif n == 4:
|
||||||
|
return abs(-32.6633*(-0.174973 + 0.101021j + z)**2)
|
||||||
|
elif n == 5:
|
||||||
|
return abs(-32.6633*(0.174973 + 0.101021j + z)**2)
|
||||||
|
|
||||||
|
def samplePoint(word):
|
||||||
|
points = [-0.606218 + 0.35j, 0. - 0.7j, 0.606218 + 0.35j, 0. +
|
||||||
|
0.181837j, 0.157475 - 0.0909185j, -0.157475 - 0.0909185j]
|
||||||
|
p = points[word[-1]]
|
||||||
|
for letter in word[-2::-1]:
|
||||||
|
p = functions(letter, p)
|
||||||
|
return p
|
||||||
|
|
||||||
|
def sampleValue(word):
|
||||||
|
return derivatives(word[0], samplePoint(word))
|
||||||
|
|
||||||
|
def generateTree(words, dc):
|
||||||
|
|
||||||
|
generators = [np.array([[0., 1., 1., 0., -1., 0., 0., 0.], [0., 1., 0., 0., 0., 0., 0.,
|
||||||
|
0.], [0., 0., 1., 0., 0., 0., 0., 0.], [0., 3., 3., 0., 0., 0.,
|
||||||
|
0., -1.], [0., 0., 0., 0., 1., 0., 0., 0.], [0., 3., 2., 0., 1., 0.,
|
||||||
|
0., -1.], [0., 2., 3., 0., 1., 0., 0., -1.], [0., 2., 2., 0., 2.,
|
||||||
|
0., 0., -1.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0., 0., 0.], [1., 0., 3., 2., -1., 0., 0.,
|
||||||
|
0.], [0., 0., 1., 0., 0., 0., 0., 0.], [0., 0., 0., 1., 0., 0., 0.,
|
||||||
|
0.], [0., 0., 4., 2., -1., 0., 0., 0.], [0., 0., 3., 3., -1., 0.,
|
||||||
|
0., 0.], [-1., 0., 1., 1., 0., 0., 0., 0.], [-1., 0., 4., 3., -1.,
|
||||||
|
0., 0., 0.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0., 0., 0.], [1., 0., 0., -1., 0., 1., 0.,
|
||||||
|
0.], [4., 0., 0., -1., -1., 3., 0., 0.], [0., 0., 0., 1., 0., 0.,
|
||||||
|
0., 0.], [4., 0., 0., -2., -1., 4., 0., 0.], [0., 0., 0., 0., 0.,
|
||||||
|
1., 0., 0.], [3., 0., 0., 0., -1., 3., 0., 0.], [3., 0.,
|
||||||
|
0., -1., -1., 4., 0., 0.]]),
|
||||||
|
np.array([[0., 0., 0., 0., 3., 3., -1., 0.], [0., 1., 0., 0., 0., 0., 0.,
|
||||||
|
0.], [0., -1., 0., 0., 4., 3., -1., 0.], [0., -1., 0., 0., 3.,
|
||||||
|
4., -1., 0.], [0., 0., 0., 0., 1., 0., 0., 0.], [0., 0., 0., 0., 0.,
|
||||||
|
1., 0., 0.], [0., -2., 0., 0., 4., 4., -1., 0.], [0., -1., 0., 0.,
|
||||||
|
1., 1., 0., 0.]]),
|
||||||
|
np.array([[0., 0., 0., 0., -1., 3., 3., 0.], [0., 0., 0., -1., -1., 4., 3.,
|
||||||
|
0.], [0., 0., 0., -1., -1., 3., 4., 0.], [0., 0., 0., 1., 0., 0.,
|
||||||
|
0., 0.], [0., 0., 0., -2., -1., 4., 4., 0.], [0., 0., 0., 0., 0.,
|
||||||
|
1., 0., 0.], [0., 0., 0., 0., 0., 0., 1., 0.], [0., 0., 0., -1., 0.,
|
||||||
|
1., 1., 0.]]),
|
||||||
|
np.array([[0., -1., 0., 0., 4., 0., 3., -1.], [0., -1., 0., 0., 4., 0., 2.,
|
||||||
|
0.], [0., 0., 0., 0., 1., 0., 1., -1.], [0., -1., 0., 0., 3., 0.,
|
||||||
|
3., 0.], [0., 0., 0., 0., 1., 0., 0., 0.], [0., -1., 0., 0., 3., 0.,
|
||||||
|
2., 1.], [0., 0., 0., 0., 0., 0., 1., 0.], [0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 1.]])]
|
||||||
|
|
||||||
|
root = Node([-1,2.632993161855454,2.632993161855454,2.632993161855454,6.265986323710909,6.265986323710909,6.265986323710909,9.898979485566363], [], words, False)
|
||||||
|
current_leaves = [root]
|
||||||
|
nodes = 1
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
next_gen = leaf.next_generation(words, dc, generators)
|
||||||
|
new_leaves += next_gen
|
||||||
|
nodes += len(next_gen) if len(next_gen) > 1 else 0
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
for i,leaf in enumerate(current_leaves):
|
||||||
|
words[str(leaf.word)] = i
|
||||||
|
print(len(current_leaves), "partitions")
|
||||||
|
print(nodes,"nodes")
|
||||||
|
return current_leaves
|
||||||
|
|
||||||
|
def constructMatrix(words, dc):
|
||||||
|
leave = generateTree(words, dc)
|
||||||
|
row = []
|
||||||
|
col = []
|
||||||
|
data = []
|
||||||
|
for i,leaf in enumerate(leave):
|
||||||
|
thing = words[str(leaf.word[1:])]
|
||||||
|
if isinstance(thing,int):
|
||||||
|
row.append(i)
|
||||||
|
col.append(thing)
|
||||||
|
data.append(sampleValue(leaf.word))
|
||||||
|
else:
|
||||||
|
sample = sampleValue(leaf.word)
|
||||||
|
for wor in thing.leaves():
|
||||||
|
row.append(i)
|
||||||
|
col.append(words[str(wor.word)])
|
||||||
|
data.append(sample)
|
||||||
|
return csr_matrix((data,(row,col)),shape=(len(leave),len(leave)))
|
||||||
|
|
||||||
|
def secant(x0,y0,x1,y1,z):
|
||||||
|
return x0 - (y0-z) * ((x1-x0)/(y1-y0))
|
||||||
|
|
||||||
|
def matrixFunction(matrix,l,a):
|
||||||
|
matrix = matrix.power(a)
|
||||||
|
vec = np.ones(l)
|
||||||
|
previous_entry = vec[0]
|
||||||
|
previous_val = 0
|
||||||
|
current = matrix * vec
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count = 0
|
||||||
|
while count < 10000000000 and abs(current_val - previous_val) > 1e-15:
|
||||||
|
previous_val = current_val
|
||||||
|
previous_entry = current[0]
|
||||||
|
current = matrix * current
|
||||||
|
#print(current[0],previous_entry)
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count += 1
|
||||||
|
print("power method:", count)
|
||||||
|
return current_val
|
||||||
|
|
||||||
|
def secantMethod(matrix,l,z,x1,x2,e,its):
|
||||||
|
k1 = x1
|
||||||
|
k2 = x2
|
||||||
|
y1 = matrixFunction(matrix,l,k1)
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y1 = testFunction(k1)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count = 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
while abs(y1-z)>e and count<its:
|
||||||
|
k3 = secant(k1,y1,k2,y2,z)
|
||||||
|
k1 = k2
|
||||||
|
y1 = y2
|
||||||
|
k2 = k3
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
count += 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
start = time.time()
|
||||||
|
|
||||||
|
m = 10
|
||||||
|
print("maximum:",m)
|
||||||
|
words = {}
|
||||||
|
matrix = constructMatrix(words,m)
|
||||||
|
#print(matrix)
|
||||||
|
|
||||||
|
print("construction (s): %f\nconstruction (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
#print(csr_matrix.transpose(matrix))
|
||||||
|
print(csr_matrix.count_nonzero(matrix), (matrix.shape[0])*5)
|
||||||
|
secantMethod(matrix,matrix.shape[0],1,1.47,1.49,10**(-10),1000)
|
||||||
|
|
||||||
|
print("total (s): %f\ntotal (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
|
||||||
|
main()
|
||||||
48
fractal_dimension/mcmullen_stuff/decanode.py
Normal file
48
fractal_dimension/mcmullen_stuff/decanode.py
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
import numpy as np
|
||||||
|
import math
|
||||||
|
|
||||||
|
class Node:
|
||||||
|
def __init__(self, tuple, word, words, infertile):
|
||||||
|
self.tuple = tuple
|
||||||
|
self.children = []
|
||||||
|
self.word = word
|
||||||
|
self.infertile = infertile
|
||||||
|
words[str(word)] = self
|
||||||
|
|
||||||
|
def dc_not_too_big(self, g, generator, dual_curvature):
|
||||||
|
temp = np.matmul(generator, self.tuple)
|
||||||
|
if g <= 9:
|
||||||
|
temp = [temp[i] for i in (g%10, (g+1)%10, 10)]
|
||||||
|
else:
|
||||||
|
temp = [temp[i] for i in (g%10, (g+1)%10, 11)]
|
||||||
|
return math.sqrt(temp[0]*temp[1] + temp[0]*temp[2] + temp[1]*temp[2]) < dual_curvature
|
||||||
|
|
||||||
|
def next_generation(self, words, dual_curvature, generators):
|
||||||
|
if self.infertile:
|
||||||
|
return [self]
|
||||||
|
if self.children == []:
|
||||||
|
for g,generator in enumerate(generators):
|
||||||
|
if len(self.word) == 0 or g != self.word[-1]:
|
||||||
|
self.children.append(Node(np.matmul(generator,self.tuple), self.word[:] + [g], words, not self.dc_not_too_big(g, generator, dual_curvature)))
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def leaves(self):
|
||||||
|
current_leaves = [self]
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
new_leaves += leaf.next()
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
return current_leaves
|
||||||
414
fractal_dimension/mcmullen_stuff/decatree.py
Normal file
414
fractal_dimension/mcmullen_stuff/decatree.py
Normal file
|
|
@ -0,0 +1,414 @@
|
||||||
|
from decanode import Node
|
||||||
|
import math
|
||||||
|
import numpy as np
|
||||||
|
import time
|
||||||
|
from scipy.sparse import csr_matrix
|
||||||
|
|
||||||
|
def functions(n, z):
|
||||||
|
duals = [[0.527864045000421 + 0.171513425153810j,
|
||||||
|
0.171513425153810], [0.326237921249264 + 0.449027976579585j,
|
||||||
|
0.171513425153810], [0.555029102851551j,
|
||||||
|
0.171513425153810], [-0.326237921249264 + 0.449027976579585j,
|
||||||
|
0.171513425153810], [-0.527864045000421 + 0.171513425153810j,
|
||||||
|
0.171513425153810], [-0.527864045000421 - 0.171513425153810j,
|
||||||
|
0.171513425153810], [-0.326237921249264 - 0.449027976579585j,
|
||||||
|
0.171513425153810], [-0.555029102851551j,
|
||||||
|
0.171513425153810], [0.326237921249264 - 0.449027976579585j,
|
||||||
|
0.171513425153810], [0.527864045000421 - 0.171513425153810j,
|
||||||
|
0.171513425153810], [1.00000000000000 + 0.324919696232906j,
|
||||||
|
0.324919696232906], [0.618033988749895 + 0.850650808352040j,
|
||||||
|
0.324919696232906], [1.05146222423827j,
|
||||||
|
0.324919696232906], [-0.618033988749895 + 0.850650808352040j,
|
||||||
|
0.324919696232906], [-1.00000000000000 + 0.324919696232906j,
|
||||||
|
0.324919696232906], [-1.00000000000000 - 0.324919696232906j,
|
||||||
|
0.324919696232906], [-0.618033988749895 - 0.850650808352040j,
|
||||||
|
0.324919696232906], [-1.05146222423827j,
|
||||||
|
0.324919696232906], [0.618033988749895 - 0.850650808352040j,
|
||||||
|
0.324919696232906], [1.00000000000000 - 0.324919696232906j,
|
||||||
|
0.324919696232906]]
|
||||||
|
return duals[n][0] + np.conj((duals[n][1])**2 / (z-duals[n][0]))
|
||||||
|
|
||||||
|
def derivatives(n, z):
|
||||||
|
duals = [[0.527864045000421 + 0.171513425153810j,
|
||||||
|
0.171513425153810], [0.326237921249264 + 0.449027976579585j,
|
||||||
|
0.171513425153810], [0.555029102851551j,
|
||||||
|
0.171513425153810], [-0.326237921249264 + 0.449027976579585j,
|
||||||
|
0.171513425153810], [-0.527864045000421 + 0.171513425153810j,
|
||||||
|
0.171513425153810], [-0.527864045000421 - 0.171513425153810j,
|
||||||
|
0.171513425153810], [-0.326237921249264 - 0.449027976579585j,
|
||||||
|
0.171513425153810], [-0.555029102851551j,
|
||||||
|
0.171513425153810], [0.326237921249264 - 0.449027976579585j,
|
||||||
|
0.171513425153810], [0.527864045000421 - 0.171513425153810j,
|
||||||
|
0.171513425153810], [1.00000000000000 + 0.324919696232906j,
|
||||||
|
0.324919696232906], [0.618033988749895 + 0.850650808352040j,
|
||||||
|
0.324919696232906], [1.05146222423827j,
|
||||||
|
0.324919696232906], [-0.618033988749895 + 0.850650808352040j,
|
||||||
|
0.324919696232906], [-1.00000000000000 + 0.324919696232906j,
|
||||||
|
0.324919696232906], [-1.00000000000000 - 0.324919696232906j,
|
||||||
|
0.324919696232906], [-0.618033988749895 - 0.850650808352040j,
|
||||||
|
0.324919696232906], [-1.05146222423827j,
|
||||||
|
0.324919696232906], [0.618033988749895 - 0.850650808352040j,
|
||||||
|
0.324919696232906], [1.00000000000000 - 0.324919696232906j,
|
||||||
|
0.324919696232906]]
|
||||||
|
return abs(-1*((z-duals[n][0])**2) / ((duals[n][1])**2))
|
||||||
|
|
||||||
|
def samplePoint(word):
|
||||||
|
points = [0.554257 + 0.180089j, 0.34255 + 0.471479j, 0. +
|
||||||
|
0.582781j, -0.34255 + 0.471479j, -0.554257 +
|
||||||
|
0.180089j, -0.554257 - 0.180089j, -0.34255 - 0.471479j, 0. -
|
||||||
|
0.582781j, 0.34255 - 0.471479j, 0.554257 - 0.180089j, 0.9 +
|
||||||
|
0.292428j, 0.556231 + 0.765586j, 0. + 0.946316j, -0.556231 +
|
||||||
|
0.765586j, -0.9 + 0.292428j, -0.9 - 0.292428j, -0.556231 -
|
||||||
|
0.765586j, 0. - 0.946316j, 0.556231 - 0.765586j, 0.9 - 0.292428j]
|
||||||
|
p = points[word[-1]]
|
||||||
|
for letter in word[-2::-1]:
|
||||||
|
p = functions(letter, p)
|
||||||
|
return p
|
||||||
|
|
||||||
|
def sampleValue(word):
|
||||||
|
return derivatives(word[0], samplePoint(word))
|
||||||
|
|
||||||
|
def generateTree(words, dc):
|
||||||
|
tt = time.time()
|
||||||
|
generators = [np.array([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 1., 0., 0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 0., 0.], [3., 5.42705, 0., 0., 0.,
|
||||||
|
0., -0.190983, 0., 0., 0., 7.23607, 0.], [8.8541, 11.5902, 0., 0.,
|
||||||
|
0., 0., -0.5, 0., 0., 0., 18.9443, 0.], [15.3262, 17.1353, 0., 0.,
|
||||||
|
0., 0., -0.809017, 0., 0., 0., 30.6525, 0.], [19.9443, 19.9443, 0.,
|
||||||
|
0., 0., 0., -1., 0., 0., 0., 37.8885, 0.], [20.9443, 18.9443, 0.,
|
||||||
|
0., 0., 0., -1., 0., 0., 0., 37.8885, 0.], [17.9443, 14.5172, 0.,
|
||||||
|
0., 0., 0., -0.809017, 0., 0., 0., 30.6525, 0.], [12.0902, 8.3541,
|
||||||
|
0., 0., 0., 0., -0.5, 0., 0., 0., 18.9443, 0.], [5.61803, 2.80902,
|
||||||
|
0., 0., 0., 0., -0.190983, 0., 0., 0., 7.23607, 0.], [0., 0., 0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 0., 1., 0.], [2.21115, 2.10557, 0., 0., 0.,
|
||||||
|
0., -0.105573, 0., 0., 0., 3., 0.]]),
|
||||||
|
np.array([[0., 5.8541, 2.61803, 0., 0., 0., 0., 0., -0.236068, 0., 7.23607,
|
||||||
|
0.], [0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 1.,
|
||||||
|
0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 3.23607, 5.23607, 0., 0.,
|
||||||
|
0., 0., 0., -0.236068, 0., 7.23607, 0.], [0., 9.47214, 11.0902, 0.,
|
||||||
|
0., 0., 0., 0., -0.618034, 0., 18.9443, 0.], [0., 16.3262, 16.3262,
|
||||||
|
0., 0., 0., 0., 0., -1., 0., 30.6525, 0.], [0., 21.1803, 18.9443,
|
||||||
|
0., 0., 0., 0., 0., -1.23607, 0., 37.8885, 0.], [0., 22.1803,
|
||||||
|
17.9443, 0., 0., 0., 0., 0., -1.23607, 0., 37.8885, 0.], [0.,
|
||||||
|
18.9443, 13.7082, 0., 0., 0., 0., 0., -1., 0., 30.6525, 0.], [0.,
|
||||||
|
12.7082, 7.8541, 0., 0., 0., 0., 0., -0.618034, 0., 18.9443,
|
||||||
|
0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0.], [0., 2.34164,
|
||||||
|
2., 0., 0., 0., 0., 0., -0.130495, 0., 3., 0.]]),
|
||||||
|
np.array([[-1., 0., 13.7082, 7.23607, 0., 0., 0., 0., 0., 0., 18.9443,
|
||||||
|
0.], [-0.381966, 0., 6.23607, 2.38197, 0., 0., 0., 0., 0., 0.,
|
||||||
|
7.23607, 0.], [0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0.,
|
||||||
|
0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.], [-0.381966, 0.,
|
||||||
|
3.61803, 5., 0., 0., 0., 0., 0., 0., 7.23607, 0.], [-1., 0.,
|
||||||
|
10.4721, 10.4721, 0., 0., 0., 0., 0., 0., 18.9443, 0.], [-1.61803,
|
||||||
|
0., 17.9443, 15.3262, 0., 0., 0., 0., 0., 0., 30.6525, 0.], [-2.,
|
||||||
|
0., 23.1803, 17.7082, 0., 0., 0., 0., 0., 0., 37.8885, 0.], [-2.,
|
||||||
|
0., 24.1803, 16.7082, 0., 0., 0., 0., 0., 0., 37.8885,
|
||||||
|
0.], [-1.61803, 0., 20.5623, 12.7082, 0., 0., 0., 0., 0., 0.,
|
||||||
|
30.6525, 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.,
|
||||||
|
0.], [-0.211146, 0., 2.55279, 1.8695, 0., 0., 0., 0., 0., 0., 3.,
|
||||||
|
0.]]),
|
||||||
|
np.array([[0., -1.61803, 0., 20.5623, 12.7082, 0., 0., 0., 0., 0., 30.6525,
|
||||||
|
0.], [0., -1., 0., 13.7082, 7.23607, 0., 0., 0., 0., 0., 18.9443,
|
||||||
|
0.], [0., -0.381966, 0., 6.23607, 2.38197, 0., 0., 0., 0., 0.,
|
||||||
|
7.23607, 0.], [0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.], [0.,
|
||||||
|
0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0.], [0., -0.381966, 0.,
|
||||||
|
3.61803, 5., 0., 0., 0., 0., 0., 7.23607, 0.], [0., -1., 0.,
|
||||||
|
10.4721, 10.4721, 0., 0., 0., 0., 0., 18.9443, 0.], [0., -1.61803,
|
||||||
|
0., 17.9443, 15.3262, 0., 0., 0., 0., 0., 30.6525, 0.], [0., -2.,
|
||||||
|
0., 23.1803, 17.7082, 0., 0., 0., 0., 0., 37.8885, 0.], [0., -2.,
|
||||||
|
0., 24.1803, 16.7082, 0., 0., 0., 0., 0., 37.8885, 0.], [0., 0., 0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 0., 1., 0.], [0., -0.211146, 0., 2.55279,
|
||||||
|
1.8695, 0., 0., 0., 0., 0., 3., 0.]]),
|
||||||
|
np.array([[0., 0., 0., 0., 18.9443, 21.1803, 0., 0., -1.23607, 0., 37.8885,
|
||||||
|
0.], [0., 0., 0., 0., 16.3262, 16.3262, 0., 0., -1., 0., 30.6525,
|
||||||
|
0.], [0., 0., 0., 0., 11.0902, 9.47214, 0., 0., -0.618034, 0.,
|
||||||
|
18.9443, 0.], [0., 0., 0., 0., 5.23607, 3.23607, 0., 0., -0.236068,
|
||||||
|
0., 7.23607, 0.], [0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
|
||||||
|
0.], [0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.], [0., 0., 0.,
|
||||||
|
0., 2.61803, 5.8541, 0., 0., -0.236068, 0., 7.23607, 0.], [0., 0.,
|
||||||
|
0., 0., 7.8541, 12.7082, 0., 0., -0.618034, 0., 18.9443, 0.], [0.,
|
||||||
|
0., 0., 0., 13.7082, 18.9443, 0., 0., -1., 0., 30.6525, 0.], [0.,
|
||||||
|
0., 0., 0., 17.9443, 22.1803, 0., 0., -1.23607, 0., 37.8885,
|
||||||
|
0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0.], [0., 0., 0.,
|
||||||
|
0., 2., 2.34164, 0., 0., -0.130495, 0., 3., 0.]]),
|
||||||
|
np.array([[0., 0., 0., 0., 0., 19.9443, 20.9443, 0., 0., 0.,
|
||||||
|
28.4164, -9.47214], [0., 0., 0., 0., 0., 20.9443, 19.9443, 0., 0.,
|
||||||
|
0., 28.4164, -9.47214], [0., 0., 0., 0., 0., 17.9443, 15.3262, 0.,
|
||||||
|
0., 0., 22.9894, -7.66312], [0., 0., 0., 0., 0., 12.0902, 8.8541,
|
||||||
|
0., 0., 0., 14.2082, -4.73607], [0., 0., 0., 0., 0., 5.61803, 3.,
|
||||||
|
0., 0., 0., 5.42705, -1.80902], [0., 0., 0., 0., 0., 1., 0., 0., 0.,
|
||||||
|
0., 0., 0.], [0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.], [0.,
|
||||||
|
0., 0., 0., 0., 3., 5.61803, 0., 0., 0., 5.42705, -1.80902], [0.,
|
||||||
|
0., 0., 0., 0., 8.8541, 12.0902, 0., 0., 0.,
|
||||||
|
14.2082, -4.73607], [0., 0., 0., 0., 0., 15.3262, 17.9443, 0., 0.,
|
||||||
|
0., 22.9894, -7.66312], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.,
|
||||||
|
0.], [0., 0., 0., 0., 0., 2.21115, 2.21115, 0., 0., 0., 2., -1.]]),
|
||||||
|
np.array([[0., 0., 0., 0., 0., 0., 12.7082, 20.5623, 0., -1.61803, 30.6525,
|
||||||
|
0.], [0., 0., 0., 0., 0., 0., 16.7082, 24.1803, 0., -2., 37.8885,
|
||||||
|
0.], [0., 0., 0., 0., 0., 0., 17.7082, 23.1803, 0., -2., 37.8885,
|
||||||
|
0.], [0., 0., 0., 0., 0., 0., 15.3262, 17.9443, 0., -1.61803,
|
||||||
|
30.6525, 0.], [0., 0., 0., 0., 0., 0., 10.4721, 10.4721, 0., -1.,
|
||||||
|
18.9443, 0.], [0., 0., 0., 0., 0., 0., 5., 3.61803, 0., -0.381966,
|
||||||
|
7.23607, 0.], [0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.], [0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0.], [0., 0., 0., 0., 0.,
|
||||||
|
0., 2.38197, 6.23607, 0., -0.381966, 7.23607, 0.], [0., 0., 0., 0.,
|
||||||
|
0., 0., 7.23607, 13.7082, 0., -1., 18.9443, 0.], [0., 0., 0., 0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 1., 0.], [0., 0., 0., 0., 0., 0., 1.8695,
|
||||||
|
2.55279, 0., -0.211146, 3., 0.]]),
|
||||||
|
np.array([[0., 0., 0., 0., -0.618034, 0., 0., 9.47214, 11.0902, 0., 18.9443,
|
||||||
|
0.], [0., 0., 0., 0., -1., 0., 0., 16.3262, 16.3262, 0., 30.6525,
|
||||||
|
0.], [0., 0., 0., 0., -1.23607, 0., 0., 21.1803, 18.9443, 0.,
|
||||||
|
37.8885, 0.], [0., 0., 0., 0., -1.23607, 0., 0., 22.1803, 17.9443,
|
||||||
|
0., 37.8885, 0.], [0., 0., 0., 0., -1., 0., 0., 18.9443, 13.7082,
|
||||||
|
0., 30.6525, 0.], [0., 0., 0., 0., -0.618034, 0., 0., 12.7082,
|
||||||
|
7.8541, 0., 18.9443, 0.], [0., 0., 0., 0., -0.236068, 0., 0.,
|
||||||
|
5.8541, 2.61803, 0., 7.23607, 0.], [0., 0., 0., 0., 0., 0., 0., 1.,
|
||||||
|
0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0.,
|
||||||
|
0.], [0., 0., 0., 0., -0.236068, 0., 0., 3.23607, 5.23607, 0.,
|
||||||
|
7.23607, 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0.], [0.,
|
||||||
|
0., 0., 0., -0.130495, 0., 0., 2.34164, 2., 0., 3., 0.]]),
|
||||||
|
np.array([[0., 0., -0.236068, 0., 0., 0., 0., 0., 2.61803, 5.8541, 7.23607,
|
||||||
|
0.], [0., 0., -0.618034, 0., 0., 0., 0., 0., 7.8541, 12.7082,
|
||||||
|
18.9443, 0.], [0., 0., -1., 0., 0., 0., 0., 0., 13.7082, 18.9443,
|
||||||
|
30.6525, 0.], [0., 0., -1.23607, 0., 0., 0., 0., 0., 17.9443,
|
||||||
|
22.1803, 37.8885, 0.], [0., 0., -1.23607, 0., 0., 0., 0., 0.,
|
||||||
|
18.9443, 21.1803, 37.8885, 0.], [0., 0., -1., 0., 0., 0., 0., 0.,
|
||||||
|
16.3262, 16.3262, 30.6525, 0.], [0., 0., -0.618034, 0., 0., 0., 0.,
|
||||||
|
0., 11.0902, 9.47214, 18.9443, 0.], [0., 0., -0.236068, 0., 0., 0.,
|
||||||
|
0., 0., 5.23607, 3.23607, 7.23607, 0.], [0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 1., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0.,
|
||||||
|
0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0.], [0.,
|
||||||
|
0., -0.130495, 0., 0., 0., 0., 0., 2., 2.34164, 3., 0.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [7.23607, -1., 0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 2., 7.23607, 0.], [16.3262, -2.61803, 0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 6.23607, 18.9443, 0.], [24.7984, -4.23607,
|
||||||
|
0., 0., 0., 0., 0., 0., 0., 11.0902, 30.6525,
|
||||||
|
0.], [29.4164, -5.23607, 0., 0., 0., 0., 0., 0., 0., 14.7082,
|
||||||
|
37.8885, 0.], [28.4164, -5.23607, 0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
15.7082, 37.8885, 0.], [22.1803, -4.23607, 0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 13.7082, 30.6525, 0.], [13.0902, -2.61803, 0., 0., 0., 0., 0.,
|
||||||
|
0., 0., 9.47214, 18.9443, 0.], [4.61803, -1., 0., 0., 0., 0., 0.,
|
||||||
|
0., 0., 4.61803, 7.23607, 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
1., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.,
|
||||||
|
0.], [3.10557, -0.552786, 0., 0., 0., 0., 0., 0., 0., 1.65836, 3.,
|
||||||
|
0.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 1., 0., 0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 0., 0.], [3.23607, 5.23607, 0., 0., 0., 0.,
|
||||||
|
0., -0.236068, 0., 0., 0., 7.23607], [9.47214, 11.0902, 0., 0., 0.,
|
||||||
|
0., 0., -0.618034, 0., 0., 0., 18.9443], [16.3262, 16.3262, 0., 0.,
|
||||||
|
0., 0., 0., -1., 0., 0., 0., 30.6525], [21.1803, 18.9443, 0., 0.,
|
||||||
|
0., 0., 0., -1.23607, 0., 0., 0., 37.8885], [22.1803, 17.9443, 0.,
|
||||||
|
0., 0., 0., 0., -1.23607, 0., 0., 0., 37.8885], [18.9443, 13.7082,
|
||||||
|
0., 0., 0., 0., 0., -1., 0., 0., 0., 30.6525], [12.7082, 7.8541, 0.,
|
||||||
|
0., 0., 0., 0., -0.618034, 0., 0., 0., 18.9443], [5.8541, 2.61803,
|
||||||
|
0., 0., 0., 0., 0., -0.236068, 0., 0., 0., 7.23607], [2.34164, 2.,
|
||||||
|
0., 0., 0., 0., 0., -0.130495, 0., 0., 0., 3.], [0., 0., 0., 0., 0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[0., 5.8541, 2.61803, 0., 0., 0., 0., 0., -0.236068, 0., 0.,
|
||||||
|
7.23607], [0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.,
|
||||||
|
1., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 3.23607, 5.23607, 0.,
|
||||||
|
0., 0., 0., 0., -0.236068, 0., 0., 7.23607], [0., 9.47214, 11.0902,
|
||||||
|
0., 0., 0., 0., 0., -0.618034, 0., 0., 18.9443], [0., 16.3262,
|
||||||
|
16.3262, 0., 0., 0., 0., 0., -1., 0., 0., 30.6525], [0., 21.1803,
|
||||||
|
18.9443, 0., 0., 0., 0., 0., -1.23607, 0., 0., 37.8885], [0.,
|
||||||
|
22.1803, 17.9443, 0., 0., 0., 0., 0., -1.23607, 0., 0.,
|
||||||
|
37.8885], [0., 18.9443, 13.7082, 0., 0., 0., 0., 0., -1., 0., 0.,
|
||||||
|
30.6525], [0., 12.7082, 7.8541, 0., 0., 0., 0., 0., -0.618034, 0.,
|
||||||
|
0., 18.9443], [0., 2.34164, 2., 0., 0., 0., 0., 0., -0.130495, 0.,
|
||||||
|
0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[0., 0., 10.4721, 10.4721, 0., -1., 0., 0., 0., 0., 0.,
|
||||||
|
18.9443], [0., 0., 5., 3.61803, 0., -0.381966, 0., 0., 0., 0., 0.,
|
||||||
|
7.23607], [0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.,
|
||||||
|
0., 1., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 2.38197, 6.23607,
|
||||||
|
0., -0.381966, 0., 0., 0., 0., 0., 7.23607], [0., 0., 7.23607,
|
||||||
|
13.7082, 0., -1., 0., 0., 0., 0., 0., 18.9443], [0., 0., 12.7082,
|
||||||
|
20.5623, 0., -1.61803, 0., 0., 0., 0., 0., 30.6525], [0., 0.,
|
||||||
|
16.7082, 24.1803, 0., -2., 0., 0., 0., 0., 0., 37.8885], [0., 0.,
|
||||||
|
17.7082, 23.1803, 0., -2., 0., 0., 0., 0., 0., 37.8885], [0., 0.,
|
||||||
|
15.3262, 17.9443, 0., -1.61803, 0., 0., 0., 0., 0., 30.6525], [0.,
|
||||||
|
0., 1.8695, 2.55279, 0., -0.211146, 0., 0., 0., 0., 0., 3.], [0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[0., 0., 0., 13.7082, 22.1803, -4.23607, 0., 0., 0., 0., 0.,
|
||||||
|
30.6525], [0., 0., 0., 9.47214, 13.0902, -2.61803, 0., 0., 0., 0.,
|
||||||
|
0., 18.9443], [0., 0., 0., 4.61803, 4.61803, -1., 0., 0., 0., 0.,
|
||||||
|
0., 7.23607], [0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.], [0.,
|
||||||
|
0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 2.,
|
||||||
|
7.23607, -1., 0., 0., 0., 0., 0., 7.23607], [0., 0., 0., 6.23607,
|
||||||
|
16.3262, -2.61803, 0., 0., 0., 0., 0., 18.9443], [0., 0., 0.,
|
||||||
|
11.0902, 24.7984, -4.23607, 0., 0., 0., 0., 0., 30.6525], [0., 0.,
|
||||||
|
0., 14.7082, 29.4164, -5.23607, 0., 0., 0., 0., 0., 37.8885], [0.,
|
||||||
|
0., 0., 15.7082, 28.4164, -5.23607, 0., 0., 0., 0., 0.,
|
||||||
|
37.8885], [0., 0., 0., 1.65836, 3.10557, -0.552786, 0., 0., 0., 0.,
|
||||||
|
0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[0., -1.23607, 0., 0., 22.1803, 17.9443, 0., 0., 0., 0., 0.,
|
||||||
|
37.8885], [0., -1., 0., 0., 18.9443, 13.7082, 0., 0., 0., 0., 0.,
|
||||||
|
30.6525], [0., -0.618034, 0., 0., 12.7082, 7.8541, 0., 0., 0., 0.,
|
||||||
|
0., 18.9443], [0., -0.236068, 0., 0., 5.8541, 2.61803, 0., 0., 0.,
|
||||||
|
0., 0., 7.23607], [0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
|
||||||
|
0.], [0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.,
|
||||||
|
0.], [0., -0.236068, 0., 0., 3.23607, 5.23607, 0., 0., 0., 0., 0.,
|
||||||
|
7.23607], [0., -0.618034, 0., 0., 9.47214, 11.0902, 0., 0., 0., 0.,
|
||||||
|
0., 18.9443], [0., -1., 0., 0., 16.3262, 16.3262, 0., 0., 0., 0.,
|
||||||
|
0., 30.6525], [0., -1.23607, 0., 0., 21.1803, 18.9443, 0., 0., 0.,
|
||||||
|
0., 0., 37.8885], [0., -0.130495, 0., 0., 2.34164, 2., 0., 0., 0.,
|
||||||
|
0., 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[-1., 0., 0., 0., 0., 18.9443, 20.9443, 0., 0., 0., 0.,
|
||||||
|
37.8885], [-1., 0., 0., 0., 0., 19.9443, 19.9443, 0., 0., 0., 0.,
|
||||||
|
37.8885], [-0.809017, 0., 0., 0., 0., 17.1353, 15.3262, 0., 0., 0.,
|
||||||
|
0., 30.6525], [-0.5, 0., 0., 0., 0., 11.5902, 8.8541, 0., 0., 0.,
|
||||||
|
0., 18.9443], [-0.190983, 0., 0., 0., 0., 5.42705, 3., 0., 0., 0.,
|
||||||
|
0., 7.23607], [0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.], [0.,
|
||||||
|
0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.], [-0.190983, 0., 0.,
|
||||||
|
0., 0., 2.80902, 5.61803, 0., 0., 0., 0., 7.23607], [-0.5, 0., 0.,
|
||||||
|
0., 0., 8.3541, 12.0902, 0., 0., 0., 0., 18.9443], [-0.809017, 0.,
|
||||||
|
0., 0., 0., 14.5172, 17.9443, 0., 0., 0., 0., 30.6525], [-0.105573,
|
||||||
|
0., 0., 0., 0., 2.10557, 2.21115, 0., 0., 0., 0., 3.], [0., 0., 0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[0., 0., 0., 0., 0., 0., 15.3262, 17.9443, 0., 0., -7.66312,
|
||||||
|
22.9894], [0., 0., 0., 0., 0., 0., 19.9443, 20.9443, 0.,
|
||||||
|
0., -9.47214, 28.4164], [0., 0., 0., 0., 0., 0., 20.9443, 19.9443,
|
||||||
|
0., 0., -9.47214, 28.4164], [0., 0., 0., 0., 0., 0., 17.9443,
|
||||||
|
15.3262, 0., 0., -7.66312, 22.9894], [0., 0., 0., 0., 0., 0.,
|
||||||
|
12.0902, 8.8541, 0., 0., -4.73607, 14.2082], [0., 0., 0., 0., 0.,
|
||||||
|
0., 5.61803, 3., 0., 0., -1.80902, 5.42705], [0., 0., 0., 0., 0.,
|
||||||
|
0., 1., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 1., 0.,
|
||||||
|
0., 0., 0.], [0., 0., 0., 0., 0., 0., 3., 5.61803, 0., 0., -1.80902,
|
||||||
|
5.42705], [0., 0., 0., 0., 0., 0., 8.8541, 12.0902, 0.,
|
||||||
|
0., -4.73607, 14.2082], [0., 0., 0., 0., 0., 0., 2.21115, 2.21115,
|
||||||
|
0., 0., -1., 2.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[0., 0., 0., 0., 0., 0., 0., 6.23607, 16.3262, -2.61803, 0.,
|
||||||
|
18.9443], [0., 0., 0., 0., 0., 0., 0., 11.0902, 24.7984, -4.23607,
|
||||||
|
0., 30.6525], [0., 0., 0., 0., 0., 0., 0., 14.7082,
|
||||||
|
29.4164, -5.23607, 0., 37.8885], [0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
15.7082, 28.4164, -5.23607, 0., 37.8885], [0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 13.7082, 22.1803, -4.23607, 0., 30.6525], [0., 0., 0., 0., 0.,
|
||||||
|
0., 0., 9.47214, 13.0902, -2.61803, 0., 18.9443], [0., 0., 0., 0.,
|
||||||
|
0., 0., 0., 4.61803, 4.61803, -1., 0., 7.23607], [0., 0., 0., 0.,
|
||||||
|
0., 0., 0., 1., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
1., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 2., 7.23607, -1., 0.,
|
||||||
|
7.23607], [0., 0., 0., 0., 0., 0., 0., 1.65836, 3.10557, -0.552786,
|
||||||
|
0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[0., 0., 0., 0., 0., -0.236068, 0., 0., 3.23607, 5.23607, 0.,
|
||||||
|
7.23607], [0., 0., 0., 0., 0., -0.618034, 0., 0., 9.47214, 11.0902,
|
||||||
|
0., 18.9443], [0., 0., 0., 0., 0., -1., 0., 0., 16.3262, 16.3262,
|
||||||
|
0., 30.6525], [0., 0., 0., 0., 0., -1.23607, 0., 0., 21.1803,
|
||||||
|
18.9443, 0., 37.8885], [0., 0., 0., 0., 0., -1.23607, 0., 0.,
|
||||||
|
22.1803, 17.9443, 0., 37.8885], [0., 0., 0., 0., 0., -1., 0., 0.,
|
||||||
|
18.9443, 13.7082, 0., 30.6525], [0., 0., 0., 0., 0., -0.618034, 0.,
|
||||||
|
0., 12.7082, 7.8541, 0., 18.9443], [0., 0., 0., 0., 0., -0.236068,
|
||||||
|
0., 0., 5.8541, 2.61803, 0., 7.23607], [0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 1., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0.,
|
||||||
|
0.], [0., 0., 0., 0., 0., -0.130495, 0., 0., 2.34164, 2., 0.,
|
||||||
|
3.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [5.8541, 0.,
|
||||||
|
0., -0.236068, 0., 0., 0., 0., 0., 2.61803, 0., 7.23607], [12.7082,
|
||||||
|
0., 0., -0.618034, 0., 0., 0., 0., 0., 7.8541, 0.,
|
||||||
|
18.9443], [18.9443, 0., 0., -1., 0., 0., 0., 0., 0., 13.7082, 0.,
|
||||||
|
30.6525], [22.1803, 0., 0., -1.23607, 0., 0., 0., 0., 0., 17.9443,
|
||||||
|
0., 37.8885], [21.1803, 0., 0., -1.23607, 0., 0., 0., 0., 0.,
|
||||||
|
18.9443, 0., 37.8885], [16.3262, 0., 0., -1., 0., 0., 0., 0., 0.,
|
||||||
|
16.3262, 0., 30.6525], [9.47214, 0., 0., -0.618034, 0., 0., 0., 0.,
|
||||||
|
0., 11.0902, 0., 18.9443], [3.23607, 0., 0., -0.236068, 0., 0., 0.,
|
||||||
|
0., 0., 5.23607, 0., 7.23607], [0., 0., 0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
1., 0., 0.], [2.34164, 0., 0., -0.130495, 0., 0., 0., 0., 0., 2.,
|
||||||
|
0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]])]
|
||||||
|
|
||||||
|
root = Node([4.23606797749979, 4.23606797749979, 4.23606797749979, \
|
||||||
|
4.23606797749979, 4.23606797749979, 4.23606797749979, \
|
||||||
|
4.23606797749979, 4.23606797749979, 4.23606797749979, \
|
||||||
|
4.23606797749979, 1.89442719099992, -1.00000000000000], [], words, False)
|
||||||
|
current_leaves = [root]
|
||||||
|
nodes = 1
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
next_gen = leaf.next_generation(words, dc, generators)
|
||||||
|
new_leaves += next_gen
|
||||||
|
nodes += len(next_gen) if len(next_gen) > 1 else 0
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
for i,leaf in enumerate(current_leaves):
|
||||||
|
words[str(leaf.word)] = i
|
||||||
|
print(len(current_leaves), "partitions")
|
||||||
|
print(nodes,"nodes")
|
||||||
|
print("tree construction (s): %f\ntree construction (m): %f" % (time.time()-tt, (time.time()-tt)/60))
|
||||||
|
return current_leaves
|
||||||
|
|
||||||
|
def constructMatrix(words, dc):
|
||||||
|
leave = generateTree(words, dc)
|
||||||
|
row = []
|
||||||
|
col = []
|
||||||
|
data = []
|
||||||
|
for i,leaf in enumerate(leave):
|
||||||
|
thing = words[str(leaf.word[1:])]
|
||||||
|
if isinstance(thing,int):
|
||||||
|
row.append(i)
|
||||||
|
col.append(thing)
|
||||||
|
data.append(sampleValue(leaf.word))
|
||||||
|
else:
|
||||||
|
sample = sampleValue(leaf.word)
|
||||||
|
for wor in thing.leaves():
|
||||||
|
row.append(i)
|
||||||
|
col.append(words[str(wor.word)])
|
||||||
|
data.append(sample)
|
||||||
|
return csr_matrix((data,(row,col)),shape=(len(leave),len(leave)))
|
||||||
|
|
||||||
|
def secant(x0,y0,x1,y1,z):
|
||||||
|
return x0 - (y0-z) * ((x1-x0)/(y1-y0))
|
||||||
|
|
||||||
|
def matrixFunction(matrix,l,a):
|
||||||
|
matrix = matrix.power(a)
|
||||||
|
vec = np.ones(l)
|
||||||
|
previous_entry = vec[0]
|
||||||
|
previous_val = 0
|
||||||
|
current = matrix * vec
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count = 0
|
||||||
|
while count < 10000000000 and abs(current_val - previous_val) > 1e-15:
|
||||||
|
previous_val = current_val
|
||||||
|
previous_entry = current[0]
|
||||||
|
current = matrix * current
|
||||||
|
#print(current[0],previous_entry)
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count += 1
|
||||||
|
print("power method:", count)
|
||||||
|
return current_val
|
||||||
|
|
||||||
|
def secantMethod(matrix,l,z,x1,x2,e,its):
|
||||||
|
k1 = x1
|
||||||
|
k2 = x2
|
||||||
|
y1 = matrixFunction(matrix,l,k1)
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y1 = testFunction(k1)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count = 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
while abs(y1-z)>e and count<its:
|
||||||
|
k3 = secant(k1,y1,k2,y2,z)
|
||||||
|
k1 = k2
|
||||||
|
y1 = y2
|
||||||
|
k2 = k3
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count += 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
start = time.time()
|
||||||
|
|
||||||
|
words = {}
|
||||||
|
m = 100
|
||||||
|
print("maximum:",m)
|
||||||
|
matrix = constructMatrix(words, m)
|
||||||
|
#print(matrix)
|
||||||
|
|
||||||
|
print("construction (s): %f\nconstruction (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
#print(csr_matrix.transpose(matrix))
|
||||||
|
print(csr_matrix.count_nonzero(matrix), (matrix.shape[0])*15)
|
||||||
|
secantMethod(matrix,matrix.shape[0],1,1.33,1.34,10**(-10),1000)
|
||||||
|
|
||||||
|
print("total (s): %f\ntotal (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
|
||||||
|
main()
|
||||||
140
fractal_dimension/mcmullen_stuff/fancymcmullen.py
Normal file
140
fractal_dimension/mcmullen_stuff/fancymcmullen.py
Normal file
|
|
@ -0,0 +1,140 @@
|
||||||
|
from node import Node
|
||||||
|
import math
|
||||||
|
import numpy as np
|
||||||
|
import time
|
||||||
|
from scipy.sparse import csr_matrix
|
||||||
|
from scipy import stats
|
||||||
|
|
||||||
|
def functions(n, z):
|
||||||
|
if n == 0:
|
||||||
|
return np.conj((2-math.sqrt(3))**2 / z)
|
||||||
|
elif n ==1:
|
||||||
|
return 2j + np.conj(3 / (z - 2j))
|
||||||
|
elif n == 2:
|
||||||
|
return -1 * math.sqrt(3) - 1j + np.conj(3 / (z + math.sqrt(3) + 1j))
|
||||||
|
elif n == 3:
|
||||||
|
return math.sqrt(3) - 1j + np.conj(3 / (z - math.sqrt(3) + 1j))
|
||||||
|
|
||||||
|
def derivatives(n, z):
|
||||||
|
if n == 0:
|
||||||
|
return abs(z**2 / (2-math.sqrt(3))**2)
|
||||||
|
elif n == 1:
|
||||||
|
return abs((z-2j)**2 / 3)
|
||||||
|
elif n == 2:
|
||||||
|
return abs((z+math.sqrt(3)+1j)**2 / 3)
|
||||||
|
elif n == 3:
|
||||||
|
return abs((z-math.sqrt(3)+1j)**2 / 3)
|
||||||
|
|
||||||
|
def samplePoint(word):
|
||||||
|
if word[-1] == 0:
|
||||||
|
p = 0 + 0j
|
||||||
|
elif word[-1] == 1:
|
||||||
|
p = 0 + 0.5j
|
||||||
|
elif word[-1] == 2:
|
||||||
|
p = -1 * math.sqrt(3) / 4 - 0.25j
|
||||||
|
elif word[-1] == 3:
|
||||||
|
p = math.sqrt(3) / 4 - 0.25j
|
||||||
|
for letter in word[-2::-1]:
|
||||||
|
p = functions(letter, p)
|
||||||
|
return p
|
||||||
|
|
||||||
|
def sampleValue(word):
|
||||||
|
return derivatives(word[0], samplePoint(word))
|
||||||
|
|
||||||
|
def generateTree(words, dc):
|
||||||
|
generators = [np.array([[-1,2,2,2],[0,1,0,0],[0,0,1,0],[0,0,0,1]]),
|
||||||
|
np.array([[1,0,0,0],[2,-1,2,2],[0,0,1,0],[0,0,0,1]]),
|
||||||
|
np.array([[1,0,0,0],[0,1,0,0],[2,2,-1,2],[0,0,0,1]]),
|
||||||
|
np.array([[1,0,0,0],[0,1,0,0],[0,0,1,0],[2,2,2,-1]])]
|
||||||
|
root = Node([-1., 2. + math.sqrt(3), 2. + math.sqrt(3), 2. + math.sqrt(3)], [], words, False)
|
||||||
|
current_leaves = [root]
|
||||||
|
nodes = 1
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
next_gen = leaf.next_generation(words, dc, generators)
|
||||||
|
new_leaves += next_gen
|
||||||
|
nodes += len(next_gen) if len(next_gen) > 1 else 0
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
for i,leaf in enumerate(current_leaves):
|
||||||
|
words[str(leaf.word)] = i
|
||||||
|
print(len(current_leaves), "partitions")
|
||||||
|
print(nodes,"nodes")
|
||||||
|
return current_leaves
|
||||||
|
|
||||||
|
def constructMatrix(words, dc):
|
||||||
|
leave = generateTree(words, dc)
|
||||||
|
row = []
|
||||||
|
col = []
|
||||||
|
data = []
|
||||||
|
for i,leaf in enumerate(leave):
|
||||||
|
thing = words[str(leaf.word[1:])]
|
||||||
|
if isinstance(thing,int):
|
||||||
|
row.append(i)
|
||||||
|
col.append(thing)
|
||||||
|
data.append(sampleValue(leaf.word))
|
||||||
|
else:
|
||||||
|
for wor in thing.leaves():
|
||||||
|
row.append(i)
|
||||||
|
col.append(words[str(wor.word)])
|
||||||
|
data.append(sampleValue(leaf.word))
|
||||||
|
return csr_matrix((data,(row,col)),shape=(len(leave),len(leave)))
|
||||||
|
|
||||||
|
def secant(x0,y0,x1,y1,z):
|
||||||
|
return x0 - (y0-z) * ((x1-x0)/(y1-y0))
|
||||||
|
|
||||||
|
def matrixFunction(matrix,l,a):
|
||||||
|
matrix = matrix.power(a)
|
||||||
|
vec = np.ones(l)
|
||||||
|
previous_entry = vec[0]
|
||||||
|
previous_val = 0
|
||||||
|
current = matrix * vec
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count = 0
|
||||||
|
while count < 1000000000 and abs(current_val - previous_val) > 1e-15:
|
||||||
|
previous_val = current_val
|
||||||
|
previous_entry = current[0]
|
||||||
|
current = matrix * current
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count += 1
|
||||||
|
print("power method:", count)
|
||||||
|
return current_val
|
||||||
|
|
||||||
|
def secantMethod(matrix,l,z,x1,x2,e,its):
|
||||||
|
k1 = x1
|
||||||
|
k2 = x2
|
||||||
|
y1 = matrixFunction(matrix,l,k1)
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y1 = testFunction(k1)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count = 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
while abs(y1-z)>e and count<its:
|
||||||
|
k3 = secant(k1,y1,k2,y2,z)
|
||||||
|
k1 = k2
|
||||||
|
y1 = y2
|
||||||
|
k2 = k3
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count += 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
start = time.time()
|
||||||
|
|
||||||
|
words = {}
|
||||||
|
|
||||||
|
matrix = constructMatrix(words,400)
|
||||||
|
#print(matrix.toarray())
|
||||||
|
|
||||||
|
print("construction (s): %f\nconstruction (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
#print(csr_matrix.transpose(matrix))
|
||||||
|
print(csr_matrix.count_nonzero(matrix), (matrix.shape[0])*3)
|
||||||
|
secantMethod(matrix,matrix.shape[0],1,1.30,1.31,10**(-10),1000)
|
||||||
|
|
||||||
|
print("total (s): %f\ntotal (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
|
||||||
|
main()
|
||||||
60
fractal_dimension/mcmullen_stuff/fournode.py
Normal file
60
fractal_dimension/mcmullen_stuff/fournode.py
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
import numpy as np
|
||||||
|
import math
|
||||||
|
|
||||||
|
class Node:
|
||||||
|
def __init__(self, tuple, word, words, infertile):
|
||||||
|
self.tuple = tuple
|
||||||
|
self.children = []
|
||||||
|
self.word = word
|
||||||
|
self.infertile = infertile
|
||||||
|
words[str(word)] = self
|
||||||
|
|
||||||
|
def dc_not_too_big(self, g, generator, dual_curvature):
|
||||||
|
temp = np.matmul(generator, self.tuple)
|
||||||
|
if g == 0:
|
||||||
|
temp = [temp[i] for i in (0,1,4)]
|
||||||
|
elif g == 1:
|
||||||
|
temp = [temp[i] for i in (0,3,4)]
|
||||||
|
elif g == 2:
|
||||||
|
temp = [temp[i] for i in (2,3,4)]
|
||||||
|
elif g == 3:
|
||||||
|
temp = [temp[i] for i in (1,2,4)]
|
||||||
|
elif g == 4:
|
||||||
|
temp = [temp[i] for i in (0,1,5)]
|
||||||
|
elif g == 5:
|
||||||
|
temp = [temp[i] for i in (0,3,5)]
|
||||||
|
elif g == 6:
|
||||||
|
temp = [temp[i] for i in (2,3,5)]
|
||||||
|
elif g == 7:
|
||||||
|
temp = [temp[i] for i in (1,2,5)]
|
||||||
|
return math.sqrt(temp[0]*temp[1] + temp[0]*temp[2] + temp[1]*temp[2]) < dual_curvature
|
||||||
|
|
||||||
|
def next_generation(self, words, dual_curvature, generators):
|
||||||
|
if self.infertile:
|
||||||
|
return [self]
|
||||||
|
if self.children == []:
|
||||||
|
for g,generator in enumerate(generators):
|
||||||
|
if len(self.word) == 0 or g != self.word[-1]:
|
||||||
|
self.children.append(Node(np.matmul(generator,self.tuple), self.word[:] + [g], words, not self.dc_not_too_big(g, generator, dual_curvature)))
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def leaves(self):
|
||||||
|
current_leaves = [self]
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
new_leaves += leaf.next()
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
return current_leaves
|
||||||
184
fractal_dimension/mcmullen_stuff/fourtree.py
Normal file
184
fractal_dimension/mcmullen_stuff/fourtree.py
Normal file
|
|
@ -0,0 +1,184 @@
|
||||||
|
from fournode import Node
|
||||||
|
import math
|
||||||
|
import numpy as np
|
||||||
|
import time
|
||||||
|
from scipy.sparse import csr_matrix
|
||||||
|
|
||||||
|
def functions(n, z):
|
||||||
|
if n == 0:
|
||||||
|
#return 3 - 2*math.sqrt(2) + (3 - 2*math.sqrt(2))*1j + np.conj((-1 + math.sqrt(2))**2 / ((-3 + 2*math.sqrt(2) - (3 - 2*math.sqrt(2))*1j + z)))
|
||||||
|
return 3-2*math.sqrt(2) + (3-2*math.sqrt(2))*1j + np.conj((1 / (17+12*math.sqrt(2))) / (z - (3-2*math.sqrt(2) + (3-2*math.sqrt(2))*1j)))
|
||||||
|
elif n == 1:
|
||||||
|
#return -3 + 2*math.sqrt(2) + (3 - 2*math.sqrt(2))*1j + np.conj((-1 + math.sqrt(2))**2 / ((3 - 2*math.sqrt(2) - (3 - 2*math.sqrt(2))*1j + z)))
|
||||||
|
return -3+2*math.sqrt(2) + (3-2*math.sqrt(2))*1j + np.conj((1 / (17+12*math.sqrt(2))) / (z - (-3+2*math.sqrt(2) + (3-2*math.sqrt(2))*1j)))
|
||||||
|
elif n == 2:
|
||||||
|
#return -3 + 2*math.sqrt(2) + (-3 + 2*math.sqrt(2))*1j + np.conj((-1 + math.sqrt(2))**2 / ((3 - 2*math.sqrt(2) - (-3 + 2*math.sqrt(2))*1j + z)))
|
||||||
|
return -3+2*math.sqrt(2) + (-3+2*math.sqrt(2))*1j + np.conj((1 / (17+12*math.sqrt(2))) / (z - (-3+2*math.sqrt(2) + (-3+2*math.sqrt(2))*1j)))
|
||||||
|
elif n == 3:
|
||||||
|
#return 3 - 2*math.sqrt(2) + (-3 + 2*math.sqrt(2))*1j + np.conj((-1 + math.sqrt(2))**2 / ((-3 + 2*math.sqrt(2) - (-3 + 2*math.sqrt(2))*1j + z)))
|
||||||
|
return 3-2*math.sqrt(2) + (-3+2*math.sqrt(2))*1j + np.conj((1 / (17+12*math.sqrt(2))) / (z - (3-2*math.sqrt(2) + (-3+2*math.sqrt(2))*1j)))
|
||||||
|
elif n == 4:
|
||||||
|
#return 1 + 1j + np.conj((-1 + math.sqrt(2))**2 / (-1 - 1j + z))
|
||||||
|
return 1 + 1j + np.conj(1 / (z - 1 - 1j))
|
||||||
|
elif n == 5:
|
||||||
|
#return -1 + 1j + np.conj((-1 + math.sqrt(2))**2 / (1 - 1j + z))
|
||||||
|
return -1 + 1j + np.conj(1 / (z + 1 - 1j))
|
||||||
|
elif n == 6:
|
||||||
|
#return -1 - 1j + np.conj((-1 + math.sqrt(2))**2 / (1 + 1j + z))
|
||||||
|
return -1 - 1j + np.conj(1 / (z + 1 + 1j))
|
||||||
|
elif n == 7:
|
||||||
|
#return 1 - 1j + np.conj((-1 + math.sqrt(2))**2 / (-1 + 1j + z))
|
||||||
|
return 1 - 1j + np.conj(1 / (z - 1 + 1j))
|
||||||
|
|
||||||
|
def derivatives(n, z):
|
||||||
|
if n == 0:
|
||||||
|
#return abs(-((-3 + 2*math.sqrt(2) - (3 - 2*math.sqrt(2))*1j + z)**2 / (-1 + math.sqrt(2))**2))
|
||||||
|
return abs((17+12*math.sqrt(2))*(-3+2*math.sqrt(2)-(3-2*math.sqrt(2))*1j + z)**2)
|
||||||
|
elif n == 1:
|
||||||
|
#return abs(-((3 - 2*math.sqrt(2) - (3 - 2*math.sqrt(2))*1j + z)**2 / (-1 + math.sqrt(2))**2))
|
||||||
|
return abs((17+12*math.sqrt(2))*(3-2*math.sqrt(2)-(3-2*math.sqrt(2))*1j + z)**2)
|
||||||
|
elif n == 2:
|
||||||
|
#return abs(-((3 - 2*math.sqrt(2) - (-3 + 2*math.sqrt(2))*1j + z)**2 / (-1 + math.sqrt(2))**2))
|
||||||
|
return abs((17+12*math.sqrt(2))*(3-2*math.sqrt(2)-(-3+2*math.sqrt(2))*1j + z)**2)
|
||||||
|
elif n == 3:
|
||||||
|
#return abs(-((-3 + 2*math.sqrt(2) - (-3 + 2*math.sqrt(2))*1j + z)**2 / (-1 + math.sqrt(2))**2))
|
||||||
|
return abs((17+12*math.sqrt(2))*(-3+2*math.sqrt(2)-(-3+2*math.sqrt(2))*1j + z)**2)
|
||||||
|
elif n == 4:
|
||||||
|
#return abs(-((-1 - 1j + z)**2 / (-1 + math.sqrt(2))**2))
|
||||||
|
return abs((-1-1j+z)**2)
|
||||||
|
elif n == 5:
|
||||||
|
#return abs(-((1 - 1j + z)**2 / (-1 + math.sqrt(2))**2))
|
||||||
|
return abs((1-1j+z)**2)
|
||||||
|
elif n == 6:
|
||||||
|
#return abs(-((1 + 1j + z)**2 / (-1 + math.sqrt(2))**2))
|
||||||
|
return abs((1+1j+z)**2)
|
||||||
|
elif n == 7:
|
||||||
|
#return abs(-((-1 + 1j + z)**2 / (-1 + math.sqrt(2))**2))
|
||||||
|
return abs((-1+1j+z)**2)
|
||||||
|
|
||||||
|
def samplePoint(word):
|
||||||
|
if word[-1] == 4:
|
||||||
|
p = 1/2 + 1j/2
|
||||||
|
elif word[-1] == 5:
|
||||||
|
p = -1/2 + 1j/2
|
||||||
|
elif word[-1] == 7:
|
||||||
|
p = 1/2 - 1j/2
|
||||||
|
elif word[-1] == 6:
|
||||||
|
p = -1/2 - 1j/2
|
||||||
|
elif word[-1] == 1:
|
||||||
|
p = -3+2*math.sqrt(2) + (3-2*math.sqrt(2))*1j
|
||||||
|
elif word[-1] == 0:
|
||||||
|
p = 3-2*math.sqrt(2) + (3-2*math.sqrt(2))*1j
|
||||||
|
elif word[-1] == 2:
|
||||||
|
p = -3+2*math.sqrt(2) + (-3+2*math.sqrt(2))*1j
|
||||||
|
elif word[-1] == 3:
|
||||||
|
p = 3-2*math.sqrt(2) + (-3+2*math.sqrt(2))*1j
|
||||||
|
for letter in word[-2::-1]:
|
||||||
|
p = functions(letter, p)
|
||||||
|
return p
|
||||||
|
|
||||||
|
def sampleValue(word):
|
||||||
|
return derivatives(word[0], samplePoint(word))
|
||||||
|
|
||||||
|
def generateTree(words, dc):
|
||||||
|
generators = [np.array([[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [3, 3, 0, -1, 4, 0], [4, 2, 0, -1, 4, 0], [0, 0, 0, 0, 1, 0], [4, 3, 0, -1, 3, 0]]),
|
||||||
|
np.array([[1, 0, 0, 0, 0, 0], [3, 0, -1, 3, 4, 0], [2, 0, -1, 4, 4, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [3, 0, -1, 4, 3, 0]]),
|
||||||
|
np.array([[0, 0, 3, 4, 3, -1], [0, 0, 4, 3, 3, -1], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 4, 4, 2, -1]]),
|
||||||
|
np.array([[0, 3, 3, -1, 4, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 2, 4, -1, 4, 0], [0, 0, 0, 0, 1, 0], [0, 3, 4, -1, 3, 0]]),
|
||||||
|
np.array([[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [3, 4, 0, 0, -1, 3], [4, 3, 0, 0, -1, 3], [4, 4, 0, 0, -1, 2], [0, 0, 0, 0, 0, 1]]),
|
||||||
|
np.array([[1, 0, 0, 0, 0, 0], [3, 0, -1, 3, 0, 4], [2, 0, -1, 4, 0, 4], [0, 0, 0, 1, 0, 0], [3, 0, -1, 4, 0, 3], [0, 0, 0, 0, 0, 1]]),
|
||||||
|
np.array([[0, 0, 3, 4, -1, 3], [0, 0, 4, 3, -1, 3], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 4, 4, -1, 2], [0, 0, 0, 0, 0, 1]]),
|
||||||
|
np.array([[0, 3, 3, -1, 0, 4], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 2, 4, -1, 0, 4], [0, 3, 4, -1, 0, 3], [0, 0, 0, 0, 0, 1]])]
|
||||||
|
root = Node([1 + math.sqrt(2), 1 + math.sqrt(2), 1 + math.sqrt(2), 1 + math.sqrt(2), 3 + 2*math.sqrt(2), -1], [], words, False)
|
||||||
|
current_leaves = [root]
|
||||||
|
nodes = 1
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
next_gen = leaf.next_generation(words, dc, generators)
|
||||||
|
new_leaves += next_gen
|
||||||
|
nodes += len(next_gen) if len(next_gen) > 1 else 0
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
for i,leaf in enumerate(current_leaves):
|
||||||
|
words[str(leaf.word)] = i
|
||||||
|
print(len(current_leaves), "partitions")
|
||||||
|
print(nodes,"nodes")
|
||||||
|
return current_leaves
|
||||||
|
|
||||||
|
def constructMatrix(words, dc):
|
||||||
|
leave = generateTree(words, dc)
|
||||||
|
row = []
|
||||||
|
col = []
|
||||||
|
data = []
|
||||||
|
for i,leaf in enumerate(leave):
|
||||||
|
thing = words[str(leaf.word[1:])]
|
||||||
|
if isinstance(thing,int):
|
||||||
|
row.append(i)
|
||||||
|
col.append(thing)
|
||||||
|
data.append(sampleValue(leaf.word))
|
||||||
|
else:
|
||||||
|
sample = sampleValue(leaf.word)
|
||||||
|
for wor in thing.leaves():
|
||||||
|
row.append(i)
|
||||||
|
col.append(words[str(wor.word)])
|
||||||
|
data.append(sample)
|
||||||
|
return csr_matrix((data,(row,col)),shape=(len(leave),len(leave)))
|
||||||
|
|
||||||
|
def secant(x0,y0,x1,y1,z):
|
||||||
|
return x0 - (y0-z) * ((x1-x0)/(y1-y0))
|
||||||
|
|
||||||
|
def matrixFunction(matrix,l,a):
|
||||||
|
matrix = matrix.power(a)
|
||||||
|
vec = np.ones(l)
|
||||||
|
previous_entry = vec[0]
|
||||||
|
previous_val = 0
|
||||||
|
current = matrix * vec
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count = 0
|
||||||
|
while count < 10000000000 and abs(current_val - previous_val) > 1e-15:
|
||||||
|
previous_val = current_val
|
||||||
|
previous_entry = current[0]
|
||||||
|
current = matrix * current
|
||||||
|
#print(current[0],previous_entry)
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count += 1
|
||||||
|
print("power method:", count)
|
||||||
|
return current_val
|
||||||
|
|
||||||
|
def secantMethod(matrix,l,z,x1,x2,e,its):
|
||||||
|
k1 = x1
|
||||||
|
k2 = x2
|
||||||
|
y1 = matrixFunction(matrix,l,k1)
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y1 = testFunction(k1)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count = 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
while abs(y1-z)>e and count<its:
|
||||||
|
k3 = secant(k1,y1,k2,y2,z)
|
||||||
|
k1 = k2
|
||||||
|
y1 = y2
|
||||||
|
k2 = k3
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count += 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
start = time.time()
|
||||||
|
|
||||||
|
words = {}
|
||||||
|
matrix = constructMatrix(words,5000)
|
||||||
|
#print(matrix)
|
||||||
|
|
||||||
|
print("construction (s): %f\nconstruction (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
#print(csr_matrix.transpose(matrix))
|
||||||
|
print(csr_matrix.count_nonzero(matrix), (matrix.shape[0])*7)
|
||||||
|
secantMethod(matrix,matrix.shape[0],1,1.33,1.34,10**(-10),1000)
|
||||||
|
|
||||||
|
print("total (s): %f\ntotal (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
|
||||||
|
main()
|
||||||
68
fractal_dimension/mcmullen_stuff/hexanode.py
Normal file
68
fractal_dimension/mcmullen_stuff/hexanode.py
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
import numpy as np
|
||||||
|
import math
|
||||||
|
|
||||||
|
class Node:
|
||||||
|
def __init__(self, tuple, word, words, infertile):
|
||||||
|
self.tuple = tuple
|
||||||
|
self.children = []
|
||||||
|
self.word = word
|
||||||
|
self.infertile = infertile
|
||||||
|
words[str(word)] = self
|
||||||
|
|
||||||
|
def dc_not_too_big(self, g, generator, dual_curvature):
|
||||||
|
temp = np.matmul(generator, self.tuple)
|
||||||
|
if g == 0:
|
||||||
|
temp = [temp[i] for i in (0,1,6)]
|
||||||
|
elif g == 1:
|
||||||
|
temp = [temp[i] for i in (1,2,6)]
|
||||||
|
elif g == 2:
|
||||||
|
temp = [temp[i] for i in (2,3,6)]
|
||||||
|
elif g == 3:
|
||||||
|
temp = [temp[i] for i in (3,4,6)]
|
||||||
|
elif g == 4:
|
||||||
|
temp = [temp[i] for i in (4,5,6)]
|
||||||
|
elif g == 5:
|
||||||
|
temp = [temp[i] for i in (0,5,6)]
|
||||||
|
elif g == 6:
|
||||||
|
temp = [temp[i] for i in (0,1,7)]
|
||||||
|
elif g == 7:
|
||||||
|
temp = [temp[i] for i in (1,2,7)]
|
||||||
|
elif g == 8:
|
||||||
|
temp = [temp[i] for i in (2,3,7)]
|
||||||
|
elif g == 9:
|
||||||
|
temp = [temp[i] for i in (3,4,7)]
|
||||||
|
elif g == 10:
|
||||||
|
temp = [temp[i] for i in (4,5,7)]
|
||||||
|
elif g == 11:
|
||||||
|
temp = [temp[i] for i in (0,5,7)]
|
||||||
|
return math.sqrt(temp[0]*temp[1] + temp[0]*temp[2] + temp[1]*temp[2]) < dual_curvature
|
||||||
|
|
||||||
|
def next_generation(self, words, dual_curvature, generators):
|
||||||
|
if self.infertile:
|
||||||
|
return [self]
|
||||||
|
if self.children == []:
|
||||||
|
for g,generator in enumerate(generators):
|
||||||
|
if len(self.word) == 0 or g != self.word[-1]:
|
||||||
|
self.children.append(Node(np.matmul(generator,self.tuple), self.word[:] + [g], words, not self.dc_not_too_big(g, generator, dual_curvature)))
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def leaves(self):
|
||||||
|
current_leaves = [self]
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
new_leaves += leaf.next()
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
return current_leaves
|
||||||
227
fractal_dimension/mcmullen_stuff/hexatreemcmullen.py
Normal file
227
fractal_dimension/mcmullen_stuff/hexatreemcmullen.py
Normal file
|
|
@ -0,0 +1,227 @@
|
||||||
|
from hexanode import Node
|
||||||
|
import math
|
||||||
|
import numpy as np
|
||||||
|
import time
|
||||||
|
from scipy.sparse import csr_matrix
|
||||||
|
from scipy import stats
|
||||||
|
|
||||||
|
def functions(n, z):
|
||||||
|
if n == 0:
|
||||||
|
return 0.333333333333333 + 0.192450089729875j + np.conj(0.0370370370370370/(-0.333333333333333 - 0.192450089729875j + z))
|
||||||
|
elif n == 1:
|
||||||
|
return 0.384900179459751j + np.conj(0.0370370370370370/(-0.384900179459751j + z))
|
||||||
|
elif n == 2:
|
||||||
|
return -0.333333333333333 + 0.192450089729875j + np.conj(0.0370370370370370/(0.333333333333333 - 0.192450089729875j + z))
|
||||||
|
elif n == 3:
|
||||||
|
return -0.333333333333333 - 0.192450089729875j + np.conj(0.0370370370370370/(0.333333333333333 + 0.192450089729875j + z))
|
||||||
|
elif n == 4:
|
||||||
|
return -0.384900179459751j + np.conj(0.0370370370370370/(0.384900179459751j + z))
|
||||||
|
elif n == 5:
|
||||||
|
return 0.333333333333333 - 0.192450089729875j + np.conj(0.0370370370370370/(-0.333333333333333 + 0.192450089729875j + z))
|
||||||
|
elif n == 6:
|
||||||
|
return 1.00000000000000 + 0.577350269189626j + np.conj(0.333333333333333/(-1.00000000000000 - 0.577350269189626j + z))
|
||||||
|
elif n == 7:
|
||||||
|
return 1.15470053837925j + np.conj(0.333333333333333/(-1.15470053837925j + z))
|
||||||
|
elif n == 8:
|
||||||
|
return -1.00000000000000 + 0.577350269189626j + np.conj(0.333333333333333/(1.00000000000000 - 0.577350269189626j + z))
|
||||||
|
elif n == 9:
|
||||||
|
return -1.00000000000000 - 0.577350269189626j + np.conj(0.333333333333333/(1.00000000000000 + 0.577350269189626j + z))
|
||||||
|
elif n == 10:
|
||||||
|
return -1.15470053837925j + np.conj(0.333333333333333/(1.15470053837925j + z))
|
||||||
|
elif n == 11:
|
||||||
|
return 1.00000000000000 - 0.577350269189626j + np.conj(0.333333333333333/(-1.00000000000000 + 0.577350269189626j + z))
|
||||||
|
|
||||||
|
def derivatives(n, z):
|
||||||
|
if n == 0:
|
||||||
|
return abs(-27.0000000000000*(-0.333333333333333 - 0.192450089729875j + z)**2)
|
||||||
|
elif n == 1:
|
||||||
|
return abs(-27.0000000000000*(-0.384900179459751j + z)**2)
|
||||||
|
elif n == 2:
|
||||||
|
return abs(-27.0000000000000*(0.333333333333333 - 0.192450089729875j + z)**2)
|
||||||
|
elif n == 3:
|
||||||
|
return abs(-27.0000000000000*(0.333333333333333 + 0.192450089729875j + z)**2)
|
||||||
|
elif n == 4:
|
||||||
|
return abs(-27.0000000000000*(0.384900179459751j + z)**2)
|
||||||
|
elif n == 5:
|
||||||
|
return abs(-27.0000000000000*(-0.333333333333333 + 0.192450089729875j + z)**2)
|
||||||
|
elif n == 6:
|
||||||
|
return abs(-3.00000000000000*(-1.00000000000000 - 0.577350269189626j + z)**2)
|
||||||
|
elif n == 7:
|
||||||
|
return abs(-3.00000000000000*(-1.15470053837925j + z)**2)
|
||||||
|
elif n == 8:
|
||||||
|
return abs(-3.00000000000000*(1.00000000000000 - 0.577350269189626j + z)**2)
|
||||||
|
elif n == 9:
|
||||||
|
return abs(-3.00000000000000*(1.00000000000000 + 0.577350269189626j + z)**2)
|
||||||
|
elif n == 10:
|
||||||
|
return abs(-3.00000000000000*(1.15470053837925j + z)**2)
|
||||||
|
elif n == 11:
|
||||||
|
return abs(-3.00000000000000*(-1.00000000000000 + 0.577350269189626j + z)**2)
|
||||||
|
|
||||||
|
def samplePoint(word):
|
||||||
|
points = [0.333333333333333 + 0.192450089729875j,
|
||||||
|
0.384900179459751j,
|
||||||
|
-0.333333333333333 + 0.192450089729875j,
|
||||||
|
-0.333333333333333 - 0.192450089729875j,
|
||||||
|
-0.384900179459751j,
|
||||||
|
0.333333333333333 - 0.192450089729875j,
|
||||||
|
0.750000000000000 + 0.433012701892219j,
|
||||||
|
0.866025403784439j,
|
||||||
|
-0.750000000000000 + 0.433012701892219j,
|
||||||
|
-0.750000000000000 - 0.433012701892219j,
|
||||||
|
-0.866025403784439j,
|
||||||
|
0.750000000000000 - 0.433012701892219j]
|
||||||
|
p = points[word[-1]]
|
||||||
|
for letter in word[-2::-1]:
|
||||||
|
p = functions(letter, p)
|
||||||
|
return p
|
||||||
|
|
||||||
|
def sampleValue(word):
|
||||||
|
return derivatives(word[0], samplePoint(word))
|
||||||
|
|
||||||
|
def generateTree(words, dc):
|
||||||
|
generators = [np.array([[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [2, 6, -1, 0, 0,
|
||||||
|
0, 6, 0], [5, 10, -2, 0, 0, 0, 12, 0], [6, 9, -2, 0, 0, 0, 12,
|
||||||
|
0], [4, 4, -1, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 0, 1, 0], [2, 10/
|
||||||
|
3, -(2/3), 0, 0, 0, 3, 0]]),
|
||||||
|
np.array([[0, 5, 3, 0, 0, 0, 9/2, -(3/2)], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1,
|
||||||
|
0, 0, 0, 0, 0], [0, 3, 5, 0, 0, 0, 9/2, -(3/2)], [0, 7, 8, 0, 0, 0,
|
||||||
|
9, -3], [0, 8, 7, 0, 0, 0, 9, -3], [0, 0, 0, 0, 0, 0, 1, 0], [0, 8/
|
||||||
|
3, 8/3, 0, 0, 0, 2, -1]]),
|
||||||
|
np.array([[0, -2, 10, 5, 0, 0, 12, 0], [0, -1, 6, 2, 0, 0, 6, 0], [0, 0, 1, 0,
|
||||||
|
0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, -1, 4, 4, 0, 0, 6,
|
||||||
|
0], [0, -2, 9, 6, 0, 0, 12, 0], [0, 0, 0, 0, 0, 0, 1,
|
||||||
|
0], [0, -(2/3), 10/3, 2, 0, 0, 3, 0]]),
|
||||||
|
np.array([[-1, 0, 0, 6, 8, 0, 12, 0], [-1, 0, 0, 7, 7, 0, 12, 0], [-(1/2), 0,
|
||||||
|
0, 9/2, 3, 0, 6, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0,
|
||||||
|
0], [-(1/2), 0, 0, 5/2, 5, 0, 6, 0], [0, 0, 0, 0, 0, 0, 1,
|
||||||
|
0], [-(1/3), 0, 0, 7/3, 8/3, 0, 3, 0]]),
|
||||||
|
np.array([[-1, 0, 0, 0, 2, 6, 6, 0], [-2, 0, 0, 0, 5, 10, 12, 0], [-2, 0, 0, 0,
|
||||||
|
6, 9, 12, 0], [-1, 0, 0, 0, 4, 4, 6, 0], [0, 0, 0, 0, 1, 0, 0,
|
||||||
|
0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [-(2/3), 0,
|
||||||
|
0, 0, 2, 10/3, 3, 0]]),
|
||||||
|
np.array([[1, 0, 0, 0, 0, 0, 0, 0], [4, 0, 0, 0, -1, 4, 6, 0], [6, 0, 0, 0, -2,
|
||||||
|
9, 12, 0], [5, 0, 0, 0, -2, 10, 12, 0], [2, 0, 0, 0, -1, 6, 6,
|
||||||
|
0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [2, 0, 0,
|
||||||
|
0, -(2/3), 10/3, 3, 0]]),
|
||||||
|
np.array([[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [4, 4, 0, 0,
|
||||||
|
0, -1, 0, 6], [9, 6, 0, 0, 0, -2, 0, 12], [10, 5, 0, 0, 0, -2, 0,
|
||||||
|
12], [6, 2, 0, 0, 0, -1, 0, 6], [10/3, 2, 0, 0, 0, -(2/3), 0,
|
||||||
|
3], [0, 0, 0, 0, 0, 0, 0, 1]]),
|
||||||
|
np.array([[0, 4, 4, -1, 0, 0, 0, 6], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0,
|
||||||
|
0, 0, 0], [0, 2, 6, -1, 0, 0, 0, 6], [0, 5, 10, -2, 0, 0, 0,
|
||||||
|
12], [0, 6, 9, -2, 0, 0, 0, 12], [0, 2, 10/3, -(2/3), 0, 0, 0,
|
||||||
|
3], [0, 0, 0, 0, 0, 0, 0, 1]]),
|
||||||
|
np.array([[0, 0, 7, 7, 0, -1, 0, 12], [0, 0, 9/2, 3, 0, -(1/2), 0, 6], [0, 0,
|
||||||
|
1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 5/2, 5,
|
||||||
|
0, -(1/2), 0, 6], [0, 0, 6, 8, 0, -1, 0, 12], [0, 0, 7/3, 8/3,
|
||||||
|
0, -(1/3), 0, 3], [0, 0, 0, 0, 0, 0, 0, 1]]),
|
||||||
|
np.array([[0, -1, 0, 7, 7, 0, 0, 12], [0, -1, 0, 8, 6, 0, 0, 12], [0, -(1/2),
|
||||||
|
0, 5, 5/2, 0, 0, 6], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0,
|
||||||
|
0], [0, -(1/2), 0, 3, 9/2, 0, 0, 6], [0, -(1/3), 0, 8/3, 7/3, 0, 0,
|
||||||
|
3], [0, 0, 0, 0, 0, 0, 0, 1]]),
|
||||||
|
np.array([[0, 0, -(1/2), 0, 3, 9/2, 0, 6], [0, 0, -1, 0, 7, 7, 0, 12], [0,
|
||||||
|
0, -1, 0, 8, 6, 0, 12], [0, 0, -(1/2), 0, 5, 5/2, 0, 6], [0, 0, 0,
|
||||||
|
0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, -(1/3), 0, 8/3, 7/
|
||||||
|
3, 0, 3], [0, 0, 0, 0, 0, 0, 0, 1]]),
|
||||||
|
np.array([[1, 0, 0, 0, 0, 0, 0, 0], [5, 0, -(1/2), 0, 0, 5/2, 0, 6], [8, 0, -1,
|
||||||
|
0, 0, 6, 0, 12], [7, 0, -1, 0, 0, 7, 0, 12], [3, 0, -(1/2), 0, 0,
|
||||||
|
9/2, 0, 6], [0, 0, 0, 0, 0, 1, 0, 0], [8/3, 0, -(1/3), 0, 0, 7/3, 0,
|
||||||
|
3], [0, 0, 0, 0, 0, 0, 0, 1]])]
|
||||||
|
|
||||||
|
root = Node([3, 3, 3, 3, 3, 3, 3, -1], [], words, False)
|
||||||
|
current_leaves = [root]
|
||||||
|
nodes = 1
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
next_gen = leaf.next_generation(words, dc, generators)
|
||||||
|
new_leaves += next_gen
|
||||||
|
nodes += len(next_gen) if len(next_gen) > 1 else 0
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
for i,leaf in enumerate(current_leaves):
|
||||||
|
words[str(leaf.word)] = i
|
||||||
|
print(len(current_leaves), "partitions")
|
||||||
|
print(nodes,"nodes")
|
||||||
|
return current_leaves
|
||||||
|
|
||||||
|
def constructMatrix(words, dc):
|
||||||
|
leave = generateTree(words, dc)
|
||||||
|
row = []
|
||||||
|
col = []
|
||||||
|
data = []
|
||||||
|
for i,leaf in enumerate(leave):
|
||||||
|
thing = words[str(leaf.word[1:])]
|
||||||
|
if isinstance(thing,int):
|
||||||
|
row.append(i)
|
||||||
|
col.append(thing)
|
||||||
|
data.append(sampleValue(leaf.word))
|
||||||
|
else:
|
||||||
|
sample = sampleValue(leaf.word)
|
||||||
|
for wor in thing.leaves():
|
||||||
|
row.append(i)
|
||||||
|
col.append(words[str(wor.word)])
|
||||||
|
data.append(sample)
|
||||||
|
return csr_matrix((data,(row,col)),shape=(len(leave),len(leave)))
|
||||||
|
|
||||||
|
def secant(x0,y0,x1,y1,z):
|
||||||
|
return x0 - (y0-z) * ((x1-x0)/(y1-y0))
|
||||||
|
|
||||||
|
def matrixFunction(matrix,l,a):
|
||||||
|
matrix = matrix.power(a)
|
||||||
|
vec = np.ones(l)
|
||||||
|
previous_entry = vec[0]
|
||||||
|
previous_val = 0
|
||||||
|
current = matrix * vec
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count = 0
|
||||||
|
while count < 10000000000 and abs(current_val - previous_val) > 1e-15:
|
||||||
|
previous_val = current_val
|
||||||
|
previous_entry = current[0]
|
||||||
|
current = matrix * current
|
||||||
|
#print(current[0],previous_entry)
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count += 1
|
||||||
|
print("power method:", count)
|
||||||
|
return current_val
|
||||||
|
|
||||||
|
def secantMethod(matrix,l,z,x1,x2,e,its):
|
||||||
|
k1 = x1
|
||||||
|
k2 = x2
|
||||||
|
y1 = matrixFunction(matrix,l,k1)
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y1 = testFunction(k1)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count = 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
while abs(y1-z)>e and count<its:
|
||||||
|
k3 = secant(k1,y1,k2,y2,z)
|
||||||
|
k1 = k2
|
||||||
|
y1 = y2
|
||||||
|
k2 = k3
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count += 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
start = time.time()
|
||||||
|
|
||||||
|
words = {}
|
||||||
|
|
||||||
|
m = 1000
|
||||||
|
print("maximum:",m)
|
||||||
|
|
||||||
|
matrix = constructMatrix(words,m)
|
||||||
|
#print(matrix)
|
||||||
|
|
||||||
|
print("construction (s): %f\nconstruction (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
#print(csr_matrix.transpose(matrix))
|
||||||
|
print(csr_matrix.count_nonzero(matrix), (matrix.shape[0])*11)
|
||||||
|
secantMethod(matrix,matrix.shape[0],1,1.33,1.34,10**(-10),1000)
|
||||||
|
|
||||||
|
print("total (s): %f\ntotal (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
|
||||||
|
main()
|
||||||
51
fractal_dimension/mcmullen_stuff/node.py
Normal file
51
fractal_dimension/mcmullen_stuff/node.py
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
import numpy as np
|
||||||
|
import math
|
||||||
|
|
||||||
|
class Node:
|
||||||
|
def __init__(self, tuple, word, words, infertile):
|
||||||
|
self.tuple = tuple
|
||||||
|
self.children = []
|
||||||
|
self.word = word
|
||||||
|
self.infertile = infertile
|
||||||
|
words[str(word)] = self
|
||||||
|
|
||||||
|
def dc_not_too_big(self, g, generator, dual_curvature):
|
||||||
|
temp = np.matmul(generator, self.tuple)
|
||||||
|
temp = np.delete(temp,g)
|
||||||
|
#print(g, self.word, math.sqrt(temp[0]*temp[1] + temp[0]*temp[2] + temp[1]*temp[2]), math.sqrt(temp[0]*temp[1] + temp[0]*temp[2] + temp[1]*temp[2]) < dual_curvature)
|
||||||
|
return math.sqrt(temp[0]*temp[1] + temp[0]*temp[2] + temp[1]*temp[2]) < dual_curvature
|
||||||
|
|
||||||
|
def next_generation(self, words, dual_curvature, generators):
|
||||||
|
if self.infertile:
|
||||||
|
return [self]
|
||||||
|
if self.children == []:
|
||||||
|
for g,generator in enumerate(generators):
|
||||||
|
if len(self.word) == 0 or g != self.word[-1]:
|
||||||
|
self.children.append(Node(np.matmul(generator,self.tuple), self.word[:] + [g], words, not self.dc_not_too_big(g, generator, dual_curvature)))
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def leaves(self):
|
||||||
|
current_leaves = [self]
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
new_leaves += leaf.next()
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
return current_leaves
|
||||||
|
|
||||||
|
def dual_curvature(self):
|
||||||
|
temp = self.tuple[:]
|
||||||
|
temp = np.delete(temp,self.word[-1])
|
||||||
|
return math.sqrt(temp[0]*temp[1] + temp[0]*temp[2] + temp[1]*temp[2])
|
||||||
48
fractal_dimension/mcmullen_stuff/nonanode.py
Normal file
48
fractal_dimension/mcmullen_stuff/nonanode.py
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
import numpy as np
|
||||||
|
import math
|
||||||
|
|
||||||
|
class Node:
|
||||||
|
def __init__(self, tuple, word, words, infertile):
|
||||||
|
self.tuple = tuple
|
||||||
|
self.children = []
|
||||||
|
self.word = word
|
||||||
|
self.infertile = infertile
|
||||||
|
words[str(word)] = self
|
||||||
|
|
||||||
|
def dc_not_too_big(self, g, generator, dual_curvature):
|
||||||
|
temp = np.matmul(generator, self.tuple)
|
||||||
|
if g <= 8:
|
||||||
|
temp = [temp[i] for i in (g%9, (g+1)%9, 9)]
|
||||||
|
else:
|
||||||
|
temp = [temp[i] for i in (g%9, (g+1)%9, 10)]
|
||||||
|
return math.sqrt(temp[0]*temp[1] + temp[0]*temp[2] + temp[1]*temp[2]) < dual_curvature
|
||||||
|
|
||||||
|
def next_generation(self, words, dual_curvature, generators):
|
||||||
|
if self.infertile:
|
||||||
|
return [self]
|
||||||
|
if self.children == []:
|
||||||
|
for g,generator in enumerate(generators):
|
||||||
|
if len(self.word) == 0 or g != self.word[-1]:
|
||||||
|
self.children.append(Node(np.matmul(generator,self.tuple), self.word[:] + [g], words, not self.dc_not_too_big(g, generator, dual_curvature)))
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def leaves(self):
|
||||||
|
current_leaves = [self]
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
new_leaves += leaf.next()
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
return current_leaves
|
||||||
361
fractal_dimension/mcmullen_stuff/nonatree.py
Normal file
361
fractal_dimension/mcmullen_stuff/nonatree.py
Normal file
|
|
@ -0,0 +1,361 @@
|
||||||
|
from nonanode import Node
|
||||||
|
import math
|
||||||
|
import numpy as np
|
||||||
|
import time
|
||||||
|
from scipy.sparse import csr_matrix
|
||||||
|
|
||||||
|
def functions(n, z):
|
||||||
|
duals = [[0.490290596565702+0.178451183290535j,
|
||||||
|
0.178451183290535], [0.260878177459588+0.451854257945975j,
|
||||||
|
0.178451183290535], [-0.0906020402178549+0.513829703507793j,
|
||||||
|
0.178451183290535], [-0.399688556347847+0.335378520217258j,
|
||||||
|
0.178451183290535], [-0.521756354919175,
|
||||||
|
0.178451183290535], [-0.399688556347847-0.335378520217258j,
|
||||||
|
0.178451183290535], [-0.0906020402178549-0.513829703507793j,
|
||||||
|
0.178451183290535], [0.260878177459588-0.451854257945975j,
|
||||||
|
0.178451183290535], [0.490290596565702-0.178451183290535j,
|
||||||
|
0.178451183290535], [1.00000000000000+0.363970234266202j,
|
||||||
|
0.363970234266202], [0.532088886237956+0.921604985106876j,
|
||||||
|
0.363970234266202], [-0.184792530904095+1.04801052091754j,
|
||||||
|
0.363970234266202], [-0.815207469095905+0.684040286651337j,
|
||||||
|
0.363970234266202], [-1.06417777247591,
|
||||||
|
0.363970234266202], [-0.815207469095905-0.684040286651337j,
|
||||||
|
0.363970234266202], [-0.184792530904095-1.04801052091754j,
|
||||||
|
0.363970234266202], [0.532088886237956-0.921604985106876j,
|
||||||
|
0.363970234266202], [1.00000000000000-0.363970234266202j,
|
||||||
|
0.363970234266202]]
|
||||||
|
return duals[n][0] + np.conj((duals[n][1])**2 / (z-duals[n][0]))
|
||||||
|
|
||||||
|
def derivatives(n, z):
|
||||||
|
duals = [[0.490290596565702 + 0.178451183290535j,
|
||||||
|
0.178451183290535], [0.260878177459588 + 0.451854257945975j,
|
||||||
|
0.178451183290535], [-0.0906020402178549 + 0.513829703507793j,
|
||||||
|
0.178451183290535], [-0.399688556347847 + 0.335378520217258j,
|
||||||
|
0.178451183290535], [-0.521756354919175,
|
||||||
|
0.178451183290535], [-0.399688556347847 - 0.335378520217258j,
|
||||||
|
0.178451183290535], [-0.0906020402178549 - 0.513829703507793j,
|
||||||
|
0.178451183290535], [0.260878177459588 - 0.451854257945975j,
|
||||||
|
0.178451183290535], [0.490290596565702 - 0.178451183290535j,
|
||||||
|
0.178451183290535], [1.00000000000000 + 0.363970234266202j,
|
||||||
|
0.363970234266202], [0.532088886237956 + 0.921604985106876j,
|
||||||
|
0.363970234266202], [-0.184792530904095 + 1.04801052091754j,
|
||||||
|
0.363970234266202], [-0.815207469095905 + 0.684040286651337j,
|
||||||
|
0.363970234266202], [-1.06417777247591,
|
||||||
|
0.363970234266202], [-0.815207469095905 - 0.684040286651337j,
|
||||||
|
0.363970234266202], [-0.184792530904095 - 1.04801052091754j,
|
||||||
|
0.363970234266202], [0.532088886237956 - 0.921604985106876j,
|
||||||
|
0.363970234266202], [1.00000000000000 - 0.363970234266202j,
|
||||||
|
0.363970234266202]]
|
||||||
|
return abs(-1*((z-duals[n][0])**2) / ((duals[n][1])**2))
|
||||||
|
|
||||||
|
def samplePoint(word):
|
||||||
|
points = [0.5148051263939873 + 0.18737374245506147j, 0.2739220863325669 +
|
||||||
|
0.47444697084327425j, -0.09513214222874763 +
|
||||||
|
0.5395211886831826j, -0.4196729841652397 +
|
||||||
|
0.3521474462281211j, -0.5478441726651339, -0.4196729841652397 -
|
||||||
|
0.3521474462281211j, -0.09513214222874763 -
|
||||||
|
0.5395211886831826j, 0.2739220863325669 -
|
||||||
|
0.47444697084327425j, 0.5148051263939873 -
|
||||||
|
0.18737374245506147j, 0.8 +
|
||||||
|
0.29117618741296186j, 0.42567110899036487 +
|
||||||
|
0.7372839880855011j, -0.1478340247232763 +
|
||||||
|
0.838408416734032j, -0.6521659752767237 +
|
||||||
|
0.54723222932107j, -0.8513422179807297, -0.6521659752767237 -
|
||||||
|
0.54723222932107j, -0.1478340247232763 -
|
||||||
|
0.838408416734032j, 0.42567110899036487 -
|
||||||
|
0.7372839880855011j, 0.8 - 0.29117618741296186j]
|
||||||
|
p = points[word[-1]]
|
||||||
|
for letter in word[-2::-1]:
|
||||||
|
p = functions(letter, p)
|
||||||
|
return p
|
||||||
|
|
||||||
|
def sampleValue(word):
|
||||||
|
return derivatives(word[0], samplePoint(word))
|
||||||
|
|
||||||
|
def generateTree(words, dc):
|
||||||
|
generators = [np.array([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 1., 0., 0., 0.,
|
||||||
|
0., 0., 0., 0., 0., 0.], [2.87939, 5.41147, 0., 0., 0., -0.226682,
|
||||||
|
0., 0., 0., 7.06418, 0.], [8.29086, 11.1702, 0., 0., 0., -0.573978,
|
||||||
|
0., 0., 0., 17.8871, 0.], [13.7023, 15.5817, 0., 0., 0., -0.879385,
|
||||||
|
0., 0., 0., 27.4047, 0.], [16.5817, 16.5817, 0., 0., 0., -1., 0.,
|
||||||
|
0., 0., 31.1634, 0.], [15.5817, 13.7023, 0., 0., 0., -0.879385, 0.,
|
||||||
|
0., 0., 27.4047, 0.], [11.1702, 8.29086, 0., 0., 0., -0.573978, 0.,
|
||||||
|
0., 0., 17.8871, 0.], [5.41147, 2.87939, 0., 0., 0., -0.226682, 0.,
|
||||||
|
0., 0., 7.06418, 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 1.,
|
||||||
|
0.], [2.19665, 2.19665, 0., 0., 0., -0.128356, 0., 0., 0., 3., 0.]]),
|
||||||
|
np.array([[0., 4.92702, 3.53209, 0., -0.394931, 0., 0., 0., 0., 7.06418,
|
||||||
|
0.], [0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 1., 0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 0.], [0., 2.39493, 6.06418, 0., -0.394931,
|
||||||
|
0., 0., 0., 0., 7.06418, 0.], [0., 7.06418, 12.8229, 0., -1., 0.,
|
||||||
|
0., 0., 0., 17.8871, 0.], [0., 11.8229, 18.1138, 0., -1.53209, 0.,
|
||||||
|
0., 0., 0., 27.4047, 0.], [0., 14.4446, 19.4611, 0., -1.74223, 0.,
|
||||||
|
0., 0., 0., 31.1634, 0.], [0., 13.7023, 16.2344, 0., -1.53209, 0.,
|
||||||
|
0., 0., 0., 27.4047, 0.], [0., 9.94356, 9.94356, 0., -1., 0., 0.,
|
||||||
|
0., 0., 17.8871, 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 1.,
|
||||||
|
0.], [0., 1.92234, 2.56624, 0., -0.223625, 0., 0., 0., 0., 3., 0.]]),
|
||||||
|
np.array([[0., 0., 11.1702, 8.29086, 0., 0., 0., -0.573978, 0., 17.8871,
|
||||||
|
0.], [0., 0., 5.41147, 2.87939, 0., 0., 0., -0.226682, 0., 7.06418,
|
||||||
|
0.], [0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 1.,
|
||||||
|
0., 0., 0., 0., 0., 0., 0.], [0., 0., 2.87939, 5.41147, 0., 0.,
|
||||||
|
0., -0.226682, 0., 7.06418, 0.], [0., 0., 8.29086, 11.1702, 0., 0.,
|
||||||
|
0., -0.573978, 0., 17.8871, 0.], [0., 0., 13.7023, 15.5817, 0., 0.,
|
||||||
|
0., -0.879385, 0., 27.4047, 0.], [0., 0., 16.5817, 16.5817, 0., 0.,
|
||||||
|
0., -1., 0., 31.1634, 0.], [0., 0., 15.5817, 13.7023, 0., 0.,
|
||||||
|
0., -0.879385, 0., 27.4047, 0.], [0., 0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 1., 0.], [0., 0., 2.19665, 2.19665, 0., 0., 0., -0.128356, 0.,
|
||||||
|
3., 0.]]),
|
||||||
|
np.array([[0., -1.53209, 0., 18.1138, 11.8229, 0., 0., 0., 0., 27.4047,
|
||||||
|
0.], [0., -1., 0., 12.8229, 7.06418, 0., 0., 0., 0., 17.8871,
|
||||||
|
0.], [0., -0.394931, 0., 6.06418, 2.39493, 0., 0., 0., 0., 7.06418,
|
||||||
|
0.], [0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0.,
|
||||||
|
1., 0., 0., 0., 0., 0., 0.], [0., -0.394931, 0., 3.53209, 4.92702,
|
||||||
|
0., 0., 0., 0., 7.06418, 0.], [0., -1., 0., 9.94356, 9.94356, 0.,
|
||||||
|
0., 0., 0., 17.8871, 0.], [0., -1.53209, 0., 16.2344, 13.7023, 0.,
|
||||||
|
0., 0., 0., 27.4047, 0.], [0., -1.74223, 0., 19.4611, 14.4446, 0.,
|
||||||
|
0., 0., 0., 31.1634, 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 1.,
|
||||||
|
0.], [0., -0.223625, 0., 2.56624, 1.92234, 0., 0., 0., 0., 3., 0.]]),
|
||||||
|
np.array([[0., -1.13716, 0., 0., 17.7189, 15.5817, 0., 0., 0., 31.1634,
|
||||||
|
0.], [0., -1., 0., 0., 16.5817, 12.8229, 0., 0., 0., 27.4047,
|
||||||
|
0.], [0., -0.652704, 0., 0., 11.8229, 7.71688, 0., 0., 0., 17.8871,
|
||||||
|
0.], [0., -0.257773, 0., 0., 5.66925, 2.6527, 0., 0., 0., 7.06418,
|
||||||
|
0.], [0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0.,
|
||||||
|
0., 1., 0., 0., 0., 0., 0.], [0., -0.257773, 0., 0., 3.13716,
|
||||||
|
5.18479, 0., 0., 0., 7.06418, 0.], [0., -0.652704, 0., 0., 8.94356,
|
||||||
|
10.5963, 0., 0., 0., 17.8871, 0.], [0., -1., 0., 0., 14.7023,
|
||||||
|
14.7023, 0., 0., 0., 27.4047, 0.], [0., 0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 1., 0.], [0., -0.145961, 0., 0., 2.34261, 2.0683, 0., 0., 0.,
|
||||||
|
3., 0.]]),
|
||||||
|
np.array([[0., 0., 0., 0., 0., 10.2909, 21.9932, -3.87939, 0., 27.4047,
|
||||||
|
0.], [0., 0., 0., 0., 0., 12.7023, 23.8726, -4.41147, 0., 31.1634,
|
||||||
|
0.], [0., 0., 0., 0., 0., 12.1702, 20.1138, -3.87939, 0., 27.4047,
|
||||||
|
0.], [0., 0., 0., 0., 0., 8.94356, 12.4757, -2.53209, 0., 17.8871,
|
||||||
|
0.], [0., 0., 0., 0., 0., 4.53209, 4.53209, -1., 0., 7.06418,
|
||||||
|
0.], [0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.], [0., 0., 0., 0.,
|
||||||
|
0., 0., 1., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 2., 7.06418, -1.,
|
||||||
|
0., 7.06418, 0.], [0., 0., 0., 0., 0., 6.06418, 15.355, -2.53209,
|
||||||
|
0., 17.8871, 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0.], [0.,
|
||||||
|
0., 0., 0., 0., 1.69871, 3.13247, -0.566237, 0., 3., 0.]]),
|
||||||
|
np.array([[-1., 0., 0., 0., 0., 0., 7.06418, 12.8229, 0., 17.8871,
|
||||||
|
0.], [-1.53209, 0., 0., 0., 0., 0., 11.8229, 18.1138, 0., 27.4047,
|
||||||
|
0.], [-1.74223, 0., 0., 0., 0., 0., 14.4446, 19.4611, 0., 31.1634,
|
||||||
|
0.], [-1.53209, 0., 0., 0., 0., 0., 13.7023, 16.2344, 0., 27.4047,
|
||||||
|
0.], [-1., 0., 0., 0., 0., 0., 9.94356, 9.94356, 0., 17.8871,
|
||||||
|
0.], [-0.394931, 0., 0., 0., 0., 0., 4.92702, 3.53209, 0., 7.06418,
|
||||||
|
0.], [0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0.], [0., 0., 0., 0.,
|
||||||
|
0., 0., 0., 1., 0., 0., 0.], [-0.394931, 0., 0., 0., 0., 0.,
|
||||||
|
2.39493, 6.06418, 0., 7.06418, 0.], [0., 0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 1., 0.], [-0.223625, 0., 0., 0., 0., 0., 1.92234, 2.56624, 0.,
|
||||||
|
3., 0.]]),
|
||||||
|
np.array([[0., 0., 0., 0., 0., 0., 0., 3., 5.53209, 5.29813, -1.76604], [0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 8.59627, 11.4757, 13.4153, -4.47178], [0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 14.1702, 16.0496, 20.5535, -6.85117], [0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 17.1138, 17.1138, 23.3726, -7.79086], [0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 16.0496, 14.1702, 20.5535, -6.85117], [0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 11.4757, 8.59627, 13.4153, -4.47178], [0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 5.53209, 3., 5.29813, -1.76604], [0., 0.,
|
||||||
|
0., 0., 0., 0., 0., 1., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 1., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0.], [0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 2.26495, 2.26495, 2., -1.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [7.06418, -1., 0., 0.,
|
||||||
|
0., 0., 0., 0., 2., 7.06418, 0.], [15.355, -2.53209, 0., 0., 0., 0.,
|
||||||
|
0., 0., 6.06418, 17.8871, 0.], [21.9932, -3.87939, 0., 0., 0., 0.,
|
||||||
|
0., 0., 10.2909, 27.4047, 0.], [23.8726, -4.41147, 0., 0., 0., 0.,
|
||||||
|
0., 0., 12.7023, 31.1634, 0.], [20.1138, -3.87939, 0., 0., 0., 0.,
|
||||||
|
0., 0., 12.1702, 27.4047, 0.], [12.4757, -2.53209, 0., 0., 0., 0.,
|
||||||
|
0., 0., 8.94356, 17.8871, 0.], [4.53209, -1., 0., 0., 0., 0., 0.,
|
||||||
|
0., 4.53209, 7.06418, 0.], [0., 0., 0., 0., 0., 0., 0., 0., 1., 0.,
|
||||||
|
0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 1.,
|
||||||
|
0.], [3.13247, -0.566237, 0., 0., 0., 0., 0., 0., 1.69871, 3., 0.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 1., 0., 0., 0.,
|
||||||
|
0., 0., 0., 0., 0., 0.], [2.87939, 5.41147, 0., 0., 0., -0.226682,
|
||||||
|
0., 0., 0., 0., 7.06418], [8.29086, 11.1702, 0., 0., 0., -0.573978,
|
||||||
|
0., 0., 0., 0., 17.8871], [13.7023, 15.5817, 0., 0., 0., -0.879385,
|
||||||
|
0., 0., 0., 0., 27.4047], [16.5817, 16.5817, 0., 0., 0., -1., 0.,
|
||||||
|
0., 0., 0., 31.1634], [15.5817, 13.7023, 0., 0., 0., -0.879385, 0.,
|
||||||
|
0., 0., 0., 27.4047], [11.1702, 8.29086, 0., 0., 0., -0.573978, 0.,
|
||||||
|
0., 0., 0., 17.8871], [5.41147, 2.87939, 0., 0., 0., -0.226682, 0.,
|
||||||
|
0., 0., 0., 7.06418], [2.19665, 2.19665, 0., 0., 0., -0.128356, 0.,
|
||||||
|
0., 0., 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[0., 4.92702, 3.53209, 0., -0.394931, 0., 0., 0., 0., 0.,
|
||||||
|
7.06418], [0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 1.,
|
||||||
|
0., 0., 0., 0., 0., 0., 0., 0.], [0., 2.39493, 6.06418,
|
||||||
|
0., -0.394931, 0., 0., 0., 0., 0., 7.06418], [0., 7.06418, 12.8229,
|
||||||
|
0., -1., 0., 0., 0., 0., 0., 17.8871], [0., 11.8229, 18.1138,
|
||||||
|
0., -1.53209, 0., 0., 0., 0., 0., 27.4047], [0., 14.4446, 19.4611,
|
||||||
|
0., -1.74223, 0., 0., 0., 0., 0., 31.1634], [0., 13.7023, 16.2344,
|
||||||
|
0., -1.53209, 0., 0., 0., 0., 0., 27.4047], [0., 9.94356, 9.94356,
|
||||||
|
0., -1., 0., 0., 0., 0., 0., 17.8871], [0., 1.92234, 2.56624,
|
||||||
|
0., -0.223625, 0., 0., 0., 0., 0., 3.], [0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 0., 0., 1.]]),
|
||||||
|
np.array([[0., 0., 8.94356, 12.4757, -2.53209, 0., 0., 0., 0., 0.,
|
||||||
|
17.8871], [0., 0., 4.53209, 4.53209, -1., 0., 0., 0., 0., 0.,
|
||||||
|
7.06418], [0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0.,
|
||||||
|
1., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 2., 7.06418, -1., 0., 0.,
|
||||||
|
0., 0., 0., 7.06418], [0., 0., 6.06418, 15.355, -2.53209, 0., 0.,
|
||||||
|
0., 0., 0., 17.8871], [0., 0., 10.2909, 21.9932, -3.87939, 0., 0.,
|
||||||
|
0., 0., 0., 27.4047], [0., 0., 12.7023, 23.8726, -4.41147, 0., 0.,
|
||||||
|
0., 0., 0., 31.1634], [0., 0., 12.1702, 20.1138, -3.87939, 0., 0.,
|
||||||
|
0., 0., 0., 27.4047], [0., 0., 1.69871, 3.13247, -0.566237, 0., 0.,
|
||||||
|
0., 0., 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[0., 0., -3.87939, 21.9932, 10.2909, 0., 0., 0., 0., 0.,
|
||||||
|
27.4047], [0., 0., -2.53209, 15.355, 6.06418, 0., 0., 0., 0., 0.,
|
||||||
|
17.8871], [0., 0., -1., 7.06418, 2., 0., 0., 0., 0., 0.,
|
||||||
|
7.06418], [0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0.,
|
||||||
|
0., 1., 0., 0., 0., 0., 0., 0.], [0., 0., -1., 4.53209, 4.53209,
|
||||||
|
0., 0., 0., 0., 0., 7.06418], [0., 0., -2.53209, 12.4757, 8.94356,
|
||||||
|
0., 0., 0., 0., 0., 17.8871], [0., 0., -3.87939, 20.1138, 12.1702,
|
||||||
|
0., 0., 0., 0., 0., 27.4047], [0., 0., -4.41147, 23.8726, 12.7023,
|
||||||
|
0., 0., 0., 0., 0., 31.1634], [0., 0., -0.566237, 3.13247, 1.69871,
|
||||||
|
0., 0., 0., 0., 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
1.]]),
|
||||||
|
np.array([[0., 0., 0., 0., 12.7023, 23.8726, -4.41147, 0., 0., 0.,
|
||||||
|
31.1634], [0., 0., 0., 0., 12.1702, 20.1138, -3.87939, 0., 0., 0.,
|
||||||
|
27.4047], [0., 0., 0., 0., 8.94356, 12.4757, -2.53209, 0., 0., 0.,
|
||||||
|
17.8871], [0., 0., 0., 0., 4.53209, 4.53209, -1., 0., 0., 0.,
|
||||||
|
7.06418], [0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.], [0., 0., 0.,
|
||||||
|
0., 0., 1., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 2., 7.06418, -1.,
|
||||||
|
0., 0., 0., 7.06418], [0., 0., 0., 0., 6.06418, 15.355, -2.53209,
|
||||||
|
0., 0., 0., 17.8871], [0., 0., 0., 0., 10.2909, 21.9932, -3.87939,
|
||||||
|
0., 0., 0., 27.4047], [0., 0., 0., 0., 1.69871, 3.13247, -0.566237,
|
||||||
|
0., 0., 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[0., 0., -1., 0., 0., 14.7023, 14.7023, 0., 0., 0., 27.4047], [0.,
|
||||||
|
0., -1.13716, 0., 0., 17.7189, 15.5817, 0., 0., 0., 31.1634], [0.,
|
||||||
|
0., -1., 0., 0., 16.5817, 12.8229, 0., 0., 0., 27.4047], [0.,
|
||||||
|
0., -0.652704, 0., 0., 11.8229, 7.71688, 0., 0., 0., 17.8871], [0.,
|
||||||
|
0., -0.257773, 0., 0., 5.66925, 2.6527, 0., 0., 0., 7.06418], [0.,
|
||||||
|
0., 0., 0., 0., 1., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0.,
|
||||||
|
1., 0., 0., 0., 0.], [0., 0., -0.257773, 0., 0., 3.13716, 5.18479,
|
||||||
|
0., 0., 0., 7.06418], [0., 0., -0.652704, 0., 0., 8.94356, 10.5963,
|
||||||
|
0., 0., 0., 17.8871], [0., 0., -0.145961, 0., 0., 2.34261, 2.0683,
|
||||||
|
0., 0., 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[-1., 0., 0., 0., 0., 0., 7.06418, 12.8229, 0., 0.,
|
||||||
|
17.8871], [-1.53209, 0., 0., 0., 0., 0., 11.8229, 18.1138, 0., 0.,
|
||||||
|
27.4047], [-1.74223, 0., 0., 0., 0., 0., 14.4446, 19.4611, 0., 0.,
|
||||||
|
31.1634], [-1.53209, 0., 0., 0., 0., 0., 13.7023, 16.2344, 0., 0.,
|
||||||
|
27.4047], [-1., 0., 0., 0., 0., 0., 9.94356, 9.94356, 0., 0.,
|
||||||
|
17.8871], [-0.394931, 0., 0., 0., 0., 0., 4.92702, 3.53209, 0., 0.,
|
||||||
|
7.06418], [0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0.], [0., 0., 0.,
|
||||||
|
0., 0., 0., 0., 1., 0., 0., 0.], [-0.394931, 0., 0., 0., 0., 0.,
|
||||||
|
2.39493, 6.06418, 0., 0., 7.06418], [-0.223625, 0., 0., 0., 0., 0.,
|
||||||
|
1.92234, 2.56624, 0., 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 1.]]),
|
||||||
|
np.array([[0., 0., 0., -0.226682, 0., 0., 0., 2.87939, 5.41147, 0.,
|
||||||
|
7.06418], [0., 0., 0., -0.573978, 0., 0., 0., 8.29086, 11.1702, 0.,
|
||||||
|
17.8871], [0., 0., 0., -0.879385, 0., 0., 0., 13.7023, 15.5817, 0.,
|
||||||
|
27.4047], [0., 0., 0., -1., 0., 0., 0., 16.5817, 16.5817, 0.,
|
||||||
|
31.1634], [0., 0., 0., -0.879385, 0., 0., 0., 15.5817, 13.7023, 0.,
|
||||||
|
27.4047], [0., 0., 0., -0.573978, 0., 0., 0., 11.1702, 8.29086, 0.,
|
||||||
|
17.8871], [0., 0., 0., -0.226682, 0., 0., 0., 5.41147, 2.87939, 0.,
|
||||||
|
7.06418], [0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0.], [0., 0., 0.,
|
||||||
|
0., 0., 0., 0., 0., 1., 0., 0.], [0., 0., 0., -0.128356, 0., 0.,
|
||||||
|
0., 2.19665, 2.19665, 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 1.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [5.18479, 0., 0., 0.,
|
||||||
|
0., -0.257773, 0., 0., 3.13716, 0., 7.06418], [10.5963, 0., 0., 0.,
|
||||||
|
0., -0.652704, 0., 0., 8.94356, 0., 17.8871], [14.7023, 0., 0., 0.,
|
||||||
|
0., -1., 0., 0., 14.7023, 0., 27.4047], [15.5817, 0., 0., 0.,
|
||||||
|
0., -1.13716, 0., 0., 17.7189, 0., 31.1634], [12.8229, 0., 0., 0.,
|
||||||
|
0., -1., 0., 0., 16.5817, 0., 27.4047], [7.71688, 0., 0., 0.,
|
||||||
|
0., -0.652704, 0., 0., 11.8229, 0., 17.8871], [2.6527, 0., 0., 0.,
|
||||||
|
0., -0.257773, 0., 0., 5.66925, 0., 7.06418], [0., 0., 0., 0., 0.,
|
||||||
|
0., 0., 0., 1., 0., 0.], [2.0683, 0., 0., 0., 0., -0.145961, 0., 0.,
|
||||||
|
2.34261, 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]])]
|
||||||
|
|
||||||
|
root = Node([3.92380440016309, 3.92380440016309, 3.92380440016309, \
|
||||||
|
3.92380440016309, 3.92380440016309, 3.92380440016309, \
|
||||||
|
3.92380440016309, 3.92380440016309, 3.92380440016309, \
|
||||||
|
2.03960672916147, -1.00000000000000], [], words, False)
|
||||||
|
current_leaves = [root]
|
||||||
|
nodes = 1
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
next_gen = leaf.next_generation(words, dc, generators)
|
||||||
|
new_leaves += next_gen
|
||||||
|
nodes += len(next_gen) if len(next_gen) > 1 else 0
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
for i,leaf in enumerate(current_leaves):
|
||||||
|
words[str(leaf.word)] = i
|
||||||
|
print(len(current_leaves), "partitions")
|
||||||
|
print(nodes,"nodes")
|
||||||
|
return current_leaves
|
||||||
|
|
||||||
|
def constructMatrix(words, dc):
|
||||||
|
leave = generateTree(words, dc)
|
||||||
|
row = []
|
||||||
|
col = []
|
||||||
|
data = []
|
||||||
|
for i,leaf in enumerate(leave):
|
||||||
|
thing = words[str(leaf.word[1:])]
|
||||||
|
if isinstance(thing,int):
|
||||||
|
row.append(i)
|
||||||
|
col.append(thing)
|
||||||
|
data.append(sampleValue(leaf.word))
|
||||||
|
else:
|
||||||
|
sample = sampleValue(leaf.word)
|
||||||
|
for wor in thing.leaves():
|
||||||
|
row.append(i)
|
||||||
|
col.append(words[str(wor.word)])
|
||||||
|
data.append(sample)
|
||||||
|
return csr_matrix((data,(row,col)),shape=(len(leave),len(leave)))
|
||||||
|
|
||||||
|
def secant(x0,y0,x1,y1,z):
|
||||||
|
return x0 - (y0-z) * ((x1-x0)/(y1-y0))
|
||||||
|
|
||||||
|
def matrixFunction(matrix,l,a):
|
||||||
|
matrix = matrix.power(a)
|
||||||
|
vec = np.ones(l)
|
||||||
|
previous_entry = vec[0]
|
||||||
|
previous_val = 0
|
||||||
|
current = matrix * vec
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count = 0
|
||||||
|
while count < 10000000000 and abs(current_val - previous_val) > 1e-15:
|
||||||
|
previous_val = current_val
|
||||||
|
previous_entry = current[0]
|
||||||
|
current = matrix * current
|
||||||
|
#print(current[0],previous_entry)
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count += 1
|
||||||
|
print("power method:", count)
|
||||||
|
return current_val
|
||||||
|
|
||||||
|
def secantMethod(matrix,l,z,x1,x2,e,its):
|
||||||
|
k1 = x1
|
||||||
|
k2 = x2
|
||||||
|
y1 = matrixFunction(matrix,l,k1)
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y1 = testFunction(k1)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count = 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
while abs(y1-z)>e and count<its:
|
||||||
|
k3 = secant(k1,y1,k2,y2,z)
|
||||||
|
k1 = k2
|
||||||
|
y1 = y2
|
||||||
|
k2 = k3
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count += 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
start = time.time()
|
||||||
|
|
||||||
|
words = {}
|
||||||
|
m = 100
|
||||||
|
print("maximum:",m)
|
||||||
|
matrix = constructMatrix(words, m)
|
||||||
|
#print(matrix)
|
||||||
|
|
||||||
|
print("construction (s): %f\nconstruction (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
#print(csr_matrix.transpose(matrix))
|
||||||
|
print(csr_matrix.count_nonzero(matrix), (matrix.shape[0])*15)
|
||||||
|
secantMethod(matrix,matrix.shape[0],1,1.33,1.34,10**(-10),1000)
|
||||||
|
|
||||||
|
print("total (s): %f\ntotal (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
|
||||||
|
main()
|
||||||
48
fractal_dimension/mcmullen_stuff/octanode.py
Normal file
48
fractal_dimension/mcmullen_stuff/octanode.py
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
import numpy as np
|
||||||
|
import math
|
||||||
|
|
||||||
|
class Node:
|
||||||
|
def __init__(self, tuple, word, words, infertile):
|
||||||
|
self.tuple = tuple
|
||||||
|
self.children = []
|
||||||
|
self.word = word
|
||||||
|
self.infertile = infertile
|
||||||
|
words[str(word)] = self
|
||||||
|
|
||||||
|
def dc_not_too_big(self, g, generator, dual_curvature):
|
||||||
|
temp = np.matmul(generator, self.tuple)
|
||||||
|
if g <= 7:
|
||||||
|
temp = [temp[i] for i in (g%8, (g+1)%8, 8)]
|
||||||
|
else:
|
||||||
|
temp = [temp[i] for i in (g%8, (g+1)%8, 9)]
|
||||||
|
return math.sqrt(temp[0]*temp[1] + temp[0]*temp[2] + temp[1]*temp[2]) < dual_curvature
|
||||||
|
|
||||||
|
def next_generation(self, words, dual_curvature, generators):
|
||||||
|
if self.infertile:
|
||||||
|
return [self]
|
||||||
|
if self.children == []:
|
||||||
|
for g,generator in enumerate(generators):
|
||||||
|
if len(self.word) == 0 or g != self.word[-1]:
|
||||||
|
self.children.append(Node(np.matmul(generator,self.tuple), self.word[:] + [g], words, not self.dc_not_too_big(g, generator, dual_curvature)))
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def leaves(self):
|
||||||
|
current_leaves = [self]
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
new_leaves += leaf.next()
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
return current_leaves
|
||||||
372
fractal_dimension/mcmullen_stuff/octatreemcmullen.py
Normal file
372
fractal_dimension/mcmullen_stuff/octatreemcmullen.py
Normal file
|
|
@ -0,0 +1,372 @@
|
||||||
|
from octanode import Node
|
||||||
|
import math
|
||||||
|
import numpy as np
|
||||||
|
import time
|
||||||
|
from scipy.sparse import csr_matrix
|
||||||
|
|
||||||
|
def functions(n, z):
|
||||||
|
"""
|
||||||
|
funs = [[0.446462692171690 + 0.184930902191118j,
|
||||||
|
0.184930902191118], [0.184930902191118 + 0.446462692171690j,
|
||||||
|
0.184930902191118], [-0.184930902191118 + 0.446462692171690j,
|
||||||
|
0.184930902191118], [-0.446462692171690 + 0.184930902191118j,
|
||||||
|
0.184930902191118], [-0.446462692171690 - 0.184930902191118j,
|
||||||
|
0.184930902191118], [-0.184930902191118 - 0.446462692171690j,
|
||||||
|
0.184930902191118], [0.184930902191118 - 0.446462692171690j,
|
||||||
|
0.184930902191118], [0.446462692171690 - 0.184930902191118j,
|
||||||
|
0.184930902191118], [1.00000000000000 + 0.414213562373095j,
|
||||||
|
0.414213562373095], [0.414213562373095 + 1.00000000000000j,
|
||||||
|
0.414213562373095], [-0.414213562373095 + 1.00000000000000j,
|
||||||
|
0.414213562373095], [-1.00000000000000 + 0.414213562373095j,
|
||||||
|
0.414213562373095], [-1.00000000000000 - 0.414213562373095j,
|
||||||
|
0.414213562373095], [-0.414213562373095 - 1.00000000000000j,
|
||||||
|
0.414213562373095], [0.414213562373095 - 1.00000000000000j,
|
||||||
|
0.414213562373095], [1.00000000000000 - 0.414213562373095j,
|
||||||
|
0.414213562373095]]
|
||||||
|
return funs[n][0] + np.conj((funs[n][1])**2 / (z-funs[n][1]))
|
||||||
|
"""
|
||||||
|
if n == 0:
|
||||||
|
return 0.446462692171690 + 0.184930902191118j + np.conj(0.0341994385852209/(-0.446462692171690 - 0.184930902191118j + z))
|
||||||
|
elif n == 1:
|
||||||
|
return 0.184930902191118 + 0.446462692171690j + np.conj(0.0341994385852209/(-0.184930902191118 - 0.446462692171690j + z))
|
||||||
|
elif n == 2:
|
||||||
|
return -0.184930902191118 + 0.446462692171690j + np.conj(0.0341994385852209/(0.184930902191118 - 0.446462692171690j + z))
|
||||||
|
elif n == 3:
|
||||||
|
return -0.446462692171690 + 0.184930902191118j + np.conj(0.0341994385852209/(0.446462692171690 - 0.184930902191118j + z))
|
||||||
|
elif n == 4:
|
||||||
|
return -0.446462692171690 - 0.184930902191118j + np.conj(0.0341994385852209/(0.446462692171690 + 0.184930902191118j + z))
|
||||||
|
elif n == 5:
|
||||||
|
return -0.184930902191118 - 0.446462692171690j + np.conj(0.0341994385852209/(0.184930902191118 + 0.446462692171690j + z))
|
||||||
|
elif n == 6:
|
||||||
|
return 0.184930902191118 - 0.446462692171690j + np.conj(0.0341994385852209/(-0.184930902191118 + 0.446462692171690j + z))
|
||||||
|
elif n == 7:
|
||||||
|
return 0.446462692171690 - 0.184930902191118j + np.conj(0.0341994385852209/(-0.446462692171690 + 0.184930902191118j + z))
|
||||||
|
elif n == 8:
|
||||||
|
return 1.00000000000000 + 0.414213562373095j + np.conj(0.171572875253810/(-1.00000000000000 - 0.414213562373095j + z))
|
||||||
|
elif n == 9:
|
||||||
|
return 0.414213562373095 + 1.00000000000000j + np.conj(0.171572875253810/(-0.414213562373095 - 1.00000000000000j + z))
|
||||||
|
elif n == 10:
|
||||||
|
return -0.414213562373095 + 1.00000000000000j + np.conj(0.171572875253810/(0.414213562373095 - 1.00000000000000j + z))
|
||||||
|
elif n == 11:
|
||||||
|
return -1.00000000000000 + 0.414213562373095j + np.conj(0.171572875253810/(1.00000000000000 - 0.414213562373095j + z))
|
||||||
|
elif n == 12:
|
||||||
|
return -1.00000000000000 - 0.414213562373095j + np.conj(0.171572875253810/(1.00000000000000 + 0.414213562373095j + z))
|
||||||
|
elif n == 13:
|
||||||
|
return -0.414213562373095 - 1.00000000000000j + np.conj(0.171572875253810/(0.414213562373095 + 1.00000000000000j + z))
|
||||||
|
elif n == 14:
|
||||||
|
return 0.414213562373095 - 1.00000000000000j + np.conj(0.171572875253810/(-0.414213562373095 + 1.00000000000000j + z))
|
||||||
|
elif n == 15:
|
||||||
|
return 1.00000000000000 - 0.414213562373095j + np.conj(0.171572875253810/(-1.00000000000000 + 0.414213562373095j + z))
|
||||||
|
|
||||||
|
def derivatives(n, z):
|
||||||
|
"""
|
||||||
|
funs = [[0.446462692171690 + 0.184930902191118j,
|
||||||
|
0.184930902191118], [0.184930902191118 + 0.446462692171690j,
|
||||||
|
0.184930902191118], [-0.184930902191118 + 0.446462692171690j,
|
||||||
|
0.184930902191118], [-0.446462692171690 + 0.184930902191118j,
|
||||||
|
0.184930902191118], [-0.446462692171690 - 0.184930902191118j,
|
||||||
|
0.184930902191118], [-0.184930902191118 - 0.446462692171690j,
|
||||||
|
0.184930902191118], [0.184930902191118 - 0.446462692171690j,
|
||||||
|
0.184930902191118], [0.446462692171690 - 0.184930902191118j,
|
||||||
|
0.184930902191118], [1.00000000000000 + 0.414213562373095j,
|
||||||
|
0.414213562373095], [0.414213562373095 + 1.00000000000000j,
|
||||||
|
0.414213562373095], [-0.414213562373095 + 1.00000000000000j,
|
||||||
|
0.414213562373095], [-1.00000000000000 + 0.414213562373095j,
|
||||||
|
0.414213562373095], [-1.00000000000000 - 0.414213562373095j,
|
||||||
|
0.414213562373095], [-0.414213562373095 - 1.00000000000000j,
|
||||||
|
0.414213562373095], [0.414213562373095 - 1.00000000000000j,
|
||||||
|
0.414213562373095], [1.00000000000000 - 0.414213562373095j,
|
||||||
|
0.414213562373095]]
|
||||||
|
return abs(-1*((z-funs[n][0])**2) / (funs[n][1]**2))
|
||||||
|
"""
|
||||||
|
if n == 0:
|
||||||
|
return abs(-29.2402460791314*(-0.446462692171690 - 0.184930902191118j + z)**2)
|
||||||
|
elif n == 1:
|
||||||
|
return abs(-29.2402460791314*(-0.184930902191118 - 0.446462692171690j +z)**2)
|
||||||
|
elif n == 2:
|
||||||
|
return abs(-29.2402460791314*(0.184930902191118 - 0.446462692171690j +z)**2)
|
||||||
|
elif n == 3:
|
||||||
|
return abs(-29.2402460791314*(0.446462692171690 - 0.184930902191118j +z)**2)
|
||||||
|
elif n == 4:
|
||||||
|
return abs(-29.2402460791314*(0.446462692171690 + 0.184930902191118j +z)**2)
|
||||||
|
elif n == 5:
|
||||||
|
return abs(-29.2402460791314*(0.184930902191118 + 0.446462692171690j +z)**2)
|
||||||
|
elif n == 6:
|
||||||
|
return abs(-29.2402460791314*(-0.184930902191118 + 0.446462692171690j + z)**2)
|
||||||
|
elif n == 7:
|
||||||
|
return abs(-29.2402460791314*(-0.446462692171690 + 0.184930902191118j +z)**2)
|
||||||
|
elif n == 8:
|
||||||
|
return abs(-5.8284271247462*(-1.00000000000000 - 0.414213562373095j + z)**2)
|
||||||
|
elif n == 9:
|
||||||
|
return abs(-5.8284271247462*(-0.414213562373095 - 1.00000000000000j + z)**2)
|
||||||
|
elif n == 10:
|
||||||
|
return abs(-5.8284271247462*(0.414213562373095 - 1.00000000000000j + z)**2)
|
||||||
|
elif n == 11:
|
||||||
|
return abs(-5.8284271247462*(1.00000000000000 - 0.414213562373095j + z)**2)
|
||||||
|
elif n == 12:
|
||||||
|
return abs(-5.8284271247462*(1.00000000000000 + 0.414213562373095j + z)**2)
|
||||||
|
elif n == 13:
|
||||||
|
return abs(-5.8284271247462*(0.414213562373095 + 1.00000000000000j + z)**2)
|
||||||
|
elif n == 14:
|
||||||
|
return abs(-5.8284271247462*(-0.414213562373095 + 1.00000000000000j + z)**2)
|
||||||
|
elif n == 15:
|
||||||
|
return abs(-5.8284271247462*(-1.00000000000000 + 0.414213562373095j + z)**2)
|
||||||
|
|
||||||
|
def samplePoint(word):
|
||||||
|
points = [[0.468786, 0.194177], [0.194177, 0.468786], [-0.194177,
|
||||||
|
0.468786], [-0.468786,
|
||||||
|
0.194177], [-0.468786, -0.194177], [-0.194177, -0.468786], \
|
||||||
|
[0.194177, -0.468786], [0.468786, -0.194177], [0.8,
|
||||||
|
0.331371], [0.331371, 0.8], [-0.331371, 0.8], [-0.8,
|
||||||
|
0.331371], [-0.8, -0.331371], [-0.331371, -0.8], [0.331371, -0.8], \
|
||||||
|
[0.8, -0.331371]]
|
||||||
|
p = points[word[-1]][0] + points[word[-1]][1]*1j
|
||||||
|
for letter in word[-2::-1]:
|
||||||
|
p = functions(letter, p)
|
||||||
|
return p
|
||||||
|
|
||||||
|
def sampleValue(word):
|
||||||
|
d = derivatives(word[0], samplePoint(word))
|
||||||
|
if d>1:
|
||||||
|
print(d, word)
|
||||||
|
return d
|
||||||
|
|
||||||
|
def generateTree(words, dc):
|
||||||
|
tt = time.time()
|
||||||
|
generators = [np.array([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 1., 0., 0., 0., 0.,
|
||||||
|
0., 0., 0., 0.], [2.70711, 5.41421, 0., 0., -0.292893, 0., 0., 0.,
|
||||||
|
6.82843, 0.], [7.53553, 10.6569, 0., 0., -0.707107, 0., 0., 0.,
|
||||||
|
16.4853, 0.], [11.6569, 13.6569, 0., 0., -1., 0., 0., 0., 23.3137,
|
||||||
|
0.], [12.6569, 12.6569, 0., 0., -1., 0., 0., 0., 23.3137,
|
||||||
|
0.], [9.94975, 8.24264, 0., 0., -0.707107, 0., 0., 0., 16.4853,
|
||||||
|
0.], [5.12132, 3., 0., 0., -0.292893, 0., 0., 0., 6.82843, 0.], [0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 0., 1., 0.], [2.17157, 2.34315, 0.,
|
||||||
|
0., -0.171573, 0., 0., 0., 3., 0.]]),np.array([[0., 4.82843, 3.41421,
|
||||||
|
0., -0.414214, 0., 0., 0., 6.82843, 0.], [0.,
|
||||||
|
1., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 1., 0., 0., 0., 0.,
|
||||||
|
0., 0., 0.], [0., 2.41421, 5.82843, 0., -0.414214, 0., 0., 0.,
|
||||||
|
6.82843, 0.], [0., 6.82843, 11.6569, 0., -1., 0., 0., 0., 16.4853,
|
||||||
|
0.], [0., 10.6569, 15.0711, 0., -1.41421, 0., 0., 0., 23.3137,
|
||||||
|
0.], [0., 11.6569, 14.0711, 0., -1.41421, 0., 0., 0., 23.3137,
|
||||||
|
0.], [0., 9.24264, 9.24264, 0., -1., 0., 0., 0., 16.4853, 0.], [0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 0., 1., 0.], [0., 2., 2.58579,
|
||||||
|
0., -0.242641, 0., 0., 0., 3., 0.]]), np.array([[-1., 0., 11.6569, 6.82843,
|
||||||
|
0., 0., 0., 0., 16.4853, 0.], [-0.414214, 0., 5.82843, 2.41421, 0.,
|
||||||
|
0., 0., 0., 6.82843, 0.], [0., 0., 1., 0., 0., 0., 0., 0., 0.,
|
||||||
|
0.], [0., 0., 0., 1., 0., 0., 0., 0., 0., 0.], [-0.414214, 0.,
|
||||||
|
3.41421, 4.82843, 0., 0., 0., 0., 6.82843, 0.], [-1., 0., 9.24264,
|
||||||
|
9.24264, 0., 0., 0., 0., 16.4853, 0.], [-1.41421, 0., 14.0711,
|
||||||
|
11.6569, 0., 0., 0., 0., 23.3137, 0.], [-1.41421, 0., 15.0711,
|
||||||
|
10.6569, 0., 0., 0., 0., 23.3137, 0.], [0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 1., 0.], [-0.242641, 0., 2.58579, 2., 0., 0., 0., 0., 3.,
|
||||||
|
0.]]), np.array([[0., 0., 0., 11.6569, 14.0711, 0., -1.41421, 0., 23.3137,
|
||||||
|
0.], [0., 0., 0., 9.24264, 9.24264, 0., -1., 0., 16.4853, 0.], [0.,
|
||||||
|
0., 0., 4.82843, 3.41421, 0., -0.414214, 0., 6.82843, 0.], [0.,
|
||||||
|
0., 0., 1., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 1., 0., 0.,
|
||||||
|
0., 0., 0.], [0., 0., 0., 2.41421, 5.82843, 0., -0.414214, 0.,
|
||||||
|
6.82843, 0.], [0., 0., 0., 6.82843, 11.6569, 0., -1., 0., 16.4853,
|
||||||
|
0.], [0., 0., 0., 10.6569, 15.0711, 0., -1.41421, 0., 23.3137,
|
||||||
|
0.], [0., 0., 0., 0., 0., 0., 0., 0., 1., 0.], [0., 0., 0., 2.,
|
||||||
|
2.58579, 0., -0.242641, 0., 3., 0.]]), np.array([[0., 0., 0., -3.41421,
|
||||||
|
17.4853, 10.2426, 0., 0., 23.3137, 0.], [0., 0., 0., -3.41421,
|
||||||
|
18.4853, 9.24264, 0., 0., 23.3137, 0.], [0., 0., 0., -2.41421,
|
||||||
|
14.0711, 5.82843, 0., 0., 16.4853, 0.], [0., 0., 0., -1., 6.82843,
|
||||||
|
2., 0., 0., 6.82843, 0.], [0., 0., 0., 0., 1., 0., 0., 0., 0.,
|
||||||
|
0.], [0., 0., 0., 0., 0., 1., 0., 0., 0., 0.], [0., 0., 0., -1.,
|
||||||
|
4.41421, 4.41421, 0., 0., 6.82843, 0.], [0., 0., 0., -2.41421,
|
||||||
|
11.6569, 8.24264, 0., 0., 16.4853, 0.], [0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 0., 1., 0.], [0., 0., 0., -0.585786, 3.17157, 1.75736, 0., 0.,
|
||||||
|
3., 0.]]), np.array([[0., 0., 0., 0., -2.41421, 11.6569, 8.24264, 0.,
|
||||||
|
16.4853, 0.], [0., 0., 0., 0., -3.41421, 17.4853, 10.2426, 0.,
|
||||||
|
23.3137, 0.], [0., 0., 0., 0., -3.41421, 18.4853, 9.24264, 0.,
|
||||||
|
23.3137, 0.], [0., 0., 0., 0., -2.41421, 14.0711, 5.82843, 0.,
|
||||||
|
16.4853, 0.], [0., 0., 0., 0., -1., 6.82843, 2., 0., 6.82843,
|
||||||
|
0.], [0., 0., 0., 0., 0., 1., 0., 0., 0., 0.], [0., 0., 0., 0., 0.,
|
||||||
|
0., 1., 0., 0., 0.], [0., 0., 0., 0., -1., 4.41421, 4.41421, 0.,
|
||||||
|
6.82843, 0.], [0., 0., 0., 0., 0., 0., 0., 0., 1., 0.], [0., 0.,
|
||||||
|
0., 0., -0.585786, 3.17157, 1.75736, 0., 3., 0.]]), np.array([[0., 0.,
|
||||||
|
0., -0.292893, 0., 0., 3., 5.12132, 6.82843, 0.], [0., 0.,
|
||||||
|
0., -0.707107, 0., 0., 8.24264, 9.94975, 16.4853, 0.], [0., 0.,
|
||||||
|
0., -1., 0., 0., 12.6569, 12.6569, 23.3137, 0.], [0., 0., 0., -1.,
|
||||||
|
0., 0., 13.6569, 11.6569, 23.3137, 0.], [0., 0., 0., -0.707107, 0.,
|
||||||
|
0., 10.6569, 7.53553, 16.4853, 0.], [0., 0., 0., -0.292893, 0.,
|
||||||
|
0., 5.41421, 2.70711, 6.82843, 0.], [0., 0., 0., 0., 0., 0., 1.,
|
||||||
|
0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 1., 0., 0.], [0., 0., 0.,
|
||||||
|
0., 0., 0., 0., 0., 1., 0.], [0., 0., 0., -0.171573, 0., 0.,
|
||||||
|
2.34315, 2.17157, 3., 0.]]),np.array([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [5.82843, 0., -0.414214,
|
||||||
|
0., 0., 0., 0., 2.41421, 6.82843, 0.], [11.6569, 0., -1., 0., 0.,
|
||||||
|
0., 0., 6.82843, 16.4853, 0.], [15.0711, 0., -1.41421, 0., 0., 0.,
|
||||||
|
0., 10.6569, 23.3137, 0.], [14.0711, 0., -1.41421, 0., 0., 0., 0.,
|
||||||
|
11.6569, 23.3137, 0.], [9.24264, 0., -1., 0., 0., 0., 0., 9.24264,
|
||||||
|
16.4853, 0.], [3.41421, 0., -0.414214, 0., 0., 0., 0., 4.82843,
|
||||||
|
6.82843, 0.], [0., 0., 0., 0., 0., 0., 0., 1., 0., 0.], [0., 0., 0.,
|
||||||
|
0., 0., 0., 0., 0., 1., 0.], [2.58579, 0., -0.242641, 0., 0., 0.,
|
||||||
|
0., 2., 3., 0.]]),np.array([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [5.41421, 0., 0., 0., 0.,
|
||||||
|
0., 0., 3., -1.70711, 5.12132], [10.6569, 0., 0., 0., 0., 0., 0.,
|
||||||
|
8.24264, -4.12132, 12.364], [13.6569, 0., 0., 0., 0., 0., 0.,
|
||||||
|
12.6569, -5.82843, 17.4853], [12.6569, 0., 0., 0., 0., 0., 0.,
|
||||||
|
13.6569, -5.82843, 17.4853], [8.24264, 0., 0., 0., 0., 0., 0.,
|
||||||
|
10.6569, -4.12132, 12.364], [3., 0., 0., 0., 0., 0., 0.,
|
||||||
|
5.41421, -1.70711, 5.12132], [0., 0., 0., 0., 0., 0., 0., 1., 0.,
|
||||||
|
0.], [2.34315, 0., 0., 0., 0., 0., 0., 2.34315, -1., 2.], [0., 0.,
|
||||||
|
0., 0., 0., 0., 0., 0., 0., 1.]]),np.array([[0., 5.82843, 2.41421, 0., 0., 0., 0., -0.414214, 0., 6.82843], [0.,
|
||||||
|
1., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 1., 0., 0., 0., 0.,
|
||||||
|
0., 0., 0.], [0., 3.41421, 4.82843, 0., 0., 0., 0., -0.414214, 0.,
|
||||||
|
6.82843], [0., 9.24264, 9.24264, 0., 0., 0., 0., -1., 0.,
|
||||||
|
16.4853], [0., 14.0711, 11.6569, 0., 0., 0., 0., -1.41421, 0.,
|
||||||
|
23.3137], [0., 15.0711, 10.6569, 0., 0., 0., 0., -1.41421, 0.,
|
||||||
|
23.3137], [0., 11.6569, 6.82843, 0., 0., 0., 0., -1., 0.,
|
||||||
|
16.4853], [0., 2.58579, 2., 0., 0., 0., 0., -0.242641, 0.,
|
||||||
|
3.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]), np.array([[-1., 0., 11.6569,
|
||||||
|
6.82843, 0., 0., 0., 0., 0., 16.4853], [-0.414214, 0., 5.82843,
|
||||||
|
2.41421, 0., 0., 0., 0., 0., 6.82843], [0., 0., 1., 0., 0., 0., 0.,
|
||||||
|
0., 0., 0.], [0., 0., 0., 1., 0., 0., 0., 0., 0., 0.], [-0.414214,
|
||||||
|
0., 3.41421, 4.82843, 0., 0., 0., 0., 0., 6.82843], [-1., 0.,
|
||||||
|
9.24264, 9.24264, 0., 0., 0., 0., 0., 16.4853], [-1.41421, 0.,
|
||||||
|
14.0711, 11.6569, 0., 0., 0., 0., 0., 23.3137], [-1.41421, 0.,
|
||||||
|
15.0711, 10.6569, 0., 0., 0., 0., 0., 23.3137], [-0.242641, 0.,
|
||||||
|
2.58579, 2., 0., 0., 0., 0., 0., 3.], [0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 0., 1.]]), np.array([[0., 0., -3.41421, 18.4853, 9.24264, 0., 0., 0., 0.,
|
||||||
|
23.3137], [0., 0., -2.41421, 14.0711, 5.82843, 0., 0., 0., 0.,
|
||||||
|
16.4853], [0., 0., -1., 6.82843, 2., 0., 0., 0., 0., 6.82843], [0.,
|
||||||
|
0., 0., 1., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 1., 0., 0.,
|
||||||
|
0., 0., 0.], [0., 0., -1., 4.41421, 4.41421, 0., 0., 0., 0.,
|
||||||
|
6.82843], [0., 0., -2.41421, 11.6569, 8.24264, 0., 0., 0., 0.,
|
||||||
|
16.4853], [0., 0., -3.41421, 17.4853, 10.2426, 0., 0., 0., 0.,
|
||||||
|
23.3137], [0., 0., -0.585786, 3.17157, 1.75736, 0., 0., 0., 0.,
|
||||||
|
3.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]), np.array([[-1., 0., 0., 0.,
|
||||||
|
11.6569, 13.6569, 0., 0., 0., 23.3137], [-1., 0., 0., 0., 12.6569,
|
||||||
|
12.6569, 0., 0., 0., 23.3137], [-0.707107, 0., 0., 0., 9.94975,
|
||||||
|
8.24264, 0., 0., 0., 16.4853], [-0.292893, 0., 0., 0., 5.12132, 3.,
|
||||||
|
0., 0., 0., 6.82843], [0., 0., 0., 0., 1., 0., 0., 0., 0.,
|
||||||
|
0.], [0., 0., 0., 0., 0., 1., 0., 0., 0., 0.], [-0.292893, 0., 0.,
|
||||||
|
0., 2.70711, 5.41421, 0., 0., 0., 6.82843], [-0.707107, 0., 0., 0.,
|
||||||
|
7.53553, 10.6569, 0., 0., 0., 16.4853], [-0.171573, 0., 0., 0.,
|
||||||
|
2.17157, 2.34315, 0., 0., 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 1.]]), np.array([[0., 0., 0., 0., 0., 5.82843, 14.0711, -2.41421, 0.,
|
||||||
|
16.4853], [0., 0., 0., 0., 0., 9.24264, 18.4853, -3.41421, 0.,
|
||||||
|
23.3137], [0., 0., 0., 0., 0., 10.2426, 17.4853, -3.41421, 0.,
|
||||||
|
23.3137], [0., 0., 0., 0., 0., 8.24264, 11.6569, -2.41421, 0.,
|
||||||
|
16.4853], [0., 0., 0., 0., 0., 4.41421, 4.41421, -1., 0.,
|
||||||
|
6.82843], [0., 0., 0., 0., 0., 1., 0., 0., 0., 0.], [0., 0., 0.,
|
||||||
|
0., 0., 0., 1., 0., 0., 0.], [0., 0., 0., 0., 0., 2., 6.82843, -1.,
|
||||||
|
0., 6.82843], [0., 0., 0., 0., 0., 1.75736, 3.17157, -0.585786,
|
||||||
|
0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
1.]]), np.array([[0., -0.414214, 0., 0., 0., 0., 2.41421, 5.82843, 0.,
|
||||||
|
6.82843], [0., -1., 0., 0., 0., 0., 6.82843, 11.6569, 0.,
|
||||||
|
16.4853], [0., -1.41421, 0., 0., 0., 0., 10.6569, 15.0711, 0.,
|
||||||
|
23.3137], [0., -1.41421, 0., 0., 0., 0., 11.6569, 14.0711, 0.,
|
||||||
|
23.3137], [0., -1., 0., 0., 0., 0., 9.24264, 9.24264, 0.,
|
||||||
|
16.4853], [0., -0.414214, 0., 0., 0., 0., 4.82843, 3.41421, 0.,
|
||||||
|
6.82843], [0., 0., 0., 0., 0., 0., 1., 0., 0., 0.], [0., 0., 0.,
|
||||||
|
0., 0., 0., 0., 1., 0., 0.], [0., -0.242641, 0., 0., 0., 0., 2.,
|
||||||
|
2.58579, 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 1., 0., 0., 0., 0.,
|
||||||
|
0., 0., 0., 0.], [2., 6.82843, -1., 0., 0., 0., 0., 0., 0.,
|
||||||
|
6.82843], [5.82843, 14.0711, -2.41421, 0., 0., 0., 0., 0., 0.,
|
||||||
|
16.4853], [9.24264, 18.4853, -3.41421, 0., 0., 0., 0., 0., 0.,
|
||||||
|
23.3137], [10.2426, 17.4853, -3.41421, 0., 0., 0., 0., 0., 0.,
|
||||||
|
23.3137], [8.24264, 11.6569, -2.41421, 0., 0., 0., 0., 0., 0.,
|
||||||
|
16.4853], [4.41421, 4.41421, -1., 0., 0., 0., 0., 0., 0.,
|
||||||
|
6.82843], [1.75736, 3.17157, -0.585786, 0., 0., 0., 0., 0., 0.,
|
||||||
|
3.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]])]
|
||||||
|
|
||||||
|
root = Node([3.61312592975275, 3.61312592975275, 3.61312592975275, \
|
||||||
|
3.61312592975275, 3.61312592975275, 3.61312592975275, \
|
||||||
|
3.61312592975275, 3.61312592975275, 2.23982880884355, \
|
||||||
|
-1.00000000000000], [], words, False)
|
||||||
|
current_leaves = [root]
|
||||||
|
nodes = 1
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
next_gen = leaf.next_generation(words, dc, generators)
|
||||||
|
new_leaves += next_gen
|
||||||
|
nodes += len(next_gen) if len(next_gen) > 1 else 0
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
for i,leaf in enumerate(current_leaves):
|
||||||
|
words[str(leaf.word)] = i
|
||||||
|
print(len(current_leaves), "partitions")
|
||||||
|
print(nodes,"nodes")
|
||||||
|
print("tree construction (s): %f\ntree construction (m): %f" % (time.time()-tt, (time.time()-tt)/60))
|
||||||
|
return current_leaves
|
||||||
|
|
||||||
|
def constructMatrix(words, dc):
|
||||||
|
leave = generateTree(words, dc)
|
||||||
|
row = []
|
||||||
|
col = []
|
||||||
|
data = []
|
||||||
|
for i,leaf in enumerate(leave):
|
||||||
|
thing = words[str(leaf.word[1:])]
|
||||||
|
if isinstance(thing,int):
|
||||||
|
row.append(i)
|
||||||
|
col.append(thing)
|
||||||
|
data.append(sampleValue(leaf.word))
|
||||||
|
else:
|
||||||
|
sample = sampleValue(leaf.word)
|
||||||
|
for wor in thing.leaves():
|
||||||
|
row.append(i)
|
||||||
|
col.append(words[str(wor.word)])
|
||||||
|
data.append(sample)
|
||||||
|
return csr_matrix((data,(row,col)),shape=(len(leave),len(leave)))
|
||||||
|
|
||||||
|
def secant(x0,y0,x1,y1,z):
|
||||||
|
return x0 - (y0-z) * ((x1-x0)/(y1-y0))
|
||||||
|
|
||||||
|
def matrixFunction(matrix,l,a):
|
||||||
|
matrix = matrix.power(a)
|
||||||
|
vec = np.ones(l)
|
||||||
|
previous_entry = vec[0]
|
||||||
|
previous_val = 0
|
||||||
|
current = matrix * vec
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count = 0
|
||||||
|
while count < 10000000000 and abs(current_val - previous_val) > 1e-15:
|
||||||
|
previous_val = current_val
|
||||||
|
previous_entry = current[0]
|
||||||
|
current = matrix * current
|
||||||
|
#print(current[0],previous_entry)
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count += 1
|
||||||
|
print("power method:", count)
|
||||||
|
return current_val
|
||||||
|
|
||||||
|
def secantMethod(matrix,l,z,x1,x2,e,its):
|
||||||
|
k1 = x1
|
||||||
|
k2 = x2
|
||||||
|
y1 = matrixFunction(matrix,l,k1)
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y1 = testFunction(k1)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count = 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
while abs(y1-z)>e and count<its:
|
||||||
|
k3 = secant(k1,y1,k2,y2,z)
|
||||||
|
k1 = k2
|
||||||
|
y1 = y2
|
||||||
|
k2 = k3
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count += 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
start = time.time()
|
||||||
|
|
||||||
|
words = {}
|
||||||
|
m = 1500
|
||||||
|
print("maximum:",m)
|
||||||
|
matrix = constructMatrix(words,m)
|
||||||
|
#print(matrix)
|
||||||
|
|
||||||
|
print("construction (s): %f\nconstruction (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
#print(csr_matrix.transpose(matrix))
|
||||||
|
print(csr_matrix.count_nonzero(matrix), (matrix.shape[0])*15)
|
||||||
|
secantMethod(matrix,matrix.shape[0],1,1.33,1.34,10**(-10),1000)
|
||||||
|
|
||||||
|
print("total (s): %f\ntotal (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
|
||||||
|
main()
|
||||||
64
fractal_dimension/mcmullen_stuff/pentanode.py
Normal file
64
fractal_dimension/mcmullen_stuff/pentanode.py
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
import numpy as np
|
||||||
|
import math
|
||||||
|
|
||||||
|
class Node:
|
||||||
|
def __init__(self, tuple, word, words, infertile):
|
||||||
|
self.tuple = tuple
|
||||||
|
self.children = []
|
||||||
|
self.word = word
|
||||||
|
self.infertile = infertile
|
||||||
|
words[str(word)] = self
|
||||||
|
|
||||||
|
def dc_not_too_big(self, g, generator, dual_curvature):
|
||||||
|
temp = np.matmul(generator, self.tuple)
|
||||||
|
if g == 0:
|
||||||
|
temp = [temp[i] for i in (0,1,5)]
|
||||||
|
elif g == 1:
|
||||||
|
temp = [temp[i] for i in (1,2,5)]
|
||||||
|
elif g == 2:
|
||||||
|
temp = [temp[i] for i in (2,3,5)]
|
||||||
|
elif g == 3:
|
||||||
|
temp = [temp[i] for i in (3,4,5)]
|
||||||
|
elif g == 4:
|
||||||
|
temp = [temp[i] for i in (0,4,5)]
|
||||||
|
elif g == 5:
|
||||||
|
temp = [temp[i] for i in (0,1,6)]
|
||||||
|
elif g == 6:
|
||||||
|
temp = [temp[i] for i in (1,2,6)]
|
||||||
|
elif g == 7:
|
||||||
|
temp = [temp[i] for i in (2,3,6)]
|
||||||
|
elif g == 8:
|
||||||
|
temp = [temp[i] for i in (3,4,6)]
|
||||||
|
elif g == 9:
|
||||||
|
temp = [temp[i] for i in (0,4,6)]
|
||||||
|
return math.sqrt(temp[0]*temp[1] + temp[0]*temp[2] + temp[1]*temp[2]) < dual_curvature
|
||||||
|
|
||||||
|
def next_generation(self, words, dual_curvature, generators):
|
||||||
|
if self.infertile:
|
||||||
|
return [self]
|
||||||
|
if self.children == []:
|
||||||
|
for g,generator in enumerate(generators):
|
||||||
|
if len(self.word) == 0 or g != self.word[-1]:
|
||||||
|
self.children.append(Node(np.matmul(generator,self.tuple), self.word[:] + [g], words, not self.dc_not_too_big(g, generator, dual_curvature)))
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def leaves(self):
|
||||||
|
current_leaves = [self]
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
new_leaves += leaf.next()
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
return current_leaves
|
||||||
186
fractal_dimension/mcmullen_stuff/pentatreemcmullen.py
Normal file
186
fractal_dimension/mcmullen_stuff/pentatreemcmullen.py
Normal file
|
|
@ -0,0 +1,186 @@
|
||||||
|
from pentanode import Node
|
||||||
|
import math
|
||||||
|
import numpy as np
|
||||||
|
import time
|
||||||
|
from scipy.sparse import csr_matrix
|
||||||
|
from scipy import stats
|
||||||
|
|
||||||
|
def functions(n, z):
|
||||||
|
if n == 0:
|
||||||
|
return 0.259616 + 0.188622j + np.conj(0.0355783/(-0.259616 - 0.188622j + z))
|
||||||
|
elif n == 1:
|
||||||
|
return -0.0991646 + 0.305197j + np.conj(0.0355783/(0.0991646 - 0.305197j + z))
|
||||||
|
elif n == 2:
|
||||||
|
return -0.320903 + np.conj(0.0355783/(0.320903 + z))
|
||||||
|
elif n == 3:
|
||||||
|
return -0.0991646 - 0.305197j + np.conj(0.0355783/(0.0991646 + 0.305197j + z))
|
||||||
|
elif n == 4:
|
||||||
|
return 0.259616 - 0.188622j + np.conj(0.0355783/(-0.259616 + 0.188622j + z))
|
||||||
|
elif n == 5:
|
||||||
|
return 1. + 0.726543j + np.conj(0.527864/(-1. - 0.726543j + z))
|
||||||
|
elif n == 6:
|
||||||
|
return -0.381966 + 1.17557j + np.conj(0.527864/(0.381966 - 1.17557j + z))
|
||||||
|
elif n == 7:
|
||||||
|
return -1.23607 + np.conj(0.527864/(1.23607 + z))
|
||||||
|
elif n == 8:
|
||||||
|
return -0.381966 - 1.17557j + np.conj(0.527864/(0.381966 + 1.17557j + z))
|
||||||
|
elif n == 9:
|
||||||
|
return 1. - 0.726543j + np.conj(0.527864/(-1. + 0.726543j + z))
|
||||||
|
|
||||||
|
def derivatives(n, z):
|
||||||
|
if n == 0:
|
||||||
|
return abs(-28.107*(-0.259616 - 0.188622j + z)**2)
|
||||||
|
elif n == 1:
|
||||||
|
return abs(-28.107*(0.0991646 - 0.305197j + z)**2)
|
||||||
|
elif n == 2:
|
||||||
|
return abs(-28.107*(0.320903 + z)**2)
|
||||||
|
elif n == 3:
|
||||||
|
return abs(-28.107*(0.0991646 + 0.305197j + z)**2)
|
||||||
|
elif n == 4:
|
||||||
|
return abs(-28.107*(-0.259616 + 0.188622j + z)**2)
|
||||||
|
elif n == 5:
|
||||||
|
return abs(-1.89443*(-1. - 0.726543j + z)**2)
|
||||||
|
elif n == 6:
|
||||||
|
return abs(-1.89443*(0.381966 - 1.17557j + z)**2)
|
||||||
|
elif n == 7:
|
||||||
|
return abs(-1.89443*(1.23607 + z)**2)
|
||||||
|
elif n == 8:
|
||||||
|
return abs(-1.89443*(0.381966 + 1.17557j + z)**2)
|
||||||
|
elif n == 9:
|
||||||
|
return abs(-1.89443*(-1. + 0.726543j + z)**2)
|
||||||
|
|
||||||
|
def samplePoint(word):
|
||||||
|
if word[-1] == 0:
|
||||||
|
p = 0.259616 + 0.188622j
|
||||||
|
elif word[-1] == 1:
|
||||||
|
p = -0.0991646 + 0.305197j
|
||||||
|
elif word[-1] == 2:
|
||||||
|
p = -0.320903
|
||||||
|
elif word[-1] == 3:
|
||||||
|
p = -0.0991646 - 0.305197j
|
||||||
|
elif word[-1] == 4:
|
||||||
|
p = 0.259616 - 0.188622j
|
||||||
|
elif word[-1] == 5:
|
||||||
|
p = 0.6 + 0.435926j
|
||||||
|
elif word[-1] == 6:
|
||||||
|
p = -0.22918 + 0.705342j
|
||||||
|
elif word[-1] == 7:
|
||||||
|
p = -0.741641
|
||||||
|
elif word[-1] == 8:
|
||||||
|
p = -0.22918 - 0.705342j
|
||||||
|
elif word[-1] == 9:
|
||||||
|
p = 0.6 - 0.435926j
|
||||||
|
for letter in word[-2::-1]:
|
||||||
|
p = functions(letter, p)
|
||||||
|
return p
|
||||||
|
|
||||||
|
def sampleValue(word):
|
||||||
|
return derivatives(word[0], samplePoint(word))
|
||||||
|
|
||||||
|
def generateTree(words, dc):
|
||||||
|
generators = [np.array([[1., 0., 0., 0., 0., 0., 0.], [0., 1., 0., 0., 0., 0., 0.], [2.61803, 4.23607, 0., -0.618034, 0., 5.23607, 0.], [5.23607, 5.23607, 0., -1., 0., 8.47214, 0.], [4.23607, 2.61803, 0., -0.618034, 0., 5.23607, 0.], [0., 0., 0., 0., 0., 1., 0.], [2.76393, 2.76393, 0., -0.472136, 0., 3., 0.]]),
|
||||||
|
np.array([[0., 4.23607, 2.61803, 0., -0.618034, 5.23607, 0.], [0., 1., 0., 0., 0., 0., 0.], [0., 0., 1., 0., 0., 0., 0.], [0., 2.61803, 4.23607, 0., -0.618034, 5.23607, 0.], [0., 5.23607, 5.23607, 0., -1., 8.47214, 0.], [0., 0., 0., 0., 0., 1., 0.], [0., 2.76393, 2.76393, 0., -0.472136, 3., 0.]]),
|
||||||
|
np.array([[0., 0., 4.23607, 6.8541, -1.61803, 8.47214, 0.], [0., 0., 3.61803, 3.61803, -1., 5.23607, 0.], [0., 0., 1., 0., 0., 0., 0.], [0., 0., 0., 1., 0., 0., 0.], [0., 0., 2., 5.23607, -1., 5.23607, 0.], [0., 0., 0., 0., 0., 1., 0.], [0., 0., 2.2918, 3.52786, -0.763932, 3., 0.]]),
|
||||||
|
np.array([[0., -0.618034, 0., 2.61803, 4.23607, 5.23607, 0.], [0., -1., 0., 5.23607, 5.23607, 8.47214, 0.], [0., -0.618034, 0., 4.23607, 2.61803, 5.23607, 0.], [0., 0., 0., 1., 0., 0., 0.], [0., 0., 0., 0., 1., 0., 0.], [0., 0., 0., 0., 0., 1., 0.], [0., -0.472136, 0., 2.76393, 2.76393, 3., 0.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0., 0.], [4.23607, 0., -0.618034, 0., 2.61803, 5.23607, 0.], [5.23607, 0., -1., 0., 5.23607, 8.47214, 0.], [2.61803, 0., -0.618034, 0., 4.23607, 5.23607, 0.], [0., 0., 0., 0., 1., 0., 0.], [0., 0., 0., 0., 0., 1., 0.], [2.76393, 0., -0.472136, 0., 2.76393, 3., 0.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0., 0.], [0., 1., 0., 0., 0., 0., 0.], [2.61803,4.23607, 0., -0.618034, 0., 0., 5.23607], [5.23607, 5.23607, 0., -1., 0., 0., 8.47214], [4.23607, 2.61803, 0., -0.618034, 0., 0.,5.23607], [2.76393, 2.76393, 0., -0.472136, 0., 0., 3.], [0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[-1., 5.23607, 2., 0., 0., 0., 5.23607], [0., 1., 0., 0., 0., 0., 0.], [0., 0., 1., 0., 0., 0., 0.], [-1., 3.61803, 3.61803, 0., 0., 0., 5.23607], [-1.61803, 6.8541, 4.23607, 0., 0., 0., 8.47214], [-0.763932, 3.52786, 2.2918, 0., 0., 0., 3.], [0., 0., 0.,0., 0., 0., 1.]]),
|
||||||
|
np.array([[-1., 0., 5.23607, 5.23607, 0., 0., 8.47214], [-0.618034, 0., 4.23607, 2.61803, 0., 0., 5.23607], [0., 0., 1., 0., 0., 0., 0.], [0., 0., 0., 1., 0., 0., 0.], [-0.618034, 0., 2.61803, 4.23607,0., 0., 5.23607], [-0.472136, 0., 2.76393, 2.76393, 0., 0., 3.], [0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[-1., 0., 0., 2., 5.23607, 0., 5.23607], [-1.61803, 0., 0., 4.23607, 6.8541, 0., 8.47214], [-1., 0., 0., 3.61803, 3.61803, 0., 5.23607], [0., 0., 0., 1., 0., 0., 0.], [0., 0., 0., 0., 1., 0., 0.], [-0.763932, 0., 0., 2.2918, 3.52786, 0., 3.], [0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0., 0.], [4.61803, 0., 0., 0., 3., -1.30902, 3.92705], [5.8541, 0., 0., 0., 5.8541, -2.11803, 6.3541], [3., 0., 0., 0., 4.61803, -1.30902, 3.92705], [0., 0., 0., 0., 1., 0., 0.], [3.05573, 0., 0., 0., 3.05573, -1., 2.], [0., 0., 0., 0., 0., 0., 1.]])]
|
||||||
|
root = Node([2.7013, 2.7013, 2.7013, 2.7013, 2.7013, 3.85184, -1.], [], words, False)
|
||||||
|
current_leaves = [root]
|
||||||
|
nodes = 1
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
next_gen = leaf.next_generation(words, dc, generators)
|
||||||
|
new_leaves += next_gen
|
||||||
|
nodes += len(next_gen) if len(next_gen) > 1 else 0
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
for i,leaf in enumerate(current_leaves):
|
||||||
|
words[str(leaf.word)] = i
|
||||||
|
print(len(current_leaves), "partitions")
|
||||||
|
print(nodes,"nodes")
|
||||||
|
return current_leaves
|
||||||
|
|
||||||
|
def constructMatrix(words, dc):
|
||||||
|
leave = generateTree(words, dc)
|
||||||
|
row = []
|
||||||
|
col = []
|
||||||
|
data = []
|
||||||
|
for i,leaf in enumerate(leave):
|
||||||
|
thing = words[str(leaf.word[1:])]
|
||||||
|
if isinstance(thing,int):
|
||||||
|
row.append(i)
|
||||||
|
col.append(thing)
|
||||||
|
data.append(sampleValue(leaf.word))
|
||||||
|
else:
|
||||||
|
sample = sampleValue(leaf.word)
|
||||||
|
for wor in thing.leaves():
|
||||||
|
row.append(i)
|
||||||
|
col.append(words[str(wor.word)])
|
||||||
|
data.append(sample)
|
||||||
|
return csr_matrix((data,(row,col)),shape=(len(leave),len(leave)))
|
||||||
|
|
||||||
|
def secant(x0,y0,x1,y1,z):
|
||||||
|
return x0 - (y0-z) * ((x1-x0)/(y1-y0))
|
||||||
|
|
||||||
|
def matrixFunction(matrix,l,a):
|
||||||
|
matrix = matrix.power(a)
|
||||||
|
vec = np.ones(l)
|
||||||
|
previous_entry = vec[0]
|
||||||
|
previous_val = 0
|
||||||
|
current = matrix * vec
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count = 0
|
||||||
|
while count < 10000000000 and abs(current_val - previous_val) > 1e-15:
|
||||||
|
previous_val = current_val
|
||||||
|
previous_entry = current[0]
|
||||||
|
current = matrix * current
|
||||||
|
#print(current[0],previous_entry)
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count += 1
|
||||||
|
print("power method:", count)
|
||||||
|
return current_val
|
||||||
|
|
||||||
|
def secantMethod(matrix,l,z,x1,x2,e,its):
|
||||||
|
k1 = x1
|
||||||
|
k2 = x2
|
||||||
|
y1 = matrixFunction(matrix,l,k1)
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y1 = testFunction(k1)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count = 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
while abs(y1-z)>e and count<its:
|
||||||
|
k3 = secant(k1,y1,k2,y2,z)
|
||||||
|
k1 = k2
|
||||||
|
y1 = y2
|
||||||
|
k2 = k3
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count += 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
start = time.time()
|
||||||
|
|
||||||
|
words = {}
|
||||||
|
|
||||||
|
m = 1000
|
||||||
|
print("maximum:",m)
|
||||||
|
matrix = constructMatrix(words,m)
|
||||||
|
#print(matrix)
|
||||||
|
|
||||||
|
print("construction (s): %f\nconstruction (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
#print(csr_matrix.transpose(matrix))
|
||||||
|
print(csr_matrix.count_nonzero(matrix), (matrix.shape[0])*9)
|
||||||
|
secantMethod(matrix,matrix.shape[0],1,1.33,1.34,10**(-10),1000)
|
||||||
|
|
||||||
|
print("total (s): %f\ntotal (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
|
||||||
|
main()
|
||||||
69
fractal_dimension/mcmullen_stuff/real6v6f1node.py
Normal file
69
fractal_dimension/mcmullen_stuff/real6v6f1node.py
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
import numpy as np
|
||||||
|
import math
|
||||||
|
|
||||||
|
class Node:
|
||||||
|
def __init__(self, tuple, word, words, infertile):
|
||||||
|
self.tuple = tuple
|
||||||
|
self.children = []
|
||||||
|
self.word = word
|
||||||
|
self.infertile = infertile
|
||||||
|
words[str(word)] = self
|
||||||
|
|
||||||
|
def dc_not_too_big(self, g, generator, dual_curvature):
|
||||||
|
temp = np.matmul(generator, self.tuple)
|
||||||
|
if g == 0:
|
||||||
|
temp = [temp[i] for i in (2,3,4,5)]
|
||||||
|
#print(temp)
|
||||||
|
if temp[-1]<0:
|
||||||
|
return True
|
||||||
|
if temp[0]*temp[1]*temp[2] + temp[0]*temp[1]*temp[3] + temp[0]*temp[2]*temp[3] + temp[1]*temp[2]*temp[3] < 0:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return math.sqrt(temp[0]*temp[1]*temp[2] + temp[0]*temp[1]*temp[3] + temp[0]*temp[2]*temp[3] + temp[1]*temp[2]*temp[3])/math.sqrt(temp[0] + temp[1] + temp[2] + temp[3]) < dual_curvature
|
||||||
|
elif g == 1:
|
||||||
|
temp = [temp[i] for i in (1,2,5)]
|
||||||
|
elif g == 2:
|
||||||
|
temp = [temp[i] for i in (0,1,5)]
|
||||||
|
elif g == 3:
|
||||||
|
temp = [temp[i] for i in (0,4,5)]
|
||||||
|
elif g == 4:
|
||||||
|
temp = [temp[i] for i in (0,1,2,3)]
|
||||||
|
#print(temp)
|
||||||
|
if temp[0]*temp[1]*temp[2] + temp[0]*temp[1]*temp[3] + temp[0]*temp[2]*temp[3] + temp[1]*temp[2]*temp[3] < 0:
|
||||||
|
return False
|
||||||
|
return math.sqrt(temp[0]*temp[1]*temp[2] + temp[0]*temp[1]*temp[3] + temp[0]*temp[2]*temp[3] + temp[1]*temp[2]*temp[3])/math.sqrt(temp[0] + temp[1] + temp[2] + temp[3]) < dual_curvature
|
||||||
|
elif g == 5:
|
||||||
|
temp = [temp[i] for i in (0,3,4)]
|
||||||
|
if temp[0]*temp[1]+temp[0]*temp[2]+temp[1]*temp[2] < 0:
|
||||||
|
return False
|
||||||
|
return math.sqrt(temp[0]*temp[1]+temp[0]*temp[2]+temp[1]*temp[2])<dual_curvature
|
||||||
|
|
||||||
|
def next_generation(self, words, dual_curvature, generators):
|
||||||
|
if self.infertile:
|
||||||
|
return [self]
|
||||||
|
if self.children == []:
|
||||||
|
for g,generator in enumerate(generators):
|
||||||
|
if len(self.word) == 0 or g != self.word[-1]:
|
||||||
|
self.children.append(Node(np.matmul(generator,self.tuple), self.word[:] + [g], words, not self.dc_not_too_big(g, generator, dual_curvature)))
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def leaves(self):
|
||||||
|
current_leaves = [self]
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
new_leaves += leaf.next()
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
return current_leaves
|
||||||
161
fractal_dimension/mcmullen_stuff/real6v6f1tree.py
Normal file
161
fractal_dimension/mcmullen_stuff/real6v6f1tree.py
Normal file
|
|
@ -0,0 +1,161 @@
|
||||||
|
#https://www.desmos.com/calculator/1aoycwgvuz
|
||||||
|
|
||||||
|
from real6v6f1node import Node
|
||||||
|
import math
|
||||||
|
import numpy as np
|
||||||
|
import time
|
||||||
|
from scipy.sparse import csr_matrix
|
||||||
|
|
||||||
|
def functions(n, z):
|
||||||
|
if n == 0:
|
||||||
|
return -1*np.conj(z)
|
||||||
|
else:
|
||||||
|
duals = [[],[0.60056621200156+1j,0.60056621200156],
|
||||||
|
[1.11757463364131127+0.028662703870927425j,0.49979457015027892407],
|
||||||
|
[0.63600982475703-1j,0.63600982475703],
|
||||||
|
[0.312309249205871+0.133830541363598j,0.312309249205871],
|
||||||
|
[0.174700306168316-0.333333333333333j,0.174700306168316]]
|
||||||
|
return duals[n][0] + np.conj((duals[n][1])**2 / (z-duals[n][0]))
|
||||||
|
|
||||||
|
def derivatives(n, z):
|
||||||
|
if n == 0:
|
||||||
|
return abs(-1)
|
||||||
|
else:
|
||||||
|
duals = [[],[0.60056621200156+1j,0.60056621200156],
|
||||||
|
[1.11757463364131127+0.028662703870927425j,0.49979457015027892407],
|
||||||
|
[0.63600982475703-1j,0.63600982475703],
|
||||||
|
[0.312309249205871+0.133830541363598j,0.312309249205871],
|
||||||
|
[0.174700306168316-0.333333333333333j,0.174700306168316]]
|
||||||
|
return abs(-1*((z-duals[n][0])**2) / ((duals[n][1])**2))
|
||||||
|
|
||||||
|
def samplePoint(word):
|
||||||
|
points = [-0.5, 0.5+0.7j, 0.9+0.05j, 0.45-0.75j, 0.3+0.1j, 0.15-0.33j]
|
||||||
|
p = points[word[-1]]
|
||||||
|
for letter in word[-2::-1]:
|
||||||
|
p = functions(letter, p)
|
||||||
|
return p
|
||||||
|
|
||||||
|
def sampleValue(word):
|
||||||
|
return derivatives(word[0], samplePoint(word))
|
||||||
|
|
||||||
|
def generateTree(words, dc):
|
||||||
|
generators = [np.array([[0., -0.618034, 0., 2.23607, -0.527864, 2.8541], [0., -1., 0.,
|
||||||
|
5.23607, -2.47214, 7.23607], [0., 0., 0., 1.61803, -1.,
|
||||||
|
1.61803], [0., 0., 0., 1., 0., 0.], [0., 0., 0., 0., 1., 0.], [0.,
|
||||||
|
0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[0., 2.61803, 2.61803, 0., -0.381966, 3.8541], [0., 1., 0., 0., 0.,
|
||||||
|
0.], [0., 0., 1., 0., 0., 0.], [0., 3.23607, 5.8541, 0., -0.618034,
|
||||||
|
6.23607], [0., 5.23607, 8.47214, 0., -1., 11.7082], [0., 0., 0., 0.,
|
||||||
|
0., 1.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0.], [0., 1., 0., 0., 0., 0.], [3., 2.61803,
|
||||||
|
0., -0.618034, 0., 3.23607], [6.47214, 3.23607, 0., -1., 0.,
|
||||||
|
5.23607], [7.47214, 2.61803, 0., -1., 0., 6.8541], [0., 0., 0., 0.,
|
||||||
|
0., 1.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0.], [6.8541, 0., 0., -1.61803, 3.61803,
|
||||||
|
5.8541], [5.23607, 0., 0., -1.61803, 4.23607, 4.8541], [3.23607, 0.,
|
||||||
|
0., -1., 3.23607, 2.], [0., 0., 0., 0., 1., 0.], [0., 0., 0., 0.,
|
||||||
|
0., 1.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0.], [0., 1., 0., 0., 0., 0.], [-1., 0.618034,
|
||||||
|
0., 0.618034, 0., 0.], [0., 0., 0., 1., 0., 0.], [1., 1.38197, 0.,
|
||||||
|
2.23607, 0., -1.61803], [0., 1.23607, 0., 0.763932, 0., -1.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0.], [10.0902, 0., 0., 6.8541,
|
||||||
|
6.8541, -2.61803], [5.23607, 0., 0., 4.8541,
|
||||||
|
4.23607, -1.61803], [0., 0., 0., 1., 0., 0.], [0., 0., 0., 0., 1.,
|
||||||
|
0.], [3.23607, 0., 0., 2., 3.23607, -1.]])]
|
||||||
|
root = Node([2.73606797749979, 3.88196601125011, 2.30901699437495, \
|
||||||
|
4.28115294937453, 3.00000000000000, -1.00000000000000], [], words, False)
|
||||||
|
current_leaves = [root]
|
||||||
|
nodes = 1
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
next_gen = leaf.next_generation(words, dc, generators)
|
||||||
|
new_leaves += next_gen
|
||||||
|
nodes += len(next_gen) if len(next_gen) > 1 else 0
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
for i,leaf in enumerate(current_leaves):
|
||||||
|
words[str(leaf.word)] = i
|
||||||
|
print(len(current_leaves), "partitions")
|
||||||
|
print(nodes,"nodes")
|
||||||
|
return current_leaves
|
||||||
|
|
||||||
|
def constructMatrix(words, dc):
|
||||||
|
leave = generateTree(words, dc)
|
||||||
|
row = []
|
||||||
|
col = []
|
||||||
|
data = []
|
||||||
|
for i,leaf in enumerate(leave):
|
||||||
|
thing = words[str(leaf.word[1:])]
|
||||||
|
if isinstance(thing,int):
|
||||||
|
row.append(i)
|
||||||
|
col.append(thing)
|
||||||
|
data.append(sampleValue(leaf.word))
|
||||||
|
else:
|
||||||
|
sample = sampleValue(leaf.word)
|
||||||
|
for wor in thing.leaves():
|
||||||
|
row.append(i)
|
||||||
|
col.append(words[str(wor.word)])
|
||||||
|
data.append(sample)
|
||||||
|
return csr_matrix((data,(row,col)),shape=(len(leave),len(leave)))
|
||||||
|
|
||||||
|
def secant(x0,y0,x1,y1,z):
|
||||||
|
return x0 - (y0-z) * ((x1-x0)/(y1-y0))
|
||||||
|
|
||||||
|
def matrixFunction(matrix,l,a):
|
||||||
|
matrix = matrix.power(a)
|
||||||
|
vec = np.ones(l)
|
||||||
|
previous_entry = vec[0]
|
||||||
|
previous_val = 0
|
||||||
|
current = matrix * vec
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count = 0
|
||||||
|
while count < 10000000000 and abs(current_val - previous_val) > 1e-15:
|
||||||
|
previous_val = current_val
|
||||||
|
previous_entry = current[0]
|
||||||
|
current = matrix * current
|
||||||
|
#print(current[0],previous_entry)
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count += 1
|
||||||
|
print("power method:", count)
|
||||||
|
return current_val
|
||||||
|
|
||||||
|
def secantMethod(matrix,l,z,x1,x2,e,its):
|
||||||
|
k1 = x1
|
||||||
|
k2 = x2
|
||||||
|
y1 = matrixFunction(matrix,l,k1)
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y1 = testFunction(k1)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count = 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
while abs(y1-z)>e and count<its:
|
||||||
|
k3 = secant(k1,y1,k2,y2,z)
|
||||||
|
k1 = k2
|
||||||
|
y1 = y2
|
||||||
|
k2 = k3
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count += 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
start = time.time()
|
||||||
|
|
||||||
|
words = {}
|
||||||
|
|
||||||
|
m = 500
|
||||||
|
print("maximum:",m)
|
||||||
|
matrix = constructMatrix(words,m)
|
||||||
|
#print(matrix)
|
||||||
|
|
||||||
|
print("construction (s): %f\nconstruction (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
#print(csr_matrix.transpose(matrix))
|
||||||
|
print(csr_matrix.count_nonzero(matrix), (matrix.shape[0])*5)
|
||||||
|
secantMethod(matrix,matrix.shape[0],1,1.33,1.34,10**(-10),1000)
|
||||||
|
|
||||||
|
print("total (s): %f\ntotal (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
|
||||||
|
main()
|
||||||
48
fractal_dimension/mcmullen_stuff/septanode.py
Normal file
48
fractal_dimension/mcmullen_stuff/septanode.py
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
import numpy as np
|
||||||
|
import math
|
||||||
|
|
||||||
|
class Node:
|
||||||
|
def __init__(self, tuple, word, words, infertile):
|
||||||
|
self.tuple = tuple
|
||||||
|
self.children = []
|
||||||
|
self.word = word
|
||||||
|
self.infertile = infertile
|
||||||
|
words[str(word)] = self
|
||||||
|
|
||||||
|
def dc_not_too_big(self, g, generator, dual_curvature):
|
||||||
|
temp = np.matmul(generator, self.tuple)
|
||||||
|
if g <= 6:
|
||||||
|
temp = [temp[i] for i in (g%7, (g+1)%7, 7)]
|
||||||
|
else:
|
||||||
|
temp = [temp[i] for i in (g%7, (g+1)%7, 8)]
|
||||||
|
return math.sqrt(temp[0]*temp[1] + temp[0]*temp[2] + temp[1]*temp[2]) < dual_curvature
|
||||||
|
|
||||||
|
def next_generation(self, words, dual_curvature, generators):
|
||||||
|
if self.infertile:
|
||||||
|
return [self]
|
||||||
|
if self.children == []:
|
||||||
|
for g,generator in enumerate(generators):
|
||||||
|
if len(self.word) == 0 or g != self.word[-1]:
|
||||||
|
self.children.append(Node(np.matmul(generator,self.tuple), self.word[:] + [g], words, not self.dc_not_too_big(g, generator, dual_curvature)))
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
if self.children == []:
|
||||||
|
return [self]
|
||||||
|
else:
|
||||||
|
return self.children
|
||||||
|
|
||||||
|
def leaves(self):
|
||||||
|
current_leaves = [self]
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
new_leaves += leaf.next()
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
return current_leaves
|
||||||
285
fractal_dimension/mcmullen_stuff/septatreemcmullen.py
Normal file
285
fractal_dimension/mcmullen_stuff/septatreemcmullen.py
Normal file
|
|
@ -0,0 +1,285 @@
|
||||||
|
from septanode import Node
|
||||||
|
import math
|
||||||
|
import numpy as np
|
||||||
|
import time
|
||||||
|
from scipy.sparse import csr_matrix
|
||||||
|
|
||||||
|
def functions(n, z):
|
||||||
|
if n == 0:
|
||||||
|
return 0.394813223302777 + 0.190132027512207j + np.conj(0.0361501878859025/(-0.394813223302777 - 0.190132027512207j + z))
|
||||||
|
elif n == 1:
|
||||||
|
return 0.0975108134337358 + 0.427222787833377j + np.conj(0.0361501878859025/(-0.0975108134337358 - 0.427222787833377j + z))
|
||||||
|
elif n == 2:
|
||||||
|
return -0.273219227809010 + 0.342606075159329j + np.conj(0.0361501878859025/(0.273219227809010 - 0.342606075159329j + z))
|
||||||
|
elif n == 3:
|
||||||
|
return -0.438209617855007 + np.conj(0.0361501878859025/(0.438209617855007 + z))
|
||||||
|
elif n == 4:
|
||||||
|
return -0.273219227809010 - 0.342606075159329j + np.conj(0.0361501878859025/(0.273219227809010 + 0.342606075159329j + z))
|
||||||
|
elif n == 5:
|
||||||
|
return 0.0975108134337358 - 0.427222787833377j + np.conj(0.0361501878859025/(-0.0975108134337358 + 0.427222787833377j + z))
|
||||||
|
elif n == 6:
|
||||||
|
return 0.394813223302777 - 0.190132027512207j + np.conj(0.0361501878859025/(-0.394813223302777 + 0.190132027512207j + z))
|
||||||
|
elif n == 7:
|
||||||
|
return 1.00000000000000 + 0.481574618807529j + np.conj(0.231914113479617/(-1.00000000000000 - 0.481574618807529j + z))
|
||||||
|
elif n == 8:
|
||||||
|
return 0.246979603717467 + 1.08208834612853j + np.conj(0.231914113479617/(-0.246979603717467 - 1.08208834612853j + z))
|
||||||
|
elif n == 9:
|
||||||
|
return -0.692021471630096 + 0.867767478235116j + np.conj(0.231914113479617/(0.692021471630096 - 0.867767478235116j + z))
|
||||||
|
elif n == 10:
|
||||||
|
return -1.10991626417474 + np.conj(0.231914113479617/(1.10991626417474 + z))
|
||||||
|
elif n == 11:
|
||||||
|
return -0.692021471630096 - 0.867767478235116j + np.conj(0.231914113479617/(0.692021471630096 + 0.867767478235116j + z))
|
||||||
|
elif n == 12:
|
||||||
|
return 0.246979603717467 - 1.08208834612853j + np.conj(0.231914113479617/(-0.246979603717467 + 1.08208834612853j + z))
|
||||||
|
elif n == 13:
|
||||||
|
return 1.00000000000000 - 0.481574618807529j + np.conj(0.231914113479617/(-1.00000000000000 + 0.481574618807529j + z))
|
||||||
|
|
||||||
|
def derivatives(n, z):
|
||||||
|
if n == 0:
|
||||||
|
return abs(-27.6623735167354*(-0.394813223302777 - 0.190132027512207j + z)**2)
|
||||||
|
elif n == 1:
|
||||||
|
return abs(-27.6623735167354*(-0.0975108134337358 - 0.427222787833377j + z)**2)
|
||||||
|
elif n == 2:
|
||||||
|
return abs(-27.6623735167354*(0.273219227809010 - 0.342606075159329j + z)**2)
|
||||||
|
elif n == 3:
|
||||||
|
return abs(-27.6623735167354*(0.438209617855007 + z)**2)
|
||||||
|
elif n == 4:
|
||||||
|
return abs(-27.6623735167354*(0.273219227809010 + 0.342606075159329j + z)**2)
|
||||||
|
elif n == 5:
|
||||||
|
return abs(-27.6623735167354*(-0.0975108134337358 + 0.427222787833377j + z)**2)
|
||||||
|
elif n == 6:
|
||||||
|
return abs(-27.6623735167354*(-0.394813223302777 + 0.190132027512207j + z)**2)
|
||||||
|
elif n == 7:
|
||||||
|
return abs(-4.31194111042273*(-1.00000000000000 - 0.481574618807529j + z)**2)
|
||||||
|
elif n == 8:
|
||||||
|
return abs(-4.31194111042273*(-0.246979603717467 - 1.08208834612853j + z)**2)
|
||||||
|
elif n == 9:
|
||||||
|
return abs(-4.31194111042273*(0.692021471630096 - 0.867767478235116j + z)**2)
|
||||||
|
elif n == 10:
|
||||||
|
return abs(-4.31194111042273*(1.10991626417474 + z)**2)
|
||||||
|
elif n == 11:
|
||||||
|
return abs(-4.31194111042273*(0.692021471630096 + 0.867767478235116j + z)**2)
|
||||||
|
elif n == 12:
|
||||||
|
return abs(-4.31194111042273*(-0.246979603717467 + 1.08208834612853j + z)**2)
|
||||||
|
elif n == 13:
|
||||||
|
return abs(-4.31194111042273*(-1.00000000000000 + 0.481574618807529j + z)**2)
|
||||||
|
|
||||||
|
|
||||||
|
def samplePoint(word):
|
||||||
|
points = [0.394813223302777 + 0.190132027512207j, 0.0975108134337358 +
|
||||||
|
0.427222787833377j, -0.273219227809010 +
|
||||||
|
0.342606075159329j, -0.438209617855007, -0.273219227809010 -
|
||||||
|
0.342606075159329j, 0.0975108134337358 -
|
||||||
|
0.427222787833377j, 0.394813223302777 - 0.190132027512207j, 0.8 +
|
||||||
|
0.38526j, 0.197584 + 0.865671j, -0.553617 +
|
||||||
|
0.694214j, -0.887933, -0.553617 - 0.694214j, 0.197584 -
|
||||||
|
0.865671j, 0.8 - 0.38526j]
|
||||||
|
p = points[word[-1]]
|
||||||
|
for letter in word[-2::-1]:
|
||||||
|
p = functions(letter, p)
|
||||||
|
return p
|
||||||
|
|
||||||
|
def sampleValue(word):
|
||||||
|
return derivatives(word[0], samplePoint(word))
|
||||||
|
|
||||||
|
def generateTree(words, dc):
|
||||||
|
|
||||||
|
generators = [np.array([[1., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 1., 0., 0., 0., 0., 0.,
|
||||||
|
0., 0.], [3.24698, 4.69202, 0., 0., 0., -0.445042, 0., 6.49396,
|
||||||
|
0.], [8.2959, 8.2959, 0., 0., 0., -1., 0., 14.5918, 0.], [11.3448,
|
||||||
|
9.09783, 0., 0., 0., -1.24698, 0., 18.1957, 0.], [10.0978, 6.49396,
|
||||||
|
0., 0., 0., -1., 0., 14.5918, 0.], [5.49396, 2.44504, 0., 0.,
|
||||||
|
0., -0.445042, 0., 6.49396, 0.], [0., 0., 0., 0., 0., 0., 0., 1.,
|
||||||
|
0.], [2.61596, 2.122, 0., 0., 0., -0.274127, 0., 3., 0.]]),
|
||||||
|
np.array([[0., 5.04892, 2.80194, 0., 0., -0.356896, 0., 6.49396, 0.], [0., 1.,
|
||||||
|
0., 0., 0., 0., 0., 0., 0.], [0., 0., 1., 0., 0., 0., 0., 0.,
|
||||||
|
0.], [0., 2.80194, 5.04892, 0., 0., -0.356896, 0., 6.49396,
|
||||||
|
0.], [0., 7.2959, 9.09783, 0., 0., -0.801938, 0., 14.5918, 0.], [0.,
|
||||||
|
10.0978, 10.0978, 0., 0., -1., 0., 18.1957, 0.], [0., 9.09783,
|
||||||
|
7.2959, 0., 0., -0.801938, 0., 14.5918, 0.], [0., 0., 0., 0., 0.,
|
||||||
|
0., 0., 1., 0.], [0., 2.34183, 2.34183, 0., 0., -0.219833, 0., 3.,
|
||||||
|
0.]]),
|
||||||
|
np.array([[0., 0., 7.2959, 10.5429, -2.24698, 0., 0., 14.5918, 0.], [0., 0.,
|
||||||
|
4.24698, 4.24698, -1., 0., 0., 6.49396, 0.], [0., 0., 1., 0., 0.,
|
||||||
|
0., 0., 0., 0.], [0., 0., 0., 1., 0., 0., 0., 0., 0.], [0., 0., 2.,
|
||||||
|
6.49396, -1., 0., 0., 6.49396, 0.], [0., 0., 5.49396,
|
||||||
|
12.3448, -2.24698, 0., 0., 14.5918, 0.], [0., 0., 7.85086,
|
||||||
|
14.1468, -2.80194, 0., 0., 18.1957, 0.], [0., 0., 0., 0., 0., 0.,
|
||||||
|
0., 1., 0.], [0., 0., 1.84787, 3.23191, -0.615957, 0., 0., 3., 0.]]),
|
||||||
|
np.array([[0., 0., -2.80194, 14.1468, 7.85086, 0., 0., 18.1957, 0.], [0.,
|
||||||
|
0., -2.24698, 12.3448, 5.49396, 0., 0., 14.5918, 0.], [0., 0., -1.,
|
||||||
|
6.49396, 2., 0., 0., 6.49396, 0.], [0., 0., 0., 1., 0., 0., 0., 0.,
|
||||||
|
0.], [0., 0., 0., 0., 1., 0., 0., 0., 0.], [0., 0., -1., 4.24698,
|
||||||
|
4.24698, 0., 0., 6.49396, 0.], [0., 0., -2.24698, 10.5429, 7.2959,
|
||||||
|
0., 0., 14.5918, 0.], [0., 0., 0., 0., 0., 0., 0., 1., 0.], [0.,
|
||||||
|
0., -0.615957, 3.23191, 1.84787, 0., 0., 3., 0.]]),
|
||||||
|
np.array([[0., -0.801938, 0., 0., 7.2959, 9.09783, 0., 14.5918, 0.], [0., -1.,
|
||||||
|
0., 0., 10.0978, 10.0978, 0., 18.1957, 0.], [0., -0.801938, 0., 0.,
|
||||||
|
9.09783, 7.2959, 0., 14.5918, 0.], [0., -0.356896, 0., 0., 5.04892,
|
||||||
|
2.80194, 0., 6.49396, 0.], [0., 0., 0., 0., 1., 0., 0., 0.,
|
||||||
|
0.], [0., 0., 0., 0., 0., 1., 0., 0., 0.], [0., -0.356896, 0., 0.,
|
||||||
|
2.80194, 5.04892, 0., 6.49396, 0.], [0., 0., 0., 0., 0., 0., 0., 1.,
|
||||||
|
0.], [0., -0.219833, 0., 0., 2.34183, 2.34183, 0., 3., 0.]]),
|
||||||
|
np.array([[0., 0., 0., -0.445042, 0., 3.24698, 4.69202, 6.49396, 0.], [0., 0.,
|
||||||
|
0., -1., 0., 8.2959, 8.2959, 14.5918, 0.], [0., 0., 0., -1.24698,
|
||||||
|
0., 11.3448, 9.09783, 18.1957, 0.], [0., 0., 0., -1., 0., 10.0978,
|
||||||
|
6.49396, 14.5918, 0.], [0., 0., 0., -0.445042, 0., 5.49396, 2.44504,
|
||||||
|
6.49396, 0.], [0., 0., 0., 0., 0., 1., 0., 0., 0.], [0., 0., 0.,
|
||||||
|
0., 0., 0., 1., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 1., 0.], [0.,
|
||||||
|
0., 0., -0.274127, 0., 2.61596, 2.122, 3., 0.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0., 0., 0., 0.], [4.24698, 0., 0., 0., 0., -1.,
|
||||||
|
4.24698, 6.49396, 0.], [7.2959, 0., 0., 0., 0., -2.24698, 10.5429,
|
||||||
|
14.5918, 0.], [7.85086, 0., 0., 0., 0., -2.80194, 14.1468, 18.1957,
|
||||||
|
0.], [5.49396, 0., 0., 0., 0., -2.24698, 12.3448, 14.5918, 0.], [2.,
|
||||||
|
0., 0., 0., 0., -1., 6.49396, 6.49396, 0.], [0., 0., 0., 0., 0.,
|
||||||
|
0., 1., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 1., 0.], [1.84787, 0.,
|
||||||
|
0., 0., 0., -0.615957, 3.23191, 3., 0.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 1., 0., 0., 0., 0., 0.,
|
||||||
|
0., 0.], [2.80194, 5.04892, 0., 0., -0.356896, 0., 0., 0.,
|
||||||
|
6.49396], [7.2959, 9.09783, 0., 0., -0.801938, 0., 0., 0.,
|
||||||
|
14.5918], [10.0978, 10.0978, 0., 0., -1., 0., 0., 0.,
|
||||||
|
18.1957], [9.09783, 7.2959, 0., 0., -0.801938, 0., 0., 0.,
|
||||||
|
14.5918], [5.04892, 2.80194, 0., 0., -0.356896, 0., 0., 0.,
|
||||||
|
6.49396], [2.34183, 2.34183, 0., 0., -0.219833, 0., 0., 0.,
|
||||||
|
3.], [0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[0., 4.69202, 3.24698, 0., -0.445042, 0., 0., 0., 6.49396], [0., 1.,
|
||||||
|
0., 0., 0., 0., 0., 0., 0.], [0., 0., 1., 0., 0., 0., 0., 0.,
|
||||||
|
0.], [0., 2.44504, 5.49396, 0., -0.445042, 0., 0., 0.,
|
||||||
|
6.49396], [0., 6.49396, 10.0978, 0., -1., 0., 0., 0., 14.5918], [0.,
|
||||||
|
9.09783, 11.3448, 0., -1.24698, 0., 0., 0., 18.1957], [0., 8.2959,
|
||||||
|
8.2959, 0., -1., 0., 0., 0., 14.5918], [0., 2.122, 2.61596,
|
||||||
|
0., -0.274127, 0., 0., 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0.,
|
||||||
|
1.]]),
|
||||||
|
np.array([[0., 0., 9.09783, 7.2959, 0., 0., -0.801938, 0., 14.5918], [0., 0.,
|
||||||
|
5.04892, 2.80194, 0., 0., -0.356896, 0., 6.49396], [0., 0., 1., 0.,
|
||||||
|
0., 0., 0., 0., 0.], [0., 0., 0., 1., 0., 0., 0., 0., 0.], [0., 0.,
|
||||||
|
2.80194, 5.04892, 0., 0., -0.356896, 0., 6.49396], [0., 0., 7.2959,
|
||||||
|
9.09783, 0., 0., -0.801938, 0., 14.5918], [0., 0., 10.0978, 10.0978,
|
||||||
|
0., 0., -1., 0., 18.1957], [0., 0., 2.34183, 2.34183, 0.,
|
||||||
|
0., -0.219833, 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[0., -1.24698, 0., 11.3448, 9.09783, 0., 0., 0., 18.1957], [0., -1.,
|
||||||
|
0., 10.0978, 6.49396, 0., 0., 0., 14.5918], [0., -0.445042, 0.,
|
||||||
|
5.49396, 2.44504, 0., 0., 0., 6.49396], [0., 0., 0., 1., 0., 0., 0.,
|
||||||
|
0., 0.], [0., 0., 0., 0., 1., 0., 0., 0., 0.], [0., -0.445042, 0.,
|
||||||
|
3.24698, 4.69202, 0., 0., 0., 6.49396], [0., -1., 0., 8.2959,
|
||||||
|
8.2959, 0., 0., 0., 14.5918], [0., -0.274127, 0., 2.61596, 2.122,
|
||||||
|
0., 0., 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[-1., 0., 0., 0., 6.49396, 10.0978, 0., 0., 14.5918], [-1.24698, 0.,
|
||||||
|
0., 0., 9.09783, 11.3448, 0., 0., 18.1957], [-1., 0., 0., 0.,
|
||||||
|
8.2959, 8.2959, 0., 0., 14.5918], [-0.445042, 0., 0., 0., 4.69202,
|
||||||
|
3.24698, 0., 0., 6.49396], [0., 0., 0., 0., 1., 0., 0., 0.,
|
||||||
|
0.], [0., 0., 0., 0., 0., 1., 0., 0., 0.], [-0.445042, 0., 0., 0.,
|
||||||
|
2.44504, 5.49396, 0., 0., 6.49396], [-0.274127, 0., 0., 0., 2.122,
|
||||||
|
2.61596, 0., 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[0., 0., -0.356896, 0., 0., 2.80194, 5.04892, 0., 6.49396], [0.,
|
||||||
|
0., -0.801938, 0., 0., 7.2959, 9.09783, 0., 14.5918], [0., 0., -1.,
|
||||||
|
0., 0., 10.0978, 10.0978, 0., 18.1957], [0., 0., -0.801938, 0., 0.,
|
||||||
|
9.09783, 7.2959, 0., 14.5918], [0., 0., -0.356896, 0., 0., 5.04892,
|
||||||
|
2.80194, 0., 6.49396], [0., 0., 0., 0., 0., 1., 0., 0., 0.], [0.,
|
||||||
|
0., 0., 0., 0., 0., 1., 0., 0.], [0., 0., -0.219833, 0., 0.,
|
||||||
|
2.34183, 2.34183, 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 1.]]),
|
||||||
|
np.array([[1., 0., 0., 0., 0., 0., 0., 0., 0.], [4.24698, 0., 0., 0., 0., -1.,
|
||||||
|
4.24698, 0., 6.49396], [7.2959, 0., 0., 0., 0., -2.24698, 10.5429,
|
||||||
|
0., 14.5918], [7.85086, 0., 0., 0., 0., -2.80194, 14.1468, 0.,
|
||||||
|
18.1957], [5.49396, 0., 0., 0., 0., -2.24698, 12.3448, 0.,
|
||||||
|
14.5918], [2., 0., 0., 0., 0., -1., 6.49396, 0., 6.49396], [0., 0.,
|
||||||
|
0., 0., 0., 0., 1., 0., 0.], [1.84787, 0., 0., 0., 0., -0.615957,
|
||||||
|
3.23191, 0., 3.], [0., 0., 0., 0., 0., 0., 0., 0., 1.]])]
|
||||||
|
|
||||||
|
root = Node([3.30476487096249, 3.30476487096249, 3.30476487096249, \
|
||||||
|
3.30476487096249, 3.30476487096249, 3.30476487096249, \
|
||||||
|
3.30476487096249, 2.53284323061569, -1.00000000000000], [], words, False)
|
||||||
|
current_leaves = [root]
|
||||||
|
nodes = 1
|
||||||
|
while True:
|
||||||
|
new_leaves = []
|
||||||
|
for leaf in current_leaves:
|
||||||
|
next_gen = leaf.next_generation(words, dc, generators)
|
||||||
|
new_leaves += next_gen
|
||||||
|
nodes += len(next_gen) if len(next_gen) > 1 else 0
|
||||||
|
if current_leaves == new_leaves:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_leaves = new_leaves
|
||||||
|
for i,leaf in enumerate(current_leaves):
|
||||||
|
words[str(leaf.word)] = i
|
||||||
|
print(len(current_leaves), "partitions")
|
||||||
|
print(nodes,"nodes")
|
||||||
|
return current_leaves
|
||||||
|
|
||||||
|
def constructMatrix(words, dc):
|
||||||
|
leave = generateTree(words, dc)
|
||||||
|
row = []
|
||||||
|
col = []
|
||||||
|
data = []
|
||||||
|
for i,leaf in enumerate(leave):
|
||||||
|
thing = words[str(leaf.word[1:])]
|
||||||
|
if isinstance(thing,int):
|
||||||
|
row.append(i)
|
||||||
|
col.append(thing)
|
||||||
|
data.append(sampleValue(leaf.word))
|
||||||
|
else:
|
||||||
|
sample = sampleValue(leaf.word)
|
||||||
|
for wor in thing.leaves():
|
||||||
|
row.append(i)
|
||||||
|
col.append(words[str(wor.word)])
|
||||||
|
data.append(sample)
|
||||||
|
return csr_matrix((data,(row,col)),shape=(len(leave),len(leave)))
|
||||||
|
|
||||||
|
def secant(x0,y0,x1,y1,z):
|
||||||
|
return x0 - (y0-z) * ((x1-x0)/(y1-y0))
|
||||||
|
|
||||||
|
def matrixFunction(matrix,l,a):
|
||||||
|
matrix = matrix.power(a)
|
||||||
|
vec = np.ones(l)
|
||||||
|
previous_entry = vec[0]
|
||||||
|
previous_val = 0
|
||||||
|
current = matrix * vec
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count = 0
|
||||||
|
while count < 10000000000 and abs(current_val - previous_val) > 1e-15:
|
||||||
|
previous_val = current_val
|
||||||
|
previous_entry = current[0]
|
||||||
|
current = matrix * current
|
||||||
|
#print(current[0],previous_entry)
|
||||||
|
current_val = current[0] / previous_entry
|
||||||
|
count += 1
|
||||||
|
print("power method:", count)
|
||||||
|
return current_val
|
||||||
|
|
||||||
|
def secantMethod(matrix,l,z,x1,x2,e,its):
|
||||||
|
k1 = x1
|
||||||
|
k2 = x2
|
||||||
|
y1 = matrixFunction(matrix,l,k1)
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y1 = testFunction(k1)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count = 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
while abs(y1-z)>e and count<its:
|
||||||
|
k3 = secant(k1,y1,k2,y2,z)
|
||||||
|
k1 = k2
|
||||||
|
y1 = y2
|
||||||
|
k2 = k3
|
||||||
|
y2 = matrixFunction(matrix,l,k2)
|
||||||
|
#y2 = testFunction(k2)
|
||||||
|
count += 1
|
||||||
|
print(count,k1,y1)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
start = time.time()
|
||||||
|
|
||||||
|
m = 100
|
||||||
|
print("maximum:",m)
|
||||||
|
words = {}
|
||||||
|
matrix = constructMatrix(words,m)
|
||||||
|
#print(matrix)
|
||||||
|
|
||||||
|
print("construction (s): %f\nconstruction (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
#print(csr_matrix.transpose(matrix))
|
||||||
|
print(csr_matrix.count_nonzero(matrix), (matrix.shape[0])*13)
|
||||||
|
secantMethod(matrix,matrix.shape[0],1,1.33,1.34,10**(-10),1000)
|
||||||
|
|
||||||
|
print("total (s): %f\ntotal (m): %f" % (time.time()-start, (time.time()-start)/60))
|
||||||
|
|
||||||
|
main()
|
||||||
Loading…
Reference in a new issue