Skip to content

Commit

Permalink
use nmod_mul, faster
Browse files Browse the repository at this point in the history
  • Loading branch information
vneiger committed Sep 3, 2024
1 parent d404497 commit 2d09be3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/nmod_mat/scalar.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "flint-mparam.h"
#include "ulong_extras.h"
#include "nmod_mat.h"
#include "nmod.h"
#include "fmpz.h"

/*******************/
Expand All @@ -31,8 +32,7 @@ _nmod_mat_scalar_addmul_ui_generic(nmod_mat_t C, const nmod_mat_t A,
{
nmod_mat_entry(C, i, j) =
n_addmod(nmod_mat_entry(A, i, j),
n_mulmod2_preinv(nmod_mat_entry(B, i, j), c,
B->mod.n, B->mod.ninv),
nmod_mul(nmod_mat_entry(B, i, j), c, B->mod),
A->mod.n);
}
}
Expand Down Expand Up @@ -83,11 +83,9 @@ _nmod_mat_scalar_mul_generic(nmod_mat_t B, const nmod_mat_t A, ulong c)
{
for (slong i = 0; i < A->r; i++)
for (slong j = 0; j < A->c; j++)
nmod_mat_entry(B, i, j) = n_mulmod2_preinv(
nmod_mat_entry(A, i, j), c, A->mod.n, A->mod.ninv);
nmod_mat_entry(B, i, j) = nmod_mul(nmod_mat_entry(A, i, j), c, A->mod);
}


void
_nmod_mat_scalar_mul_precomp(nmod_mat_t B, const nmod_mat_t A, ulong c, ulong c_pr)
{
Expand Down

0 comments on commit 2d09be3

Please sign in to comment.