Skip to content

Commit 1a7ab4f

Browse files
committed
Use only small modulus
1 parent 10d2838 commit 1a7ab4f

File tree

1 file changed

+76
-75
lines changed

1 file changed

+76
-75
lines changed

src/flint/test/test_all.py

Lines changed: 76 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,7 @@ def test_fmpz_mod():
18361836
assert fmpz(test_y) / F_test(test_x) == (test_y * pow(test_x, -1, test_mod)) % test_mod
18371837
assert test_y / F_test(test_x) == (test_y * pow(test_x, -1, test_mod)) % test_mod
18381838

1839-
def _test_fmpz_mod_dlog():
1839+
def test_fmpz_mod_dlog():
18401840
from flint import fmpz, fmpz_mod_ctx
18411841

18421842
# Input modulus must be prime
@@ -1868,6 +1868,7 @@ def _test_fmpz_mod_dlog():
18681868
# Randomised testing with smooth large modulus
18691869
e2, e3 = 92, 79
18701870
p = 2**e2 * 3**e3 + 1
1871+
p = 167
18711872
F = fmpz_mod_ctx(p)
18721873

18731874
for _ in range(10):
@@ -1878,7 +1879,7 @@ def _test_fmpz_mod_dlog():
18781879
x = g.discrete_log(a)
18791880
assert g**x == a
18801881

1881-
def _test_fmpz_mod_poly():
1882+
def test_fmpz_mod_poly():
18821883
from flint import fmpz_poly, fmpz_mod_poly, fmpz_mod_poly_ctx, fmpz_mod_ctx, fmpz
18831884

18841885
# fmpz_mod_poly_ctx tests
@@ -2014,8 +2015,8 @@ def _test_fmpz_mod_poly():
20142015

20152016
# Arithmetic
20162017
p_sml = 163
2017-
p_med = 2**127 - 1
2018-
p_big = 2**255 - 19
2018+
p_med = 167
2019+
p_big = 173
20192020

20202021
F_sml = fmpz_mod_ctx(p_sml)
20212022
F_med = fmpz_mod_ctx(p_med)
@@ -2295,7 +2296,7 @@ def _test_fmpz_mod_poly():
22952296
assert raises(lambda: f.pow_trunc(-1, 5), ValueError)
22962297

22972298

2298-
def _test_fmpz_mod_mat():
2299+
def test_fmpz_mod_mat():
22992300
c11 = flint.fmpz_mod_ctx(11)
23002301
c13 = flint.fmpz_mod_ctx(13)
23012302

@@ -2511,12 +2512,12 @@ def _all_polys():
25112512
(lambda *a: flint.fmpz_mod_poly(*a, flint.fmpz_mod_poly_ctx(163)),
25122513
lambda x: flint.fmpz_mod(x, flint.fmpz_mod_ctx(163)),
25132514
True, flint.fmpz(163)),
2514-
(lambda *a: flint.fmpz_mod_poly(*a, flint.fmpz_mod_poly_ctx(2**127 - 1)),
2515-
lambda x: flint.fmpz_mod(x, flint.fmpz_mod_ctx(2**127 - 1)),
2516-
True, flint.fmpz(2**127 - 1)),
2517-
(lambda *a: flint.fmpz_mod_poly(*a, flint.fmpz_mod_poly_ctx(2**255 - 19)),
2518-
lambda x: flint.fmpz_mod(x, flint.fmpz_mod_ctx(2**255 - 19)),
2519-
True, flint.fmpz(2**255 - 19)),
2515+
#(lambda *a: flint.fmpz_mod_poly(*a, flint.fmpz_mod_poly_ctx(2**127 - 1)),
2516+
# lambda x: flint.fmpz_mod(x, flint.fmpz_mod_ctx(2**127 - 1)),
2517+
# True, flint.fmpz(2**127 - 1)),
2518+
#(lambda *a: flint.fmpz_mod_poly(*a, flint.fmpz_mod_poly_ctx(2**255 - 19)),
2519+
# lambda x: flint.fmpz_mod(x, flint.fmpz_mod_ctx(2**255 - 19)),
2520+
# True, flint.fmpz(2**255 - 19)),
25202521

