Skip to content

Commit 867b681

Browse files
committed
fix naming
1 parent 1f8078b commit 867b681

File tree

4 files changed

+23
-28
lines changed

4 files changed

+23
-28
lines changed

graph.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@ def plot_combined_graph_from_tests(primality_tests):
2222
plt.show()
2323

2424

25-
def generate_spp_heatmap(c0_range, c1_range, k_rough):
26-
list_of_spp = [[smallest_lucas_type_pseudoprime(c0, c1, k_rough, 1000) for c0 in c0_range] for c1 in c1_range[::-1]]
27-
sns.heatmap(list_of_spp, cmap="YlGnBu", annot=True, fmt="d", xticklabels=c0_range, yticklabels=c1_range[::-1])
25+
def generate_spp_heatmap(c0_min, c0_max, c1_min, c1_max, k_rough, pp_max):
26+
list_of_spp = [[smallest_lucas_type_pseudoprime(c0, c1, k_rough, pp_max) for c0 in range(c0_min, c0_max)] for c1 in range(c1_min, c1_max)[::-1]]
27+
sns.heatmap(list_of_spp, cmap="YlGnBu", annot=True, fmt="d", xticklabels=range(c0_min, c0_max), yticklabels=range(c1_min, c1_max)[::-1])
2828
plt.title('Logs of Smallest 3-rough Pseudoprimes ', fontdict={'fontsize':13})
2929
plt.xlabel('Parameter c0')
3030
plt.ylabel('Parameter c1')
3131
plt.show()
32-
def generate_npp_heatmap(c0_range, c1_range, k_rough):
33-
list_of_spp = [[number_of_lucas_type_pseudoprime_up_to(c0, c1, k_rough, 1000) for c0 in c0_range] for c1 in c1_range[::-1]]
34-
sns.heatmap(list_of_spp, cmap="YlGnBu", annot=True, fmt="d", xticklabels=c0_range, yticklabels=c1_range[::-1])
32+
33+
def generate_npp_heatmap(c0_min, c0_max, c1_min, c1_max, k_rough, pp_max):
34+
list_of_spp = [[number_of_lucas_type_pseudoprime_up_to(c0, c1, k_rough, pp_max) for c0 in range(c0_min, c0_max)] for c1 in range(c1_min, c1_max)[::-1]]
35+
sns.heatmap(list_of_spp, cmap="YlGnBu", annot=True, fmt="d", xticklabels=range(c0_min, c0_max), yticklabels=range(c1_min, c1_max)[::-1])
3536
plt.title(f'Number of 3-rough Pseudoprimes up to 1000', fontdict={'fontsize': 13})
3637
plt.xlabel('Parameter c0')
3738
plt.ylabel('Parameter c1')

main.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,24 @@
99
]
1010
#plot_combined_graph_from_tests(compare_primality_tests)
1111

12-
c0_min = -60
13-
c0_max = 41
14-
c1_min = 0
15-
c1_max = 101
12+
c0_min = 2
13+
c0_max = 11
14+
c1_min = 2
15+
c1_max = 11
16+
k_rough = 1
17+
pp_max = 1000 # max pseudoprimes
1618

17-
#plot_heatmap_lucastype_nrpseudoprimes(c0_min, c0_max, c1_min, c1_max, 1, 1000)
19+
generate_spp_heatmap(c0_min, c0_max, c1_min, c1_max, k_rough, pp_max)
20+
generate_npp_heatmap(c0_min, c0_max, c1_min, c1_max, k_rough, pp_max)
1821

19-
n_values = list(range(1, 50))
2022
# Fermat case
23+
n_values = list(range(1, 50))
2124
c0_values = [-n**2 for n in n_values]
2225
c1_values = [2 * n for n in n_values]
2326

2427
plt.plot(c0_values, c1_values, marker='o', linestyle='-', color='red', label='Fermat Case')
2528

26-
#plot_spp_largerscale(c0_min, c0_max, c1_min, c1_max, 1, 1000)
29+
plot_spp_largerscale(c0_min, c0_max, c1_min, c1_max, 1, 1000)
2730

2831

2932
#analyze_primality_test(lambda n: lucas_type_primality_test(n, 1, 2), "Lucas-Type Primality Test",1)

primality_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ def lucas_type_primality_test(n, c0, c1):
2727
b = c
2828
return (b-c1) % n == 0
2929

30-
def fermat_primality_test(n, c):#fermat's little theorem
30+
def fermat_primality_test(n, c):# fermat's little theorem
3131
return pow(c, n - 1, n) == 1
3232

33-
def smallest_lucas_type_pseudoprime(c0, c1, k, pp_max):
33+
def smallest_lucas_type_pseudoprime(c0, c1, k_rough, pp_max):
3434
for n in range(2, pp_max+1):
35-
if not is_prime(n) and lucas_type_primality_test(n, c0, c1) and is_k_rough(n,k):
35+
if not is_prime(n) and lucas_type_primality_test(n, c0, c1) and is_k_rough(n,k_rough):
3636
return n
37-
return max
37+
return pp_max
3838

3939
def log_of_smallest_lucas_type_pseudoprime_k_rough(c0, c1, k_rough, pp_max):
4040
for n in range(2, pp_max+1):

util.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
1-
default_limit = 1000
2-
31
# A k rough number is a positive integer whose prime factors are all greater than or equal to k.
4-
def is_k_rough(n,k):
5-
for i in range(2, k+1):
2+
def is_k_rough(n,k_rough):
3+
for i in range(2, k_rough+1):
64
if n % i == 0:
75
return False
86
return True
97

108
def is_k_pseudoprime(n,k):
119
return is_k_rough(n, k) and not is_prime(n)
1210

13-
def primality_test_with_rough_pseudoprimes(primality_test, k):
14-
results = []
15-
for n in range(2, default_limit + 1):
16-
if primality_test(n) and is_k_pseudoprime(n, k):
17-
results.append(n)
18-
return results
19-
2011
def is_prime(n): # trial division
2112
if n < 2 or n % 2 == 0:
2213
return n == 2

0 commit comments

Comments
 (0)