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

563595 views
1
#include"typedef.h"
2
/**************************************************************************\
3
@---------------------------------------------------------------------------
4
@---------------------------------------------------------------------------
5
@ FILE: trace_bifo.c
6
@---------------------------------------------------------------------------
7
@---------------------------------------------------------------------------
8
@
9
\**************************************************************************/
10
11
/**************************************************************************\
12
@---------------------------------------------------------------------------
13
@ Calculates S = (S[i][j]) with S[i][j] = trace(F1[i]F2[j]) for 1<= i,j <= anz.
14
@ Then g = gcd(S[i][j]) is calculated and the result is S = 1/g * S.
15
@
16
@---------------------------------------------------------------------------
17
@
18
\*************************************************************************/
19
matrix_TYP *trace_bifo(F1, F2, anz)
20
matrix_TYP **F1, **F2;
21
int anz;
22
{
23
int i,j,k,l, Sij, n;
24
matrix_TYP *S;
25
int g,x;
26
27
extern matrix_TYP *init_mat();
28
29
/* changed tilman 7/1/97 form
30
n = F1[1]->cols;
31
to: */
32
n = F1[0]->cols;
33
S = init_mat(anz, anz, "");
34
for(i=0;i<anz;i++)
35
for(j=0;j<anz;j++)
36
{
37
Sij = 0;
38
for(k=0;k<n;k++)
39
for(l=0;l<n;l++)
40
Sij += F1[i]->array.SZ[k][l] * F2[j]->array.SZ[l][k];
41
S->array.SZ[i][j] = Sij;
42
}
43
g = 0;
44
for(i=0; i<anz && g != 1; i++)
45
for(j=0; j<anz && g != 1; j++)
46
{
47
if(S->array.SZ[i][j] != 0)
48
{
49
if(g == 0)
50
{
51
g = S->array.SZ[i][j];
52
if(g < 0)
53
g = -g;
54
}
55
else
56
{
57
x = GGT(g, S->array.SZ[i][j]);
58
if(x<0)
59
g = -x;
60
else g = x;
61
}
62
}
63
}
64
65
if(g != 1 && g != 0)
66
{
67
for(i=0; i<anz && g != 1; i++)
68
for(j=0; j<anz && g != 1; j++)
69
S->array.SZ[i][j] /= g;
70
}
71
return(S);
72
}
73
74