25212522
# GF(p^k) (p prime)
25222523
(lambda *a: flint.fq_default_poly(*a, flint.fq_default_poly_ctx(2**127 - 1)),
@@ -2543,16 +2544,16 @@ def _all_polys():
25432544
(lambda *a: flint.fmpz_mod_poly(*a, flint.fmpz_mod_poly_ctx(164)),
25442545
lambda x: flint.fmpz_mod(x, flint.fmpz_mod_ctx(164)),
25452546
False, flint.fmpz(164)),
2546-
(lambda *a: flint.fmpz_mod_poly(*a, flint.fmpz_mod_poly_ctx(2**127)),
2547-
lambda x: flint.fmpz_mod(x, flint.fmpz_mod_ctx(2**127)),
2548-
False, flint.fmpz(2**127)),
2549-
(lambda *a: flint.fmpz_mod_poly(*a, flint.fmpz_mod_poly_ctx(2**255)),
2550-
lambda x: flint.fmpz_mod(x, flint.fmpz_mod_ctx(2**255)),
2551-
False, flint.fmpz(2**255)),
2547+
#(lambda *a: flint.fmpz_mod_poly(*a, flint.fmpz_mod_poly_ctx(2**127)),
2548+
# lambda x: flint.fmpz_mod(x, flint.fmpz_mod_ctx(2**127)),
2549+
# False, flint.fmpz(2**127)),
2550+
#(lambda *a: flint.fmpz_mod_poly(*a, flint.fmpz_mod_poly_ctx(2**255)),
2551+
# lambda x: flint.fmpz_mod(x, flint.fmpz_mod_ctx(2**255)),
2552+
# False, flint.fmpz(2**255)),
25522553
]
25532554

25542555

2555-
def _test_polys():
2556+
def test_polys():
25562557
for P, S, is_field, characteristic in _all_polys():
25572558

25582559
composite_characteristic = characteristic != 0 and not characteristic.is_prime()
@@ -3464,7 +3465,7 @@ def _all_polys_mpolys():
34643465
yield P, S, [x, y], is_field, characteristic
34653466

34663467

3467-
def _test_factor_poly_mpoly():
3468+
def test_factor_poly_mpoly():
34683469
"""Test that factor() is consistent across different poly/mpoly types."""
34693470

34703471
def check(p, coeff, factors):
@@ -3674,16 +3675,16 @@ def factor_sqf(p):
36743675
def _all_matrices():
36753676
"""Return a list of matrix types and scalar types."""
36763677
R163 = flint.fmpz_mod_ctx(163)
3677-
R127 = flint.fmpz_mod_ctx(2**127 - 1)
3678-
R255 = flint.fmpz_mod_ctx(2**255 - 19)
3678+
#R127 = flint.fmpz_mod_ctx(2**127 - 1)
3679+
#R255 = flint.fmpz_mod_ctx(2**255 - 19)
36793680
return [
36803681
# (matrix_type, scalar_type, is_field)
36813682
(flint.fmpz_mat, flint.fmpz, False),
36823683
(flint.fmpq_mat, flint.fmpq, True),
36833684
(lambda *a: flint.nmod_mat(*a, 17), lambda x: flint.nmod(x, 17), True),
36843685
(lambda *a: flint.fmpz_mod_mat(*a, R163), lambda x: flint.fmpz_mod(x, R163), True),
3685-
(lambda *a: flint.fmpz_mod_mat(*a, R127), lambda x: flint.fmpz_mod(x, R127), True),
3686-
(lambda *a: flint.fmpz_mod_mat(*a, R255), lambda x: flint.fmpz_mod(x, R255), True),
3686+
#(lambda *a: flint.fmpz_mod_mat(*a, R127), lambda x: flint.fmpz_mod(x, R127), True),
3687+
#(lambda *a: flint.fmpz_mod_mat(*a, R255), lambda x: flint.fmpz_mod(x, R255), True),
36873688
]
36883689

