finding big signature, based on old code
This commit is contained in:
parent
0337fedda0
commit
a02abef0ff
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
# TBD: read about Factory Method, variable in docstring, sage documentation
|
# TBD: read about Factory Method, variable in docstring, sage documentation
|
||||||
|
# move settings to sep file
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This script calculates signature functions for knots (cable sums).
|
This script calculates signature functions for knots (cable sums).
|
||||||
@ -76,9 +77,10 @@ class MySettings(object):
|
|||||||
# [-k[0], -k[3], -k[4]], [-k[1], -k[2]]]"
|
# [-k[0], -k[3], -k[4]], [-k[1], -k[2]]]"
|
||||||
# self.knot_formula = "[[k[0], k[1], k[2]], [k[3]],\
|
# self.knot_formula = "[[k[0], k[1], k[2]], [k[3]],\
|
||||||
# [-k[0], -k[1], -k[3]], [-k[2]]]"
|
# [-k[0], -k[1], -k[3]], [-k[2]]]"
|
||||||
self.default_limit = 3
|
self.limit = 3
|
||||||
|
|
||||||
self.verbose = True
|
# self.verbose = True
|
||||||
|
self.verbose = False
|
||||||
|
|
||||||
|
|
||||||
class SignatureFunction(object):
|
class SignatureFunction(object):
|
||||||
@ -187,10 +189,12 @@ def main(arg):
|
|||||||
# search_for_null_signature_value(limit=new_limit)
|
# search_for_null_signature_value(limit=new_limit)
|
||||||
|
|
||||||
|
|
||||||
|
# searching for signture > 5 + #(v_i != 0)
|
||||||
def search_for_large_signature_value(knot_formula=None,
|
def search_for_large_signature_value(knot_formula=None,
|
||||||
limit=None, verbose=None):
|
limit=None,
|
||||||
|
verbose=None):
|
||||||
if limit is None:
|
if limit is None:
|
||||||
limit = config.default_limit
|
limit = config.limit
|
||||||
if knot_formula is None:
|
if knot_formula is None:
|
||||||
knot_formula = config.knot_formula
|
knot_formula = config.knot_formula
|
||||||
if verbose is None:
|
if verbose is None:
|
||||||
@ -198,71 +202,59 @@ def search_for_large_signature_value(knot_formula=None,
|
|||||||
|
|
||||||
k_vector_size = extract_max(knot_formula) + 1
|
k_vector_size = extract_max(knot_formula) + 1
|
||||||
limit = max(limit, k_vector_size)
|
limit = max(limit, k_vector_size)
|
||||||
print limit
|
|
||||||
combinations = it.combinations(range(1, limit + 1), k_vector_size)
|
combinations = it.combinations(range(1, limit + 1), k_vector_size)
|
||||||
for k in combinations:
|
P = Primes()
|
||||||
print
|
|
||||||
print k
|
|
||||||
# P = Primes()
|
|
||||||
# sage: P.unrank(0)
|
|
||||||
# 2
|
|
||||||
# sage: P.unrank(5)
|
|
||||||
# 13
|
|
||||||
# sage: P.unrank(42)
|
|
||||||
return None
|
|
||||||
with open(config.f_results, 'w') as f_results:
|
|
||||||
for k in combinations:
|
|
||||||
if verbose:
|
|
||||||
print
|
|
||||||
print k
|
|
||||||
# TBD: maybe the following condition or the function
|
|
||||||
# get_shifted_combination should be redefined to a dynamic version
|
|
||||||
if config.only_slice_candidates and k_vector_size == 5:
|
|
||||||
k = get_shifted_combination(k)
|
|
||||||
# print k
|
|
||||||
knot_sum = eval(knot_formula)
|
|
||||||
print "knot_sum"
|
|
||||||
print knot_sum
|
|
||||||
|
|
||||||
if is_trivial_combination(knot_sum):
|
with open(config.f_results, 'w') as f_results:
|
||||||
if verbose:
|
for c in combinations:
|
||||||
print "\nTrivial combination" + str(knot_sum)
|
k = [(P.unrank(i) - 1)/2 for i in c]
|
||||||
continue
|
knot_sum = eval(knot_formula)
|
||||||
result = eval_cable_for_large_signature(knot_sum,
|
result = eval_cable_for_large_signature(knot_sum,
|
||||||
print_results=False)
|
print_results=False)
|
||||||
if result is not None:
|
# if result is not None:
|
||||||
knot_description, null_comb, all_comb = result
|
# knot_description, large_comb, all_comb = result
|
||||||
line = (str(k) + ", " + str(null_comb) + ", " +
|
# line = (str(k) + ", " + str(all_comb) + ", " +
|
||||||
str(all_comb) + "\n")
|
# str(all_comb) + "\n")
|
||||||
f_results.write(line)
|
# f_results.write(line)
|
||||||
|
|
||||||
def eval_cable_for_large_signature(knot_sum, print_results=True, verbose=None):
|
# searching for signture > 5 + #(v_i != 0)
|
||||||
|
def eval_cable_for_large_signature(knot_sum,
|
||||||
|
print_results=True,
|
||||||
|
verbose=None):
|
||||||
if verbose is None:
|
if verbose is None:
|
||||||
verbose = config.verbose
|
verbose = config.verbose
|
||||||
if verbose:
|
|
||||||
print "\neval_cable_for_large_signature"
|
|
||||||
if len(knot_sum) != 4:
|
if len(knot_sum) != 4:
|
||||||
print "Wrong number of cable direct summands!"
|
print "Wrong number of cable direct summands!"
|
||||||
return None
|
return None
|
||||||
q = 2 * abs(knot_sum[-1][-1]) + 1
|
q = 2 * abs(knot_sum[-1][-1]) + 1
|
||||||
print "q is " + str(q)
|
|
||||||
|
|
||||||
f = get_function_of_theta_for_sum(*knot_sum, verbose=False)
|
f = get_function_of_theta_for_sum(*knot_sum, verbose=False)
|
||||||
knot_description = get_knot_descrption(*knot_sum)
|
knot_description = get_knot_descrption(*knot_sum)
|
||||||
all_combinations = get_number_of_combinations(*knot_sum)
|
|
||||||
|
|
||||||
null_combinations = 0
|
# large_value_combinations = 0
|
||||||
zero_theta_combinations = []
|
# good_thetas_list = []
|
||||||
|
|
||||||
ranges_list = [range(abs(knot[-1]) + 1) for knot in knot_sum]
|
ranges_list = [range(abs(knot[-1]) + 1) for knot in knot_sum]
|
||||||
if verbose:
|
# if verbose:
|
||||||
print "eval_cable_for_large_signature - knot_description: "
|
# print "eval_cable_for_large_signature - knot_description: "
|
||||||
print knot_description
|
# print knot_description
|
||||||
|
|
||||||
for v_theta in it.product(*ranges_list):
|
for v_theta in it.product(*ranges_list):
|
||||||
|
if (v_theta[0]^2 - v_theta[1]^2 + v_theta[2]^2 - v_theta[3]^2) % q:
|
||||||
|
continue
|
||||||
y = f(*v_theta).value(1/2)
|
y = f(*v_theta).value(1/2)
|
||||||
print y
|
|
||||||
if abs(y) > 5 + np.count_nonzero(v_theta):
|
if abs(y) > 5 + np.count_nonzero(v_theta):
|
||||||
print "hura hura"
|
print "\nLarge signature value"
|
||||||
|
print knot_description
|
||||||
|
print "v_theta: " + str(v_theta)
|
||||||
|
condition = (str(v_theta[0]^2) + " - " + str(v_theta[1]^2) + " + " +
|
||||||
|
str(v_theta[2]^2) + " - " + str(v_theta[3]^2))
|
||||||
|
print condition
|
||||||
|
print "non zero value in v_theta: " + str(np.count_nonzero(v_theta))
|
||||||
|
print "signature at 1/2: " + str(y)
|
||||||
|
|
||||||
|
|
||||||
# == 0:
|
# == 0:
|
||||||
# zero_theta_combinations.append(v_theta)
|
# zero_theta_combinations.append(v_theta)
|
||||||
# m = len([theta for theta in v_theta if theta != 0])
|
# m = len([theta for theta in v_theta if theta != 0])
|
||||||
@ -270,23 +262,24 @@ def eval_cable_for_large_signature(knot_sum, print_results=True, verbose=None):
|
|||||||
# else:
|
# else:
|
||||||
# assert sum(v_theta) != 0
|
# assert sum(v_theta) != 0
|
||||||
|
|
||||||
if print_results:
|
# if print_results:
|
||||||
print
|
# print
|
||||||
print knot_description
|
# print knot_description
|
||||||
print "Zero cases: " + str(null_combinations)
|
# print "Zero cases: " + str(null_combinations)
|
||||||
print "All cases: " + str(all_combinations)
|
# print "All cases: " + str(all_combinations)
|
||||||
if zero_theta_combinations:
|
# if zero_theta_combinations:
|
||||||
print "Zero theta combinations: "
|
# print "Zero theta combinations: "
|
||||||
for el in zero_theta_combinations:
|
# for el in zero_theta_combinations:
|
||||||
print el
|
# print el
|
||||||
if null_combinations^2 >= all_combinations:
|
# if null_combinations^2 >= all_combinations:
|
||||||
return knot_description, null_combinations, all_combinations
|
# return knot_description, null_combinations, all_combinations
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
# searching for signature == 0
|
||||||
def search_for_null_signature_value(knot_formula=None, limit=None):
|
def search_for_null_signature_value(knot_formula=None, limit=None):
|
||||||
if limit is None:
|
if limit is None:
|
||||||
limit = config.default_limit
|
limit = config.limit
|
||||||
if knot_formula is None:
|
if knot_formula is None:
|
||||||
knot_formula = config.knot_formula
|
knot_formula = config.knot_formula
|
||||||
|
|
||||||
@ -307,42 +300,34 @@ def search_for_null_signature_value(knot_formula=None, limit=None):
|
|||||||
|
|
||||||
if is_trivial_combination(knot_sum):
|
if is_trivial_combination(knot_sum):
|
||||||
continue
|
continue
|
||||||
result = search_for_thetas(knot_sum, print_results=False)
|
result = search_for_large_thetas(knot_sum, print_results=False)
|
||||||
if result is not None:
|
if result is not None:
|
||||||
knot_description, null_comb, all_comb = result
|
knot_description, null_comb, all_comb = result
|
||||||
line = (str(k) + ", " + str(null_comb) + ", " +
|
line = (str(k) + ", " + str(null_comb) + ", " +
|
||||||
str(all_comb) + "\n")
|
str(all_comb) + "\n")
|
||||||
f_results.write(line)
|
f_results.write(line)
|
||||||
|
|
||||||
def search_for_thetas(knot_sum, print_results=False, verbose=None):
|
# searching for signature == 0
|
||||||
|
def eval_cable_for_null_signature(knot_sum, print_results=True, verbose=None):
|
||||||
|
# search for zero combinations
|
||||||
if verbose is None:
|
if verbose is None:
|
||||||
vebose = confi.verbose
|
vebose = confi.verbose
|
||||||
if verbose:
|
f = get_function_of_theta_for_sum(*knot_sum, verbose=False)
|
||||||
print "search_for_thetas"
|
|
||||||
f = get_function_of_theta_for_sum(*knot_sum)
|
|
||||||
knot_description = get_knot_descrption(*knot_sum)
|
knot_description = get_knot_descrption(*knot_sum)
|
||||||
all_combinations = get_number_of_combinations(*knot_sum)
|
all_combinations = get_number_of_combinations(*knot_sum)
|
||||||
|
|
||||||
large_value_combinations = 0
|
null_combinations = 0
|
||||||
good_theta_list = []
|
zero_theta_combinations = []
|
||||||
|
|
||||||
ranges_list = [range(abs(knot[-1]) + 1) for knot in knot_sum]
|
ranges_list = [range(abs(knot[-1]) + 1) for knot in knot_sum]
|
||||||
if verbose:
|
if verbose:
|
||||||
print "knot_description:"
|
print
|
||||||
print knot_description
|
print knot_description
|
||||||
for v_theta in it.product(*ranges_list):
|
for v_theta in it.product(*ranges_list):
|
||||||
if (v_theta[0]^2 - v_theta[1]^2 + v_theta[2]^2 - v_theta[3]^2) % q:
|
if f(*v_theta, verbose=False).sum_of_absolute_values() == 0:
|
||||||
print "ojojoj"
|
zero_theta_combinations.append(v_theta)
|
||||||
print (v_theta[0]^2 - v_theta[1]^2 + v_theta[2]^2 - v_theta[3]^2) % q
|
|
||||||
continue
|
|
||||||
print f(*v_theta).value(-1)
|
|
||||||
if f(*v_theta).value(-1):
|
|
||||||
print "Hip hip hura"
|
|
||||||
good_theta_list.append(v_theta)
|
|
||||||
m = len([theta for theta in v_theta if theta != 0])
|
m = len([theta for theta in v_theta if theta != 0])
|
||||||
large_value_combinations += 2^m
|
null_combinations += 2^m
|
||||||
else:
|
|
||||||
print "smuteczek"
|
|
||||||
# else:
|
# else:
|
||||||
# assert sum(v_theta) != 0
|
# assert sum(v_theta) != 0
|
||||||
|
|
||||||
@ -492,43 +477,6 @@ def get_function_of_theta_for_sum(*arg, **key_args):
|
|||||||
return signature_function_for_sum
|
return signature_function_for_sum
|
||||||
|
|
||||||
|
|
||||||
def eval_cable_for_null_signature(knot_sum, print_results=True, verbose=None):
|
|
||||||
# search for zero combinations
|
|
||||||
if verbose is None:
|
|
||||||
vebose = confi.verbose
|
|
||||||
f = get_function_of_theta_for_sum(*knot_sum, verbose=False)
|
|
||||||
knot_description = get_knot_descrption(*knot_sum)
|
|
||||||
all_combinations = get_number_of_combinations(*knot_sum)
|
|
||||||
|
|
||||||
null_combinations = 0
|
|
||||||
zero_theta_combinations = []
|
|
||||||
|
|
||||||
ranges_list = [range(abs(knot[-1]) + 1) for knot in knot_sum]
|
|
||||||
if verbose:
|
|
||||||
print
|
|
||||||
print knot_description
|
|
||||||
for v_theta in it.product(*ranges_list):
|
|
||||||
if f(*v_theta, verbose=False).sum_of_absolute_values() == 0:
|
|
||||||
zero_theta_combinations.append(v_theta)
|
|
||||||
m = len([theta for theta in v_theta if theta != 0])
|
|
||||||
null_combinations += 2^m
|
|
||||||
# else:
|
|
||||||
# assert sum(v_theta) != 0
|
|
||||||
|
|
||||||
if print_results:
|
|
||||||
print
|
|
||||||
print knot_description
|
|
||||||
print "Zero cases: " + str(null_combinations)
|
|
||||||
print "All cases: " + str(all_combinations)
|
|
||||||
if zero_theta_combinations:
|
|
||||||
print "Zero theta combinations: "
|
|
||||||
for el in zero_theta_combinations:
|
|
||||||
print el
|
|
||||||
if null_combinations^2 >= all_combinations:
|
|
||||||
return knot_description, null_combinations, all_combinations
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def get_number_of_combinations(*arg):
|
def get_number_of_combinations(*arg):
|
||||||
number_of_combinations = 1
|
number_of_combinations = 1
|
||||||
for knot in arg:
|
for knot in arg:
|
||||||
@ -756,7 +704,6 @@ main.__doc__ = \
|
|||||||
Optionaly a parameter (a limit for k_0 value) can be given.
|
Optionaly a parameter (a limit for k_0 value) can be given.
|
||||||
Thought to be run for time consuming calculations.
|
Thought to be run for time consuming calculations.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
config = MySettings()
|
config = MySettings()
|
||||||
if __name__ == '__main__' and '__file__' in globals():
|
if __name__ == '__main__' and '__file__' in globals():
|
||||||
# not called in interactive mode as __file__ is not defined
|
# not called in interactive mode as __file__ is not defined
|
||||||
|
Loading…
Reference in New Issue
Block a user