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 "matrix.h"
3
/**************************************************************************\
4
@---------------------------------------------------------------------------
5
@---------------------------------------------------------------------------
6
@ FILE: scal_pr_mat.c
7
@---------------------------------------------------------------------------
8
@---------------------------------------------------------------------------
9
@
10
\**************************************************************************/
11
12
/*{{{}}}*/
13
/*{{{ scal_pr*/
14
/*---------------------------------------------------------------*\
15
@-------------------------------------------------------------------------
16
@ matrix_TYP *scal_pr ( vectors, form, truth )
17
@ matrix_TYP *vectors, *form ;
18
@ boolean truth;
19
@
20
@ Calculates: tr
21
@ vectors * form * vectors
22
@ vectors is supposed to be a matrix of row-vectors.
23
@ form is supposed to be a symmetric bilinear form; if
24
@ form == NULL, the standard scalar product is used.
25
@
26
@ truth is an option to simplify the scalar-products for lattices
27
@-------------------------------------------------------------------------
28
\*---------------------------------------------------------------*/
29
matrix_TYP *scal_pr ( vectors, form, truth )
30
matrix_TYP *vectors, *form ;
31
boolean truth;
32
{
33
int rV, cV, i, j, k;
34
int **V, **F, **S, *z, kgv = 0;
35
matrix_TYP *res;
36
37
/*============================================================*\
38
|| Option to simplify the scalar-products for lattices ||
39
\*============================================================*/
40
if(!truth) {
41
tgauss(vectors);
42
}
43
44
V = vectors->array.SZ;
45
rV = vectors->rows;
46
cV = vectors->cols;
47
F = form->array.SZ;
48
49
res = init_mat(rV,rV,"iks");
50
if( save_null_mat(vectors) || save_null_mat(form)) {
51
res->kgv = 0;
52
res->flags.Integral =
53
res->flags.Symmetric =
54
res->flags.Diagonal =
55
res->flags.Scalar = TRUE;
56
return(res);
57
}
58
59
z = (int *)calloc(cV,sizeof(int));
60
61
S = res->array.SZ;
62
63
/*------------------------------------------------------------*\
64
| Matrix product |
65
| 5.02.92: because of the Gauss_Algorithm the vectors are |
66
| supposed to be given as a upper triangular matrix. |
67
\*------------------------------------------------------------*/
68
for ( i = 0; i < rV; i++) {
69
/*---------------------------------------------------------*\
70
| Determine z as i-th row of vectors * form |
71
\*---------------------------------------------------------*/
72
for ( j = 0; j < cV; j++) {/* exchange '0' and 'i' */
73
if ( V[i][j] != 0 ) {
74
if (form->flags.Diagonal) {
75
z[j] = V[i][j] * F[j][j];
76
} else {
77
for ( k = 0; k < cV; k++ ) {
78
if ( F[j][k] != 0 ) {
79
z[k] += V[i][j] * F[j][k];
80
}
81
}
82
}
83
}
84
}
85
/*---------------------------------------------------------*\
86
| tr |
87
| Determine i-th row of vectors * form * vectors |
88
| tr |
89
| as z * vectors |
90
\*---------------------------------------------------------*/
91
for (j = 0 ; j < cV; j ++ ) {
92
if ( z[j] != 0 ) {
93
for ( k = 0; k <= i ; k++) {
94
if ( V[k][j] != 0 ) {
95
S[i][k] += z[j] * V[k][j];
96
}
97
}
98
z[j] = 0;
99
}
100
}
101
}
102
103
for ( i = 0; i < rV; i++ ) {
104
for ( j = 0; j < i; j++ ) {
105
S[j][i] = S[i][j];
106
}
107
}
108
109
free(z);
110
/*COUNTER--;*/
111
kgv= vectors->kgv * vectors->kgv * form->kgv;
112
/*------------------------------------------------------------*\
113
| Fill data into matrix_TYP res |
114
\*------------------------------------------------------------*/
115
res->flags.Integral = (kgv == 1);
116
res->kgv = kgv;
117
Check_mat(res);
118
return (res);
119
}
120
/*}}} */
121
122