36893690

@@ -3803,7 +3804,7 @@ def _poly_type_from_matrix_type(mat_type):
38033804
assert False
38043805

38053806

3806-
def _test_matrices_eq():
3807+
def test_matrices_eq():
38073808
for M, S, is_field in _all_matrices():
38083809
A1 = M([[1, 2], [3, 4]])
38093810
A2 = M([[1, 2], [3, 4]])
@@ -3828,7 +3829,7 @@ def _test_matrices_eq():
38283829
assert (A1 != A2) is True
38293830

38303831

3831-
def _test_matrices_constructor():
3832+
def test_matrices_constructor():
38323833
for M, S, is_field in _all_matrices():
38333834
assert raises(lambda: M(), TypeError)
38343835

@@ -3900,7 +3901,7 @@ def _matrix_repr(M):
39003901
assert False
39013902

39023903

3903-
def _test_matrices_strrepr():
3904+
def test_matrices_strrepr():
39043905
for M, S, is_field in _all_matrices():
39053906
A = M([[1, 2], [3, 4]])
39063907
A_str = "[1, 2]\n[3, 4]"
@@ -3923,7 +3924,7 @@ def _test_matrices_strrepr():
39233924
ctx.pretty = pretty
39243925

39253926

3926-
def _test_matrices_getitem():
3927+
def test_matrices_getitem():
39273928
for M, S, is_field in _all_matrices():
39283929
M1234 = M([[1, 2], [3, 4]])
39293930
assert M1234[0, 0] == S(1)
@@ -3939,7 +3940,7 @@ def _test_matrices_getitem():
39393940
assert raises(lambda: M1234[-1, -1], IndexError)
39403941

39413942

3942-
def _test_matrices_setitem():
3943+
def test_matrices_setitem():
39433944
for M, S, is_field in _all_matrices():
39443945
M1234 = M([[1, 2], [3, 4]])
39453946

@@ -3965,7 +3966,7 @@ def setbad(obj, key, val):
39653966
assert raises(lambda: setbad(M1234, (-1,-1), 1), IndexError)
39663967

39673968

3968-
def _test_matrices_bool():
3969+
def test_matrices_bool():
39693970
for M, S, is_field in _all_matrices():
39703971
assert bool(M([])) is False
39713972
assert bool(M([[0]])) is False
@@ -3976,14 +3977,14 @@ def _test_matrices_bool():
39763977
assert bool(M([[1, 0], [0, 1]])) is True
39773978

39783979

3979-
def _test_matrices_pos_neg():
3980+
def test_matrices_pos_neg():
39803981
for M, S, is_field in _all_matrices():
39813982
M1234 = M([[1, 2], [3, 4]])
39823983
assert +M1234 == M1234
39833984
assert -M1234 == M([[-1, -2], [-3, -4]])
39843985

39853986

3986-
def _test_matrices_add():
3987+
def test_matrices_add():
39873988
for M, S, is_field in _all_matrices():
39883989
M1234 = M([[1, 2], [3, 4]])
39893990
M5678 = M([[5, 6], [7, 8]])
@@ -4003,7 +4004,7 @@ def _test_matrices_add():
40034004
assert raises(lambda: M2([[1, 2], [3, 4]]) + M1234, (TypeError, ValueError))
40044005

40054006

4006-
def _test_matrices_sub():
4007+
def test_matrices_sub():
40074008
for M, S, is_field in _all_matrices():
40084009
M1234 = M([[1, 2], [3, 4]])
40094010
M5678 = M([[5, 6], [7, 8]])
@@ -4023,7 +4024,7 @@ def _test_matrices_sub():
40234024
assert raises(lambda: M2([[1, 2], [3, 4]]) - M1234, (TypeError, ValueError))
40244025

