File: orbitPoly.gi

package info (click to toggle)
gap-hap 1.66%2Bds-1
  • links: PTS
  • area: main
  • in suites: trixie
  • size: 55,348 kB
  • sloc: xml: 15,368; sh: 216; javascript: 155; makefile: 126; ansic: 57; perl: 36
file content (158 lines) | stat: -rw-r--r-- 3,764 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#####################################################################
#####################################################################
InstallGlobalFunction(OrbitPolytope,
function(G,v,Props)
local
	Points,p,x,i,w,Dim,tmp,input, tmpdir, tmpIn, tmp2dir, tmp2In,
	a,b,c,d,U,V,W,AppendTo, PrintTo;

AppendTo:=HAP_AppendTo;
PrintTo:=HAP_PrintTo;

Dim:=Length(v);
Points:=[];

tmpdir := DirectoryTemporary();;
tmpIn:=Filename( tmpdir , "tmpIn.log" );
tmp2dir := DirectoryTemporary();;
tmp2In:=Filename( tmpdir , "tmp2In.log" );


############################CREATE POINTS###############
if IsPermGroup(G) then

for x in G do
w:=[];
    for i in [1..Dim] do
    Append(w,[v[i^x]]);
    od;
Append(Points, [w]);
od;
						
else

for x in G do
    w:=v*x;
    Append(Points, [w]);
    od;
fi;
######################POINTS CREATED###################


################## CALCULATE HULL POINTS ###############
AppendTo(tmpIn,"POINTS","\n");
for p in Points do
AppendTo(tmpIn,1);
    for i in [1..Dim] do
    AppendTo(tmpIn," ",p[i]);
    od;
AppendTo(tmpIn,"\n");
od;


################# HULL CALCULATED ###################################


if "DIMENSION" in Props or "dimension" in Props then
Exec(Concatenation(POLYMAKE_PATH, tmpIn," DIM > ", tmp2In));
input:=InputTextFile(tmp2In);
tmp:=ReadLine(input);
tmp:=ReadLine(input);
Print("Dimension of orbit polytope is: ", tmp, "\n");
Exec(Concatenation("rm ", tmp2In));
fi;

if "VERTEX_DEGREES" in Props or "vertex_degrees" in Props then
Exec(Concatenation(POLYMAKE_PATH,tmpIn,  " VERTEX_DEGREES > ",tmp2In));
input:=InputTextFile(tmp2In);
tmp:=ReadLine(input);
tmp:=ReadLine(input);
Print("Vertex degree in graph of polytope is: ", Rat(Concatenation([tmp{[1..Position(tmp,' ')-1]}])), "\n");
#Exec(Concatenation("rm ",tmp2In));
fi;



if "VISUAL_GRAPH" in Props or "visual_graph" in Props then
Exec(Concatenation(POLYMAKE_PATH,tmpIn ," VISUAL_GRAPH"));
fi;

if "SCHLEGEL" in Props or "schlegel" in Props then
Exec(Concatenation(POLYMAKE_PATH,tmpIn ," SCHLEGEL"));
fi;


if "VISUAL" in Props or "visual" in Props then

if IsPermGroup(G) and Length(v)=4 then
	Exec(Concatenation("rm ",tmpIn));
	AppendTo(tmpIn,"POINTS","\n");

	for x in G do
	a:=v[1^x]-v[1];
	b:=v[2^x]-v[2];
	c:=v[3^x]-v[3];
	d:=v[4^x]-v[4];
	U:=2*a-2*b;
	V:=2*c-2*d;
	W:=a+b-c-d;
	AppendTo (tmpIn,1," ",U, " ",V," ",W,  "\n");
	od;
fi;
Exec(Concatenation(POLYMAKE_PATH,tmpIn ," VISUAL"));
fi;

#Exec(Concatenation("rm ",tmpIn));



end);
#####################################################################
#####################################################################

#####################################################################
#####################################################################
InstallOtherMethod(Display,
"method for displaying convex hulls of sets of points",
[IsPolymakeObject],
function(F)
local
        Points,p,x,i,w,Dim,tmp,input, tmpdir, tmpIn, tmp2dir, tmp2In,
        a,b,c,d,U,V,W,AppendTo, PrintTo;

AppendTo:=HAP_AppendTo;
PrintTo:=HAP_PrintTo;

Dim:=Length(Polymake(F,"F_VECTOR"));
Points:=Polymake(F,"VERTICES");

tmpdir := DirectoryTemporary();;
tmpIn:=Filename( tmpdir , "tmpIn.log" );
tmp2dir := DirectoryTemporary();;
tmp2In:=Filename( tmpdir , "tmp2In.log" );




################## CALCULATE HULL POINTS ###############
AppendTo(tmpIn,"POINTS","\n");
for p in Points do
AppendTo(tmpIn,1);
    for i in [1..Dim] do
    AppendTo(tmpIn," ",p[i]);
    od;
AppendTo(tmpIn,"\n");
od;


################# HULL CALCULATED ###################################


Exec(Concatenation(POLYMAKE_PATH,tmpIn ," VISUAL"));

#Exec(Concatenation("rm ",tmpIn));

end);
#####################################################################
#####################################################################