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

563580 views
1
#include"typedef.h"
2
#include"matrix.h"
3
/**************************************************************************\
4
@---------------------------------------------------------------------------
5
@---------------------------------------------------------------------------
6
@ FILE: kron_mat.c
7
@---------------------------------------------------------------------------
8
@---------------------------------------------------------------------------
9
@
10
\**************************************************************************/
11
12
/**************************************************************************\
13
@---------------------------------------------------------------------------
14
@ matrix_TYP *kron_mat(A,B)
15
@ matrix_TYP *A, *B;
16
@
17
@ calculates the Kronecker product of the matrices A and B.
18
@---------------------------------------------------------------------------
19
@
20
\**************************************************************************/
21
22
matrix_TYP *kron_mat(A,B)
23
matrix_TYP *A, *B;
24
{
25
26
int i,j,k,l,r,c;
27
int rows, cols;
28
matrix_TYP *C;
29
30
rows = A->rows *B->rows;
31
cols = A->cols *B->cols;
32
C = init_mat(rows,cols, "");
33
for(i=0; i<A->rows;i++)
34
for(j=0;j<A->cols;j++)
35
{
36
/* changed 15/4/97 tilman
37
r = i*A->rows; */
38
r = i*B->rows;
39
for(k=0;k<B->rows;k++)
40
{
41
/* changed 15/4/97 tilman
42
c = j*A->cols; */
43
c = j*B->cols;
44
for(l=0;l<B->cols;l++)
45
{
46
C->array.SZ[r][c] = A->array.SZ[i][j] * B->array.SZ[k][l];
47
c++;
48
}
49
r++;
50
}
51
}
52
return(C);
53
}
54
55