40254026

4026-
def _test_matrices_mul():
4027+
def test_matrices_mul():
40274028
for M, S, is_field in _all_matrices():
40284029
M1234 = M([[1, 2], [3, 4]])
40294030
M5678 = M([[5, 6], [7, 8]])
@@ -4049,7 +4050,7 @@ def _test_matrices_mul():
40494050
assert raises(lambda: M2([[1, 2], [3, 4]]) * M1234, (TypeError, ValueError))
40504051

40514052

4052-
def _test_matrices_pow():
4053+
def test_matrices_pow():
40534054
for M, S, is_field in _all_matrices():
40544055
M1234 = M([[1, 2], [3, 4]])
40554056
assert M1234**0 == M([[1, 0], [0, 1]])
@@ -4070,7 +4071,7 @@ def _test_matrices_pow():
40704071
assert raises(lambda: None**M1234, TypeError)
40714072

40724073

4073-
def _test_matrices_div():
4074+
def test_matrices_div():
40744075
for M, S, is_field in _all_matrices():
40754076
M1234 = M([[1, 2], [3, 4]])
40764077
if is_field:
@@ -4082,7 +4083,7 @@ def _test_matrices_div():
40824083
raises(lambda: None / M1234, TypeError)
40834084

40844085

4085-
def _test_matrices_properties():
4086+
def test_matrices_properties():
40864087
for M, S, is_field in _all_matrices():
40874088
# XXX: Add these properties to all matrix types
40884089
if M is not flint.fmpz_mat:
@@ -4126,7 +4127,7 @@ def _test_matrices_properties():
41264127
assert M([[1, 1, 0], [1, 2, 0]]).is_lower_triangular() is False
41274128

41284129

4129-
def _test_matrices_inv():
4130+
def test_matrices_inv():
41304131
for M, S, is_field in _all_matrices():
41314132
if is_field:
41324133
M1234 = M([[1, 2], [3, 4]])
@@ -4138,7 +4139,7 @@ def _test_matrices_inv():
41384139
# XXX: Test non-field matrices. unimodular?
41394140

41404141

4141-
def _test_matrices_det():
4142+
def test_matrices_det():
41424143
for M, S, is_field in _all_matrices():
41434144
M1234 = M([[1, 2], [3, 4]])
41444145
assert M1234.det() == S(-2)
@@ -4148,7 +4149,7 @@ def _test_matrices_det():
41484149
assert raises(lambda: Mr.det(), ValueError)
41494150

41504151

4151-
def _test_matrices_charpoly():
4152+
def test_matrices_charpoly():
41524153
for M, S, is_field in _all_matrices():
41534154
P = _poly_type_from_matrix_type(M)
41544155
M1234 = M([[1, 2], [3, 4]])
@@ -4159,7 +4160,7 @@ def _test_matrices_charpoly():
41594160
assert raises(lambda: Mr.charpoly(), ValueError)
41604161

41614162

4162-
def _test_matrices_minpoly():
4163+
def test_matrices_minpoly():
41634164
for M, S, is_field in _all_matrices():
41644165
P = _poly_type_from_matrix_type(M)
41654166
M1234 = M([[1, 2], [3, 4]])
@@ -4170,7 +4171,7 @@ def _test_matrices_minpoly():
41704171
assert raises(lambda: Mr.minpoly(), ValueError)
41714172

41724173

4173-
def _test_matrices_rank():
4174+
def test_matrices_rank():
41744175
for M, S, is_field in _all_matrices():
41754176
M1234 = M([[1, 2], [3, 4]])
41764177
assert M1234.rank() == 2
@@ -4182,7 +4183,7 @@ def _test_matrices_rank():
41824183
assert Mz.rank() == 0
41834184

41844185

4185-
def _test_matrices_rref():
4186+
def test_matrices_rref():
41864187
for M, S, is_field in _all_matrices():
41874188
if is_field:
41884189
Mr = M([[1, 2, 3], [4, 5, 6]])
@@ -4193,7 +4194,7 @@ def _test_matrices_rref():
41934194
assert Mr == Mr_rref
41944195

