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

563604 views
1
#include "typedef.h"
2
#include "datei.h"
3
#include "getput.h"
4
5
/***************************************************************************
6
@
7
@---------------------------------------------------------------------------
8
@
9
@ FILE: lattice_tools.c
10
@
11
@---------------------------------------------------------------------------
12
@
13
***************************************************************************/
14
15
16
/***************************************************************************
17
@
18
@---------------------------------------------------------------------------
19
@
20
@ lattice_element *init_lattice_element()
21
@
22
@ initializes a lattice_element, and allocates memory for res->symbol
23
@ via calloc(100*sizeof(char));
24
@
25
@---------------------------------------------------------------------------
26
@
27
***************************************************************************/
28
lattice_element *init_lattice_element()
29
{
30
lattice_element *res;
31
32
res = (lattice_element *) malloc(1 * sizeof(lattice_element));
33
34
res->grp = NULL;
35
res->symbol = (char *) calloc(100 , sizeof(char));
36
res->almost = -1;
37
res->zclass = -1;
38
res->alpha = -1;
39
res->N_orbits = 0;
40
res->TR = NULL;
41
42
return res;
43
}
44
45
/***************************************************************************
46
@
47
@---------------------------------------------------------------------------
48
@
49
@ void free_lattice_element(lattice_element *x)
50
@
51
@ frees all stuff assigned in x, and x itself
52
@
53
@---------------------------------------------------------------------------
54
@
55
***************************************************************************/
56
void free_lattice_element(lattice_element *x)
57
{
58
int i;
59
60
if (x->grp != NULL) free_bravais(x->grp);
61
for (i=0;i<x->N_orbits;i++) free_mat(x->TR[i]);
62
free(x->symbol);
63
if (x->TR != NULL) free(x->TR);
64
65
free(x);
66
}
67
68
/***************************************************************************
69
@
70
@---------------------------------------------------------------------------
71
@
72
@---------------------------------------------------------------------------
73
@
74
***************************************************************************/
75
lattice_element *fget_lattice_element(FILE *F,int OPTION)
76
{
77
lattice_element *E;
78
79
E = init_lattice_element();
80
fscanf(F,"%s %d %d\n",E->symbol,&E->almost,&E->zclass);
81
82
fscanf(F,"%d\n",&E->alpha);
83
84
E->TR = fmget_mat(F,&E->N_orbits);
85
86
/* sometimes we want to get hold of the group in the catalog as well */
87
if (OPTION){
88
E->grp = brav_from_datei(E->symbol,E->almost,E->zclass);
89
}
90
91
return E;
92
}
93
94
/***************************************************************************
95
@
96
@---------------------------------------------------------------------------
97
@
98
@---------------------------------------------------------------------------
99
@
100
***************************************************************************/
101
void fput_lattice_element(lattice_element *E,FILE *F)
102
{
103
int i;
104
105
if (F==NULL) F = stdout;
106
107
fprintf(F,"Symbol: %s almost: %d zclass: %d\n",
108
E->symbol,E->almost,E->zclass);
109
110
fprintf(F,"alpha : %d\n",E->alpha);
111
112
fprintf(F,"#%d\n",E->N_orbits);
113
114
for (i=0;i<E->N_orbits;i++){
115
fput_mat(F,E->TR[i],NULL,2);
116
}
117
118
if (E->grp != NULL) put_bravais(E->grp,NULL,NULL);
119
120
return ;
121
}
122
123
124