CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418346
1
#include"typedef.h"
2
#include"tools.h"
3
#include"matrix.h"
4
#include"getput.h"
5
#include"longtools.h"
6
7
8
9
10
main (int argc, char *argv[])
11
{
12
matrix_TYP **M, *Trf, *E;
13
int Manz, i;
14
15
extern char **FILENAMES;
16
extern int FILEANZ;
17
18
19
read_header(argc, argv);
20
if(FILEANZ != 1)
21
{
22
printf("Usage: %s 'file' [-t]\n",argv[0]);
23
printf("\n");
24
printf("file: matrix_TYP containing a set of matrices\n");
25
printf("\n");
26
printf("Calculates the Smith normal form of the matrices\n");
27
printf("given in file, resp. the isomorphism type of the factor group of\n");
28
printf("two lattices, where the matrix is interpreted as the coordinate\n");
29
printf("columns of a generating set of the second lattice in terms of a\n");
30
printf("basis of the first one.\n");
31
printf("\n");
32
printf("CAUTION: If the given matrix is rational, the\n");
33
printf(" Smith normal form is calculated for the least\n");
34
printf(" integral multiple of it.\n");
35
printf("\n");
36
printf("Options:\n");
37
printf("-t : gives the left tranformation matrix as well.\n");
38
printf("\n");
39
if (is_option('h')){
40
exit(0);
41
}
42
else{
43
exit(31);
44
}
45
}
46
47
M = mget_mat(FILENAMES[0], &Manz);
48
for(i=0;i<Manz;i++)
49
{
50
if (!M[i]->flags.Integral) rat2kgv(M[i]);
51
52
if(is_option('t'))
53
Trf = init_mat(M[i]->rows, M[i]->rows, "1");
54
else
55
Trf = NULL;
56
E = long_elt_mat(Trf, M[i], NULL);
57
put_mat(E, NULL, "ELT of matrix", 0);
58
free_mat(E);
59
if(is_option('t'))
60
{
61
put_mat(Trf, NULL, "Transformtion matrix", 0);
62
free_mat(Trf);
63
}
64
}
65
66
67
exit(0);
68
}
69
70