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
#include "tools.h"
3
4
/***************************************************************************
5
@---------------------------------------------------------------------------
6
@
7
@ FILE: divide_by_gcd.c
8
@
9
@---------------------------------------------------------------------------
10
****************************************************************************/
11
12
/***************************************************************************
13
@---------------------------------------------------------------------------
14
@
15
@ int divide_by_gcd(matrix_TYP *A)
16
@
17
@ divides the entries of A->array.SZ by the positive gcd of it's entries,
18
@ and returns this gcd.
19
@
20
@---------------------------------------------------------------------------
21
****************************************************************************/
22
int divide_by_gcd(matrix_TYP *A)
23
{
24
int g = labs(A->array.SZ[0][0]),
25
i,
26
j;
27
28
for (i=0;i<A->rows && (g!=1);i++){
29
for (j=0;j<A->cols && (g!=1);j++){
30
g = labs(GGT(A->array.SZ[i][j],g));
31
}
32
}
33
34
if (g!=1){
35
for (i=0;i<A->rows;i++){
36
for (j=0;j<A->cols;j++){
37
A->array.SZ[i][j] = A->array.SZ[i][j]/g;
38
}
39
}
40
}
41
42
return g;
43
}
44
45