Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

563680 views
1
#include"typedef.h"
2
/**************************************************************************\
3
@---------------------------------------------------------------------------
4
@---------------------------------------------------------------------------
5
@ FILE: modp_mat.c
6
@---------------------------------------------------------------------------
7
@---------------------------------------------------------------------------
8
@
9
\**************************************************************************/
10
11
/**************************************************************************\
12
@---------------------------------------------------------------------------
13
@ void modp_mat(M, p)
14
@ matrix_TYP *M;
15
@ int p;
16
@
17
@ reduces the entries of M modulo p such -|p/2| < x < |p/2|
18
@ for every entry x of M.
19
@ if p = 2 or p = -2, the entries are 0 or 1.
20
@---------------------------------------------------------------------------
21
@
22
\**************************************************************************/
23
24
void modp_mat(M, prime)
25
matrix_TYP *M;
26
int prime;
27
{
28
int i,j, phalbe, mphalbe;
29
30
if(prime < 0)
31
prime = -prime;
32
phalbe = prime/2;
33
mphalbe = -phalbe;
34
if(prime == 2)
35
mphalbe = 0;
36
for(i=0;i<M->rows;i++)
37
for(j=0;j<M->cols;j++)
38
{
39
M->array.SZ[i][j] %=prime;
40
if(M->array.SZ[i][j] < mphalbe)
41
M->array.SZ[i][j] +=prime;
42
if(M->array.SZ[i][j] > phalbe)
43
M->array.SZ[i][j] -=prime;
44
}
45
}
46
47