def compare_speed(f1, f2, x_len, y_len, path='../input_files/equations_short_9.txt'): groups, leaf_number = parser(path) # groups, leaf_number = parser('input_files/equations_short_9.txt') size = len(groups) cnt = 0 for i in range(size): s1 = time() xy_series = f1(groups[i][1:], (x_len + 1) // 2) time_1 = time() - s1 # print(res_1) s2 = time() xy_series = f2(groups[i][1:], (x_len + 1) // 2, y_len) time_2 = time() - s2 if time_1 <= time_2: print(i) cnt += 1 print(cnt, size) print(size / cnt)
f = add_local(x, a) cut_f = f[(-2 * n):] return cut_f if __name__ == '__main__': from source.poly_func.my_poly_functions import show_local from source.parsers import parser import time from source.get_series import beautiful_time import os parallel_setup.init() start = time.time() groups, leaf_number = parser('../input_files/equations_short_8.txt') # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> x_len = 75 # длина ряда!!! test_mode = True # тестовый режим активирован? start_folg = 0 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if test_mode: try: os.mkdir('../rubbish_files/output_' + leaf_number + '_' + str(x_len)) except: pass # os.mkdir('../rubbish_files/log_' + leaf_number + '_' + str(x_len)) loges_file = open( '../rubbish_files/log_short_' + leaf_number + '_' + str(x_len) + '.txt',
hours = all_time // 3600 all_time %= 3600 minutes = all_time // 60 seconds = round(all_time % 60, 3) return str(hours) + ' часов, ' + str(minutes) + ' минут, ' + str( seconds) + ' секунд.' if __name__ == '__main__': from source.poly_func.my_poly_functions import show_global import time parallel_setup.init() start = time.time() groups, leaf_number = parser('input_files/equations_short_10.txt') # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> x_len = 151 # длина ряда!!! y_len = 2 test_mode = False # тестовый режим активирован? # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if test_mode: file = open( 'rubbish_files/short_nice_series_' + leaf_number + '_' + str(x_len) + '_' + str(y_len) + '.txt', 'w') loges_file = open( 'rubbish_files/log_short_' + leaf_number + '_' + str(x_len) + '_' + str(y_len) + '.txt', 'w') else:
from source.parsers import parser from source import parallel_setup from source.get_series import equations2series_y, equations2series, combo_equations_to_series from source.sequence_evaluation import compute_sequence from source.poly_func.my_poly_functions import show_global, show_local import time parallel_setup.init() start = time.time() groups, leaf_number = parser('../input_files/long_data/equations_4.txt') correct_answers = [ [ '(853467)*x^33 + (310572)*x^31 + (113634)*x^29 + (41835)*x^27 + (15511)*x^25 + (5798)*x^23 + (2188)*x^21 + (835)*x^19 + (323)*x^17 + (127)*x^15 + (51)*x^13 + (21)*x^11 + (9)*x^9 + (4)*x^7 + (2)*x^5 + (1)*x^3 + (1)*x^1 ', '(y^14 + 16*y^13 + 224*y^12 + 2000*y^11 + 13700*y^10 + 71568*y^9 + 293188*y^8 + 946192*y^7 + 2407990*y^6 + 4794608*y^5 + 7344116*y^4 + 8392176*y^3 + 6772584*y^2 + 3465840*y^1 + 853467)*x^33 + (y^13 + 15*y^12 + 195*y^11 + 1610*y^10 + 10115*y^9 + 48048*y^8 + 176995*y^7 + 506480*y^6 + 1121913*y^5 + 1895465*y^4 + 2373371*y^3 + 2088450*y^2 + 1161615*y^1 + 310572)*x^31 + (y^12 + 14*y^11 + 168*y^10 + 1274*y^9 + 7280*y^8 + 31122*y^7 + 101738*y^6 + 253682*y^5 + 477477*y^4 + 660660*y^3 + 638638*y^2 + 388752*y^1 + 113634)*x^29 + (y^11 + 13*y^10 + 143*y^9 + 988*y^8 + 5083*y^7 + 19305*y^6 + 55055*y^5 + 116831*y^4 + 180466*y^3 + 193336*y^2 + 129844*y^1 + 41835)*x^27 + (y^10 + 12*y^9 + 120*y^8 + 748*y^7 + 3421*y^6 + 11352*y^5 + 27599*y^4 + 48180*y^3 + 57816*y^2 + 43252*y^1 + 15511)*x^25 + (y^9 + 11*y^8 + 99*y^7 + 550*y^6 + 2200*y^5 + 6237*y^4 + 12507*y^3 + 17028*y^2 + 14355*y^1 + 5798)*x^23 + (y^8 + 10*y^7 + 80*y^6 + 390*y^5 + 1335*y^4 + 3132*y^3 + 4920*y^2 + 4740*y^1 + 2188)*x^21 + (y^7 + 9*y^6 + 63*y^5 + 264*y^4 + 750*y^3 + 1386*y^2 + 1554*y^1 + 835)*x^19 + (y^6 + 8*y^5 + 48*y^4 + 168*y^3 + 378*y^2 + 504*y^1 + 323)*x^17 + (y^5 + 7*y^4 + 35*y^3 + 98*y^2 + 161*y^1 + 127)*x^15 + (y^4 + 6*y^3 + 24*y^2 + 50*y^1 + 51)*x^13 + (y^3 + 5*y^2 + 15*y^1 + 21)*x^11 + (y^2 + 4*y^1 + 9)*x^9 + (y^1 + 4)*x^7 + (2)*x^5 + (1)*x^3 + (1)*x^1 ' ], [ '(32768)*x^33 + (16384)*x^31 + (8192)*x^29 + (4096)*x^27 + (2048)*x^25 + (1024)*x^23 + (512)*x^21 + (256)*x^19 + (128)*x^17 + (64)*x^15 + (32)*x^13 + (16)*x^11 + (8)*x^9 + (4)*x^7 + (2)*x^5 + (1)*x^3 + (1)*x^1 ', '(12870*y^7 + 480480*y^6 + 4036032*y^5 + 11531520*y^4 + 12812800*y^3 + 5591040*y^2 + 860160*y^1 + 32768)*x^33 + (429*y^7 + 48048*y^6 + 672672*y^5 + 2690688*y^4 + 3843840*y^3 + 2050048*y^2 + 372736*y^1 + 16384)*x^31 + (3432*y^6 + 96096*y^5 + 576576*y^4 + 1098240*y^3 + 732160*y^2 + 159744*y^1 + 8192)*x^29 + (132*y^6 + 11088*y^5 + 110880*y^4 + 295680*y^3 + 253440*y^2 + 67584*y^1 + 4096)*x^27 + (924*y^5 + 18480*y^4 + 73920*y^3 + 84480*y^2 + 28160*y^1 + 2048)*x^25 + (42*y^5 + 2520*y^4 + 16800*y^3 + 26880*y^2 + 11520*y^1 + 1024)*x^23 + (252*y^4 + 3360*y^3 + 8064*y^2 + 4608*y^1 + 512)*x^21 + (14*y^4 + 560*y^3 + 2240*y^2 + 1792*y^1 + 256)*x^19 + (70*y^3 + 560*y^2 + 672*y^1 + 128)*x^17 + (5*y^3 + 120*y^2 + 240*y^1 + 64)*x^15 + (20*y^2 + 80*y^1 + 32)*x^13 + (2*y^2 + 24*y^1 + 16)*x^11 + (6*y^1 + 8)*x^9 + (y^1 + 4)*x^7 + (2)*x^5 + (1)*x^3 + (1)*x^1 ' ], [ '(32768)*x^33 + (16384)*x^31 + (8192)*x^29 + (4096)*x^27 + (2048)*x^25 + (1024)*x^23 + (512)*x^21 + (256)*x^19 + (128)*x^17 + (64)*x^15 + (32)*x^13 + (16)*x^11 + (8)*x^9 + (4)*x^7 + (2)*x^5 + (1)*x^3 + (1)*x^1 ', '(12870*y^7 + 480480*y^6 + 4036032*y^5 + 11531520*y^4 + 12812800*y^3 + 5591040*y^2 + 860160*y^1 + 32768)*x^33 + (429*y^7 + 48048*y^6 + 672672*y^5 + 2690688*y^4 + 3843840*y^3 + 2050048*y^2 + 372736*y^1 + 16384)*x^31 + (3432*y^6 + 96096*y^5 + 576576*y^4 + 1098240*y^3 + 732160*y^2 + 159744*y^1 + 8192)*x^29 + (132*y^6 + 11088*y^5 + 110880*y^4 + 295680*y^3 + 253440*y^2 + 67584*y^1 + 4096)*x^27 + (924*y^5 + 18480*y^4 + 73920*y^3 + 84480*y^2 + 28160*y^1 + 2048)*x^25 + (42*y^5 + 2520*y^4 + 16800*y^3 + 26880*y^2 + 11520*y^1 + 1024)*x^23 + (252*y^4 + 3360*y^3 + 8064*y^2 + 4608*y^1 + 512)*x^21 + (14*y^4 + 560*y^3 + 2240*y^2 + 1792*y^1 + 256)*x^19 + (70*y^3 + 560*y^2 + 672*y^1 + 128)*x^17 + (5*y^3 + 120*y^2 + 240*y^1 + 64)*x^15 + (20*y^2 + 80*y^1 + 32)*x^13 + (2*y^2 + 24*y^1 + 16)*x^11 + (6*y^1 + 8)*x^9 + (y^1 + 4)*x^7 + (2)*x^5 + (1)*x^3 + (1)*x^1 ' ], [ '(32768)*x^33 + (16384)*x^31 + (8192)*x^29 + (4096)*x^27 + (2048)*x^25 + (1024)*x^23 + (512)*x^21 + (256)*x^19 + (128)*x^17 + (64)*x^15 + (32)*x^13 + (16)*x^11 + (8)*x^9 + (4)*x^7 + (2)*x^5 + (1)*x^3 + (1)*x^1 ', '(12870*y^7 + 480480*y^6 + 4036032*y^5 + 11531520*y^4 + 12812800*y^3 + 5591040*y^2 + 860160*y^1 + 32768)*x^33 + (429*y^7 + 48048*y^6 + 672672*y^5 + 2690688*y^4 + 3843840*y^3 + 2050048*y^2 + 372736*y^1 + 16384)*x^31 + (3432*y^6 + 96096*y^5 + 576576*y^4 + 1098240*y^3 + 732160*y^2 + 159744*y^1 + 8192)*x^29 + (132*y^6 + 11088*y^5 + 110880*y^4 + 295680*y^3 + 253440*y^2 + 67584*y^1 + 4096)*x^27 + (924*y^5 + 18480*y^4 + 73920*y^3 + 84480*y^2 + 28160*y^1 + 2048)*x^25 + (42*y^5 + 2520*y^4 + 16800*y^3 + 26880*y^2 + 11520*y^1 + 1024)*x^23 + (252*y^4 + 3360*y^3 + 8064*y^2 + 4608*y^1 + 512)*x^21 + (14*y^4 + 560*y^3 + 2240*y^2 + 1792*y^1 + 256)*x^19 + (70*y^3 + 560*y^2 + 672*y^1 + 128)*x^17 + (5*y^3 + 120*y^2 + 240*y^1 + 64)*x^15 + (20*y^2 + 80*y^1 + 32)*x^13 + (2*y^2 + 24*y^1 + 16)*x^11 + (6*y^1 + 8)*x^9 + (y^1 + 4)*x^7 + (2)*x^5 + (1)*x^3 + (1)*x^1 ' ], [