File: simpprod.gi

package info (click to toggle)
gap-hap 1.73%2Bds-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 58,508 kB
  • sloc: xml: 16,467; sh: 197; javascript: 155; makefile: 121; ansic: 47; perl: 24
file content (83 lines) | stat: -rw-r--r-- 1,707 bytes parent folder | download
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
###############################################
###############################################
InstallGlobalFunction(DirectProductOfSimplicialComplexes,
function(K,L)
local vertices, ProdSimplices, F, FK, FL,x,y;

vertices:=Cartesian(K!.vertices,L!.vertices);
FK:=MaximalSimplicesOfSimplicialComplex(K);
FL:=MaximalSimplicesOfSimplicialComplex(L);
F:=[];

########################################
ProdSimplices:=function(a,b)
local dim,la,lb,ca,cb,ea,eb,x,y,i,j,expa,expb,pair2simp,ans;

la:=Length(a);
lb:=Length(b);
dim:=la+lb-1;
ca:=Combinations([2..dim],la-1);
cb:=Combinations([2..dim],lb-1);
expa:=[];
expb:=[];

for x in ca do
ea:=List([1..x[1]-1],i->a[1]);
for i in [1..la-2] do    
for j in [x[i]..x[i+1]-1] do  
ea[j]:=a[i+1];
od;
for j in [x[la-1]..dim] do
ea[j]:=a[la];
od;
od;
while Length(ea)<dim do Add(ea,a[la]); od;  ## April 2025 (for 1-simplices)
Add(expa,ea);
od;


for x in cb do
eb:=List([1..x[1]-1],i->b[1]);
for i in [1..lb-2] do  
for j in [x[i]..x[i+1]-1] do  
eb[j]:=b[i+1];
od;
for j in [x[lb-1]..dim] do
eb[j]:=b[lb];
od;
od;
while Length(eb)<dim do Add(eb,b[lb]); od;  ## April 2025 (for 1-simplices)
Add(expb,eb);
od;

#######################
pair2simp:=function(v,w)
return List([1..Length(v)], k-> Position(vertices,[v[k],w[k]]));
end;
#######################

ans:=[];
for x in expa do
for y in expb do
Add(ans,pair2simp(x,y));
od;od;

ans:=Filtered(ans,x->Length(x)=Length(SSortedList(x)));

return ans;
end;
########################################

for x in FK do
for y in FL do
Append(F,ProdSimplices(x,y));
od;od;

return SimplicialComplex(F);;
end);
######################################################
######################################################
#
#