cable class

This commit is contained in:
Maria Marchwicka 2020-08-24 22:20:28 +02:00
parent afbda34111
commit 4cdb4622ab

View File

@ -203,6 +203,248 @@ class SignatureFunction(object):
return 2 * sum(before_arg) + cnt[arg] return 2 * sum(before_arg) + cnt[arg]
class TorusCable(object):
def __init__(self, knot_formula=None, k_vector=None, q_vector=None):
# q_i = 2 * k_i + 1
if knot_formula is None:
knot_formula = config.knot_formula
if k_vector is None:
if q_vector is None:
# TBD docstring
print("Please give a list of k (k_vector) or q values (q_vector).")
return None
else:
k_vector = [(q - 1)/2 for q in q_vector]
# elif q_vector is None:
# q_vector = [2 * k + 1 for k in k_vector]
# self.knot_sum = eval(knot_formula)
self.knot_formula = knot_formula
self.k_vector = k_vector
self.q_vector = q_vector
k = k_vector
self.knot_description = get_knot_descrption(*self.knot_sum)
self.sigma_function = None
def is_sigma_for_vector_class_big(self, theta_vector):
return True
def __get_sigma_function(self):
print("settinf the function ")
k_1, k_2, k_3, k_4 = [abs(k) for k in self.k_vector]
q_4 = 2 * k_4 + 1
ksi = 1/q_4
sigma_q_1 = get_untwisted_signature_function(k_1)
sigma_q_2 = get_untwisted_signature_function(k_2)
sigma_q_3 = get_untwisted_signature_function(k_3)
def sigma_function(theta_vector):
# "untwisted" part (Levine-Tristram signatures)
a_1, a_2, a_3, a_4 = theta_vector
untwisted_part = 2 * (sigma_q_2(ksi * a_1) -
sigma_q_2(ksi * a_2) +
sigma_q_3(ksi * a_3) -
sigma_q_3(ksi * a_4) +
sigma_q_1(ksi * a_1 * 2) -
sigma_q_1(ksi * a_4 * 2))
# "twisted" part
tp = [0, 0, 0, 0]
for i, a in enumerate(theta_vector):
if a:
tp[i] = -q_4 + 2 * a - 2 * (a^2/q_4)
twisted_part = tp[0] - tp[1] + tp[2] - tp[3]
sigma_v = untwisted_part + twisted_part
return sigma_v
return sigma_function
def calculate_sigma(self, theta_vector):
if self.sigma_function is None:
self.sigma_function = self.__get_sigma_function()
return self.__calculate_sigma(theta_vector)
def __calculate_sigma(self, theta_vector):
return self.sigma_function(theta_vector)
# searching for sigma > 5 + #(v_i != 0)
def eval_cable_for_large_sigma(k_vector=None, knot_formula=None,
print_results=True, verbose=None,
q_vector=None):
cable = TorusCable(knot_formula=knot_formula, k_vector=k_vector,
q_vector=q_vector)
# k is a k_vector
k = cable.k_vector
knot_description = cable.knot_description
print("\n" * 5)
print(knot_description)
k_1, k_2, k_3, k_4 = [abs(i) for i in k]
q_4 = 2 * k_4 + 1
ksi = 1/q_4
if verbose:
print("\n\n")
print(100 * "*")
print("Searching for a large signature values for the cable sum: ")
print(knot_description)
large_sigma_for_all_v_combinations = True
bad_vectors = []
good_vectors = []
# iteration over all possible character combinations
# T(2, q_1; 2, q_2; 2, q_4) # -T(2, q_2; 2, q_4) #
# # T(2, q_3; 2, q_4) # -T(2, q_1; 2, q_3; 2, q_4)
last_theta = 1
large_sigma_for_last_theta_non_zero = True
for vector in it.product(range(q_4), range(q_4), range(q_4)):
v_theta = list(vector)
v_theta.append(last_theta)
a_1, a_2, a_3 = list(vector)
a_4 = last_theta
assert [a_1, a_2, a_3, a_4] == v_theta
if a_1 == a_2 == a_3:
if a_3 == 0:
print("\na_1 == a_2 == a_3 == 0")
continue
elif a_3 == a_4:
print("\nall a_i == a != 0")
continue
if (a_1^2 - a_2^2 + a_3^2 - a_4^2) % q_4:
continue
# print("\t\t\tMultiplication of the vector " + str(v_theta))
large_sigma_for_this_vector = False
for shift in range(1, q_4):
# print("shift = " + str(shift) + ", q_4 = " + str(q_4))
shifted_theta = [(shift * a) % q_4 for a in
[a_1, a_2, a_3, a_4]]
sigma_v = cable.calculate_sigma(shifted_theta)
if abs(sigma_v) > 5 + np.count_nonzero(shifted_theta):
large_sigma_for_this_vector = True
break
if large_sigma_for_this_vector:
good_vectors.append(v_theta)
pass
else:
bad_vectors.append(v_theta)
large_sigma_for_last_theta_non_zero = False
print("\ngood_vectors")
print(len(good_vectors))
print("\nbad_vectors")
print(len(bad_vectors))
print(bad_vectors)
bad_vectors = []
good_vectors = []
large_sigma_for_last_theta_zero = True
for vector in it.product(range(q_4), range(q_4)):
v_theta = list(vector)
v_theta.append(1)
v_theta.append(0)
a_1, a_2 = vector
a_3 = 1
a_4 = 0
assert [a_1, a_2, a_3, a_4] == v_theta
if (a_1^2 - a_2^2 + a_3^2 - a_4^2) % q_4:
continue
# print("\t\t\tMultiplication of the vector " + str(v_theta))
large_sigma_for_this_vector = False
for shift in range(1, q_4):
# print("shift = " + str(shift) + ", q_4 = " + str(q_4))
shifted_theta = [(shift * a) % q_4 for a in
[a_1, a_2, a_3, a_4]]
sigma_v = cable.calculate_sigma(shifted_theta)
if abs(sigma_v) > 5 + np.count_nonzero(shifted_theta):
large_sigma_for_this_vector = True
break
if large_sigma_for_this_vector:
good_vectors.append(v_theta)
pass
else:
bad_vectors.append(v_theta)
large_sigma_for_last_theta_zero = False
# break
print("\ngood_vectors")
print(len(good_vectors))
print("\nbad_vectors")
print(len(bad_vectors))
print(bad_vectors)
bad_vectors = []
good_vectors = []
print("\n\nNic nie ma")
for vector in range(q_4):
v_theta = [vector]
v_theta.append(1)
v_theta.append(0)
v_theta.append(last_theta)
a_1 = vector
a_2 = 1
a_3 = 0
a_4 = last_theta
assert [a_1, a_2, a_3, a_4] == v_theta
if a_1 == a_2 == a_3:
if a_3 == 0:
print("\na_1 == a_2 == a_3 == 0")
continue
elif a_3 == a_4:
print("\nall a_i == a != 0")
continue
if (a_1^2 - a_2^2 + a_3^2 - a_4^2) % q_4:
continue
# print("\t\t\tMultiplication of the vector " + str(v_theta))
large_sigma_for_this_vector = False
for shift in range(1, q_4):
# print("shift = " + str(shift) + ", q_4 = " + str(q_4))
shifted_theta = [(shift * a) % q_4 for a in
[a_1, a_2, a_3, a_4]]
sigma_v = cable.calculate_sigma(shifted_theta)
if abs(sigma_v) > 5 + np.count_nonzero(shifted_theta):
large_sigma_for_this_vector = True
break
if large_sigma_for_this_vector:
good_vectors.append(v_theta)
pass
else:
bad_vectors.append(v_theta)
large_sigma_for_last_theta_zero = False
# break
if large_sigma_for_last_theta_non_zero and large_sigma_for_last_theta_zero:
print(100 * "\n\nHURA HURA")
print(knot_description)
print("\ngood_vectors")
print(len(good_vectors))
print("\nbad_vectors")
print(len(bad_vectors))
print(bad_vectors)
return None
def main(arg): def main(arg):
if arg[1]: if arg[1]:
limit = int(arg[1]) limit = int(arg[1])
@ -234,7 +476,7 @@ def search_for_large_signature_value(knot_formula=None,
# iterate over q-vector # iterate over q-vector
for c in combinations: for c in combinations:
k = [(P.unrank(i) - 1)/2 for i in c] k = [(P.unrank(i + 2) - 1)/2 for i in c]
if config.only_slice_candidates: if config.only_slice_candidates:
if not (k[3] > 4 * k[2] and if not (k[3] > 4 * k[2] and
k[2] > 4 * k[1] and k[2] > 4 * k[1] and
@ -250,266 +492,6 @@ def search_for_large_signature_value(knot_formula=None,
# searching for sigma > 5 + #(v_i != 0)
def eval_cable_for_large_sigma(k_vector=None,
knot_formula=None,
print_results=True,
verbose=None,
q_vector=None):
if knot_formula is None:
knot_formula = config.knot_formula
if verbose is None:
verbose = config.verbose
if k_vector is None:
if q_vector is None:
# TBD docstring
print("Please give a list of k (k_vector) or q values (q_vector).")
return None
else:
k_vector = [(i - 1)/2 for i in q_vector]
k = k_vector
knot_sum = eval(knot_formula)
if len(knot_sum) != 4:
print("Wrong number of cable direct summands!")
return None
knot_description = get_knot_descrption(*knot_sum)
return _eval_cable_for_large_sigma(k_vector, knot_description,
print_results, verbose)
def _eval_cable_for_large_sigma(k, knot_description, print_results, verbose):
# k is a k_vector
print("\n" * 5)
print(knot_description)
k_1, k_2, k_3, k_4 = [abs(i) for i in k]
q_4 = 2 * k_4 + 1
ksi = 1/q_4
if verbose:
print("\n\n")
print(100 * "*")
print("Searching for a large signature values for the cable sum: ")
print(knot_description)
large_sigma_for_all_v_combinations = True
bad_vectors = []
good_vectors = []
# iteration over all possible character combinations
# T(2, q_1; 2, q_2; 2, q_4) # -T(2, q_2; 2, q_4) #
# # T(2, q_3; 2, q_4) # -T(2, q_1; 2, q_3; 2, q_4)
sigma_q_1 = get_untwisted_signature_function(k_1)
sigma_q_2 = get_untwisted_signature_function(k_2)
sigma_q_3 = get_untwisted_signature_function(k_3)
# large_sigma_for_last_theta_non_zero = True
#!!!!!!!!!!!!!!!!
# consider a_4 non-zero and zero
last_theta = 1
large_sigma_for_last_theta_non_zero = True
for vector in it.product(3 * [range(q_4)]):
v_theta = list(vector)
v_theta.append(last_theta)
a_1, a_2, a_3 = vector
a_4 = last_theta
assert [a_1, a_2, a_3, a_4] == v_theta
if a_1 == a_2 == a_3:
if a_3 == 0:
print("\na_1 == a_2 == a_3 == 0")
continue
elif a_3 == a_4:
print("\nall a_i == a != 0")
continue
if (a_1^2 - a_2^2 + a_3^2 - a_4^2) % q_4:
continue
# print("\t\t\tMultiplication of the vector " + str(v_theta))
large_sigma_for_this_vector = False
for shift in range(1, q_4):
# print("shift = " + str(shift) + ", q_4 = " + str(q_4))
shifted_theta = [(shift * a) % q_4 for a in
[a_1, a_2, a_3, a_4]]
# "untwisted" part (Levine-Tristram signatures)
a_1, a_2, a_3, a_4 = shifted_theta
untwisted_part = 2 * (sigma_q_2(ksi * a_1) -
sigma_q_2(ksi * a_2) +
sigma_q_3(ksi * a_3) -
sigma_q_3(ksi * a_4) +
sigma_q_1(ksi * a_1 * 2) -
sigma_q_1(ksi * a_4 * 2))
# "twisted" part
tp = [0, 0, 0, 0]
for i, a in enumerate(shifted_theta):
if a:
tp[i] = -q_4 + 2 * a - 2 * (a^2/q_4)
twisted_part = tp[0] - tp[1] + tp[2] - tp[3]
# assert twisted_part == int(twisted_part)
sigma_v = untwisted_part + twisted_part
# print(knot_description + "\t" + str(shifted_theta) +\
# "\t" + str(sigma_v))
# + "\t" + str(2 * sigma_q_1(2 * ksi * a_4)))
if abs(sigma_v) > 5 + np.count_nonzero(shifted_theta):
large_sigma_for_this_vector = True
if large_sigma_for_this_vector:
good_vectors.append(shifted_theta)
pass
else:
bad_vectors.append(shifted_theta)
large_sigma_for_last_theta_non_zero = False
last_theta = 0
large_sigma_for_last_theta_zero = True
for vector in it.product(3 * [range(q_4)]):
v_theta = list(vector)
v_theta.append(last_theta)
a_1, a_2, a_3 = vector
a_4 = last_theta
assert [a_1, a_2, a_3, a_4] == v_theta
if a_1 == a_2 == a_3:
if a_3 == 0:
print("\na_1 == a_2 == a_3 == 0")
continue
elif a_3 == a_4:
print("\nall a_i == a != 0")
continue
if (a_1^2 - a_2^2 + a_3^2 - a_4^2) % q_4:
continue
# print("\t\t\tMultiplication of the vector " + str(v_theta))
large_sigma_for_this_vector = False
for shift in range(1, q_4):
# print("shift = " + str(shift) + ", q_4 = " + str(q_4))
shifted_theta = [(shift * a) % q_4 for a in
[a_1, a_2, a_3, a_4]]
# "untwisted" part (Levine-Tristram signatures)
a_1, a_2, a_3, a_4 = shifted_theta
untwisted_part = 2 * (sigma_q_2(ksi * a_1) -
sigma_q_2(ksi * a_2) +
sigma_q_3(ksi * a_3) -
sigma_q_3(ksi * a_4) +
sigma_q_1(ksi * a_1 * 2) -
sigma_q_1(ksi * a_4 * 2))
# "twisted" part
tp = [0, 0, 0, 0]
for i, a in enumerate(shifted_theta):
if a:
tp[i] = -q_4 + 2 * a - 2 * (a^2/q_4)
twisted_part = tp[0] - tp[1] + tp[2] - tp[3]
# assert twisted_part == int(twisted_part)
sigma_v = untwisted_part + twisted_part
# print(knot_description + "\t" + str(shifted_theta) +\
# "\t" + str(sigma_v))
# + "\t" + str(2 * sigma_q_1(2 * ksi * a_4)))
if abs(sigma_v) > 5 + np.count_nonzero(shifted_theta):
large_sigma_for_this_vector = True
# break
# else:
# pass
# print(knot_description + "\t" + \
# str(shifted_theta) +\
# "\t" + str(sigma_v))
if large_sigma_for_this_vector:
good_vectors.append(shifted_theta)
pass
# print("large_sigma_for_this_vector\n\n\n\n")
# print("\n\nHURA HURA")
else:
# print(shifted_theta)
# if a_3 == a_4:
# print(sigma_q_1(ksi * a_4 * 2))
bad_vectors.append(shifted_theta)
large_sigma_for_last_theta_zero = False
# break
if large_sigma_for_last_theta_non_zero and large_sigma_for_last_theta_zero:
print(100 * "\n\nHURA HURA")
print(knot_description)
# # if config.print_calculations_for_large_sigma:
# # print("*" * 100)
# # print("\n\nLarge signature value\n")
# # print(knot_description)
# # print("\nv_theta: ", end="")
# # print(v_theta)
# # print("k values: ", end="")
# # print(str(k_1) + " " + str(k_2) + " " + \
# # str(k_3) + " " + str(k_4))
# # print(condition)
# # print("non zero value in v_theta: " + \
# # str(np.count_nonzero(v_theta)))
# # print("sigma_v: " + str(sigma_v))
# # print("\ntwisted_part: ", end="")
# # print(twisted_part)
# # print("untwisted_part: ", end="")
# # print(untwisted_part)
# # print("\n\nCALCULATIONS")
# # print("*" * 100)
# # sults_LT(v_theta, knot_description,
# # ksi, untwisted_part,
# # k, sigma_q_1, sigma_q_2, sigma_q_3)
# # sults_sigma(v_theta, knot_description, tp, q_4)
# # print("*" * 100 + "\n" * 5)
# # else:
# # print(knot_description + "\t" + str(v_theta) +\
# # "\t" + str(sigma_v) + "\t" + str(2 * sigma_q_1(2 * ksi * a_4)))
# # # if config.stop_after_firts_large_sigma:
# # # break
# # # sigma is small
# # else:
# # if config.print_calculations_for_small_sigma:
# # print("\n" * 5 + "*" * 100)
# # print("\nSmall signature value\n")
# # print(knot_description)
# # print_results_LT(v_theta, knot_description, ksi, untwisted_part,
# # k, sigma_q_1, sigma_q_2, sigma_q_3)
# # print_results_sigma(v_theta, knot_description, tp, q_4)
# # print("*" * 100 + "\n" * 5)
# # large_sigma_for_all_v_combinations = False
# #
# # if not config.print_calculations_for_small_sigma:
# # print(knot_description + "\t" + str(v_theta) +\
# # "\t" + str(sigma_v) + "\t" + str(2 * sigma_q_1(2 * ksi * a_4)))
# #
# #
# # # print("ojojojoj")
# # # break
#
# if large_sigma_for_all_v_combinations:
# print("\n\n\nHura hura")
# good_knots.append((knot_description, v_theta))
#
# # else:
# # print "\n\tSmall signature value"
# # print knot_description
# # print "v_theta: " + str(v_theta)
# # print condition
# # print "non zero value in v_theta: " + str(np.count_nonzero(v_theta))
# # print "signature at 1/2: " + str(y)
print("\ngood_vectors")
print(good_vectors)
print("\nbad_vectors")
print(bad_vectors)
return None
def print_results_LT(v_theta, knot_description, ksi, untwisted_part, def print_results_LT(v_theta, knot_description, ksi, untwisted_part,
k, sigma_q_1, sigma_q_2, sigma_q_3): k, sigma_q_1, sigma_q_2, sigma_q_3):
a_1, a_2, a_3, a_4 = v_theta a_1, a_2, a_3, a_4 = v_theta