GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include "typedef.h"1#include "matrix.h"2/**************************************************************************\3@---------------------------------------------------------------------------4@---------------------------------------------------------------------------5@ FILE: scal_pr_mat.c6@---------------------------------------------------------------------------7@---------------------------------------------------------------------------8@9\**************************************************************************/1011/*{{{}}}*/12/*{{{ scal_pr*/13/*---------------------------------------------------------------*\14@-------------------------------------------------------------------------15@ matrix_TYP *scal_pr ( vectors, form, truth )16@ matrix_TYP *vectors, *form ;17@ boolean truth;18@19@ Calculates: tr20@ vectors * form * vectors21@ vectors is supposed to be a matrix of row-vectors.22@ form is supposed to be a symmetric bilinear form; if23@ form == NULL, the standard scalar product is used.24@25@ truth is an option to simplify the scalar-products for lattices26@-------------------------------------------------------------------------27\*---------------------------------------------------------------*/28matrix_TYP *scal_pr ( vectors, form, truth )29matrix_TYP *vectors, *form ;30boolean truth;31{32int rV, cV, i, j, k;33int **V, **F, **S, *z, kgv = 0;34matrix_TYP *res;3536/*============================================================*\37|| Option to simplify the scalar-products for lattices ||38\*============================================================*/39if(!truth) {40tgauss(vectors);41}4243V = vectors->array.SZ;44rV = vectors->rows;45cV = vectors->cols;46F = form->array.SZ;4748res = init_mat(rV,rV,"iks");49if( save_null_mat(vectors) || save_null_mat(form)) {50res->kgv = 0;51res->flags.Integral =52res->flags.Symmetric =53res->flags.Diagonal =54res->flags.Scalar = TRUE;55return(res);56}5758z = (int *)calloc(cV,sizeof(int));5960S = res->array.SZ;6162/*------------------------------------------------------------*\63| Matrix product |64| 5.02.92: because of the Gauss_Algorithm the vectors are |65| supposed to be given as a upper triangular matrix. |66\*------------------------------------------------------------*/67for ( i = 0; i < rV; i++) {68/*---------------------------------------------------------*\69| Determine z as i-th row of vectors * form |70\*---------------------------------------------------------*/71for ( j = 0; j < cV; j++) {/* exchange '0' and 'i' */72if ( V[i][j] != 0 ) {73if (form->flags.Diagonal) {74z[j] = V[i][j] * F[j][j];75} else {76for ( k = 0; k < cV; k++ ) {77if ( F[j][k] != 0 ) {78z[k] += V[i][j] * F[j][k];79}80}81}82}83}84/*---------------------------------------------------------*\85| tr |86| Determine i-th row of vectors * form * vectors |87| tr |88| as z * vectors |89\*---------------------------------------------------------*/90for (j = 0 ; j < cV; j ++ ) {91if ( z[j] != 0 ) {92for ( k = 0; k <= i ; k++) {93if ( V[k][j] != 0 ) {94S[i][k] += z[j] * V[k][j];95}96}97z[j] = 0;98}99}100}101102for ( i = 0; i < rV; i++ ) {103for ( j = 0; j < i; j++ ) {104S[j][i] = S[i][j];105}106}107108free(z);109/*COUNTER--;*/110kgv= vectors->kgv * vectors->kgv * form->kgv;111/*------------------------------------------------------------*\112| Fill data into matrix_TYP res |113\*------------------------------------------------------------*/114res->flags.Integral = (kgv == 1);115res->kgv = kgv;116Check_mat(res);117return (res);118}119/*}}} */120121122