Skip to content

Commit ba6af38

Browse files
committed
Add mpn_mod_vec_rand func
1 parent 05724a4 commit ba6af38

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/mpn_mod.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ mpn_mod_ctx_set_is_field(gr_ctx_t ctx, truth_t is_field)
6767

6868
int gr_ctx_init_mpn_mod(gr_ctx_t ctx, const fmpz_t n);
6969
int _gr_ctx_init_mpn_mod(gr_ctx_t ctx, nn_srcptr n, slong nlimbs);
70+
int mpn_mod_rand(nn_ptr res, flint_rand_t state, gr_ctx_t ctx);
7071
void gr_ctx_init_mpn_mod_randtest(gr_ctx_t ctx, flint_rand_t state);
7172

7273
int mpn_mod_ctx_write(gr_stream_t out, gr_ctx_t ctx);
@@ -191,6 +192,7 @@ int mpn_mod_div(nn_ptr res, nn_srcptr x, nn_srcptr y, gr_ctx_t ctx);
191192
int _mpn_mod_vec_zero(nn_ptr res, slong len, gr_ctx_t ctx);
192193
int _mpn_mod_vec_clear(nn_ptr FLINT_UNUSED(res), slong FLINT_UNUSED(len), gr_ctx_t FLINT_UNUSED(ctx));
193194
int _mpn_mod_vec_set(nn_ptr res, nn_srcptr x, slong len, gr_ctx_t ctx);
195+
int _mpn_mod_vec_rand(nn_ptr res, flint_rand_t state, slong len, gr_ctx_t ctx);
194196
void _mpn_mod_vec_swap(nn_ptr vec1, nn_ptr vec2, slong len, gr_ctx_t ctx);
195197
int _mpn_mod_vec_neg(nn_ptr res, nn_srcptr x, slong len, gr_ctx_t ctx);
196198
int _mpn_mod_vec_add(nn_ptr res, nn_srcptr x, nn_srcptr y, slong len, gr_ctx_t ctx);

src/mpn_mod/vec.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ _mpn_mod_vec_set(nn_ptr res, nn_srcptr x, slong len, gr_ctx_t ctx)
3232
return GR_SUCCESS;
3333
}
3434

35+
int
36+
_mpn_mod_vec_rand(nn_ptr res, flint_rand_t state, slong len, gr_ctx_t ctx)
37+
{
38+
slong n = MPN_MOD_CTX_NLIMBS(ctx);
39+
slong i;
40+
41+
for (i = 0; i < len; i++)
42+
if (mpn_mod_rand(res + i * n, state, ctx) != GR_SUCCESS)
43+
return GR_UNABLE;
44+
45+
return GR_SUCCESS;
46+
}
47+
3548
void
3649
_mpn_mod_vec_swap(nn_ptr vec1, nn_ptr vec2, slong len, gr_ctx_t ctx)
3750
{

0 commit comments

Comments
 (0)