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"polyeder.h"
3
#include"matrix.h"
4
#include"longtools.h"
5
/**************************************************************************\
6
@---------------------------------------------------------------------------
7
@---------------------------------------------------------------------------
8
@ FILE: first_polyeder.c
9
@---------------------------------------------------------------------------
10
@---------------------------------------------------------------------------
11
@
12
\**************************************************************************/
13
14
15
16
17
/**************************************************************************\
18
@---------------------------------------------------------------------------
19
@ polyeder_TYP *first_polyeder(mauern, anz)
20
@ wall_TYP **mauern;
21
@ int anz;
22
@
23
@ The arguments of 'first_polyeder' are linear inequalities
24
@ representent by 'mauern'.
25
@ 'anz' is the number of these equalities.
26
@ 'first_polyeder' returns NULL if there are not n = mauern[0]->dim
27
@ independent inequalities among the walls.
28
@ Otherwise, 'first_polyeder' selects n linear independent inequalities
29
@ and calculates the linear simplex defined by them.
30
@---------------------------------------------------------------------------
31
@
32
\**************************************************************************/
33
polyeder_TYP *first_polyeder(mauern, anz)
34
wall_TYP **mauern;
35
int anz;
36
{
37
int i,j,k,n;
38
int s, rrang, test, *take;
39
matrix_TYP *M, *Mi;
40
polyeder_TYP *erg;
41
42
43
n = mauern[0]->dim;
44
M = init_mat(anz, n, "");
45
take = (int *)malloc(anz *sizeof(int));
46
for(i=0;i<anz;i++)
47
take[i] = 0;
48
for(i=0;i<anz;i++)
49
for(j=0; j<n; j++)
50
M->array.SZ[i][j] = mauern[i]->gl[j];
51
/******************************
52
put_mat(M, NULL, "matrix in first_polyeder", 0);
53
******************************/
54
55
M->rows = 1;
56
rrang = n;
57
while(rrang != 0 && M->rows <= anz)
58
{
59
60
/* changed 19/8/97 tilman from:
61
s = long_row_gauss(M); to: */
62
s = long_row_basis(M,FALSE);
63
64
s = n - s;
65
if(s == rrang)
66
take[M->rows-1] = FALSE;
67
else
68
take[M->rows-1] = TRUE;
69
rrang = s;
70
if(rrang != 0)
71
M->rows++;
72
}
73
if(rrang != 0)
74
{
75
M->rows = anz;
76
free_mat(M);
77
free(take);
78
return(NULL);
79
}
80
81
erg = init_polyeder(n, n);
82
erg->is_closed = FALSE;
83
erg->is_degenerate = FALSE;
84
for(i=0; i<n;i++)
85
{
86
erg->vert[i] = init_vertex(n, n-1);
87
erg->wall[i] = init_wall(n);
88
}
89
k = 0;
90
M->rows = n;
91
for(i=0; i<anz;i++)
92
{
93
if(take[i] == TRUE)
94
{
95
for(j=0;j<n;j++)
96
{
97
M->array.SZ[k][j] = mauern[i]->gl[j];
98
erg->wall[k]->gl[j] = mauern[i]->gl[j];
99
}
100
erg->wall[k]->next_no = mauern[i]->next_no; /* 7 lines anne 8/10/97 */
101
erg->wall[k]->next = NULL;
102
if(mauern[i]->next != NULL){
103
erg->wall[k]->next = (int**)malloc(mauern[i]->next_no*sizeof(int*));
104
memcpy(erg->wall[k]->next, mauern[i]->next,
105
mauern[i]->next_no * sizeof(int));
106
}
107
erg->wall[k]->mat = copy_mat(mauern[i]->mat); /*anne, 4.3.97(2 Zeile)*/
108
erg->wall[k]->neu = mauern[i]->neu;
109
/* inserted next 5 lines to correspond to first_fuber */
110
erg->wall[k]->nproduct = mauern[i]->nproduct;
111
erg->wall[k]->product = (int *) malloc(erg->wall[k]->nproduct *
112
sizeof(int));
113
for (j=0;j<erg->wall[k]->nproduct;j++)
114
erg->wall[k]->product[j] = mauern[i]->product[j];
115
116
k++;
117
}
118
}
119
/******************************
120
put_mat(M, NULL, "matrix in first_polyeder", 0);
121
******************************/
122
Mi = long_mat_inv(M);
123
M->rows = anz;
124
free_mat(M);
125
free(take);
126
for(i=0;i<n;i++)
127
{
128
k = 0;
129
for(j=0;j<n;j++)
130
{
131
erg->vert[i]->v[j] = Mi->array.SZ[j][i];
132
if(i!=j)
133
{ erg->vert[i]->wall[k] = j; k++;}
134
}
135
}
136
free_mat(Mi);
137
for(i=0;i<n;i++)
138
normal_vertex(erg->vert[i]);
139
return(erg);
140
}
141
142