41954196

4196-
def _test_matrices_fflu():
4197+
def test_matrices_fflu():
41974198

41984199
QQ = flint.fmpq_mat
41994200
shape = lambda A: (A.nrows(), A.ncols())
@@ -4250,7 +4251,7 @@ def check_fflu(A):
42504251
check_fflu(A)
42514252

42524253

4253-
def _test_matrices_solve():
4254+
def test_matrices_solve():
42544255
for M, S, is_field in _all_matrices():
42554256
if is_field:
42564257
A = M([[1, 2], [3, 4]])
@@ -4269,7 +4270,7 @@ def _test_matrices_solve():
42694270
assert raises(lambda: A.solve(b), ZeroDivisionError)
42704271

42714272

4272-
def _test_matrices_transpose():
4273+
def test_matrices_transpose():
42734274
for M, S, is_field in _all_matrices():
42744275
M1234 = M([[1, 2, 3], [4, 5, 6]])
42754276
assert M1234.transpose() == M([[1, 4], [2, 5], [3, 6]])
@@ -4690,46 +4691,46 @@ def test_all_tests():
46904691
test_nmod_series,
46914692

46924693
test_fmpz_mod,
4693-
#test_fmpz_mod_dlog,
4694-
#test_fmpz_mod_poly,
4695-
#test_fmpz_mod_mat,
4694+
test_fmpz_mod_dlog,
4695+
test_fmpz_mod_poly,
4696+
test_fmpz_mod_mat,
46964697

46974698
test_division_scalar,
46984699
test_division_poly,
46994700
test_division_matrix,
47004701

4701-
# test_factor_poly_mpoly,
4702+
test_factor_poly_mpoly,
47024703

4703-
# test_polys,
4704+
test_polys,
47044705
test_mpolys,
47054706

47064707
test_fmpz_mpoly_vec,
47074708

4708-
#test_matrices_eq,
4709-
#test_matrices_constructor,
4710-
#test_matrices_strrepr,
4711-
#test_matrices_getitem,
4712-
#test_matrices_setitem,
4713-
#test_matrices_bool,
4714-
#test_matrices_transpose,
4715-
#test_matrices_pos_neg,
4716-
#test_matrices_add,
4717-
#test_matrices_sub,
4718-
#test_matrices_mul,
4719-
#test_matrices_pow,
4720-
#test_matrices_div,
4721-
#test_matrices_properties,
4722-
#test_matrices_inv,
4723-
#test_matrices_det,
4724-
#test_matrices_charpoly,
4725-
#test_matrices_minpoly,
4726-
#test_matrices_rank,
4727-
#test_matrices_rref,
4728-
#test_matrices_solve,
4729-
#test_matrices_fflu,
4730-
4731-
# test_fq_default,
4732-
# test_fq_default_poly,
4709+
test_matrices_eq,
4710+
test_matrices_constructor,
4711+
test_matrices_strrepr,
4712+
test_matrices_getitem,
4713+
test_matrices_setitem,
4714+
test_matrices_bool,
4715+
test_matrices_transpose,
4716+
test_matrices_pos_neg,
4717+
test_matrices_add,
4718+
test_matrices_sub,
4719+
test_matrices_mul,
4720+
test_matrices_pow,
4721+
test_matrices_div,
4722+
test_matrices_properties,
4723+
test_matrices_inv,
4724+
test_matrices_det,
4725+
test_matrices_charpoly,
4726+
test_matrices_minpoly,
4727+
test_matrices_rank,
4728+
test_matrices_rref,
4729+
test_matrices_solve,
4730+
test_matrices_fflu,
4731+
4732+
# _test_fq_default,
4733+
# _test_fq_default_poly,
47334734

47344735
test_arb,
47354736

0 commit comments

Comments
 (0)