File tree Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ dirichlet_group_size(const dirichlet_group_t G)
64
64
65
65
ulong dirichlet_group_num_primitive (const dirichlet_group_t G );
66
66
67
- void dirichlet_group_init (dirichlet_group_t G , ulong q );
67
+ int dirichlet_group_init (dirichlet_group_t G , ulong q );
68
68
void dirichlet_subgroup_init (dirichlet_group_t H , const dirichlet_group_t G , ulong h );
69
69
void dirichlet_group_clear (dirichlet_group_t G );
70
70
void dirichlet_group_dlog_precompute (dirichlet_group_t G , ulong num );
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ dirichlet_group_lift_generators(dirichlet_group_t G)
103
103
}
104
104
}
105
105
106
- void
106
+ int
107
107
dirichlet_group_init (dirichlet_group_t G , ulong q )
108
108
{
109
109
slong k ;
@@ -123,6 +123,12 @@ dirichlet_group_init(dirichlet_group_t G, ulong q)
123
123
n_factor_init (& fac );
124
124
n_factor (& fac , q , 1 );
125
125
126
+ #if FLINT_BITS == 64
127
+ for (k = 0 ; k < fac .num ; k ++ )
128
+ if (fac .p [k ] > UWORD (1000000000000 ))
129
+ return 0 ;
130
+ #endif
131
+
126
132
G -> num = fac .num + G -> neven ;
127
133
G -> P = flint_malloc (G -> num * sizeof (dirichlet_prime_group_struct ));
128
134
G -> generators = flint_malloc (G -> num * sizeof (ulong ));
@@ -145,6 +151,8 @@ dirichlet_group_init(dirichlet_group_t G, ulong q)
145
151
dirichlet_prime_group_init (& G -> P [k ], p , e );
146
152
}
147
153
dirichlet_group_lift_generators (G );
154
+
155
+ return 1 ;
148
156
}
149
157
150
158
void
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ Multiplicative group modulo *q*
48
48
An *dirichlet_group_t * is defined as an array of *dirichlet_group_struct *
49
49
of length 1, permitting it to be passed by reference.
50
50
51
- .. function :: void dirichlet_group_init(dirichlet_group_t G, ulong q)
51
+ .. function :: int dirichlet_group_init(dirichlet_group_t G, ulong q)
52
52
53
53
Initializes *G * to the group of Dirichlet characters mod *q *.
54
54
@@ -69,8 +69,9 @@ Multiplicative group modulo *q*
69
69
safely be called even with large *q *.
70
70
71
71
For implementation reasons, the largest prime factor of *q * must not
72
- exceed `10^{12} ` (an abort will be raised). This restriction could
73
- be removed in the future.
72
+ exceed `10^{12} `. This restriction could
73
+ be removed in the future. The function returns 1 on success and 0
74
+ if a factor is too large.
74
75
75
76
.. function :: void dirichlet_subgroup_init(dirichlet_group_t H, const dirichlet_group_t G, ulong h)
76
77
You can’t perform that action at this time.
0 commit comments