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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
|
###############################################################
###############################################################
InstallGlobalFunction(EilenbergMacLaneSimplicialFreeAbelianGroup,
function(G,n,m)
local K, L, VectorToWord, M, D, i, j, dimension, boundary, degeneracy,
MFUN, DFUN;
K:=EilenbergMacLaneSimplicialGroup(G,n,m);;
L:=List([0..m],i->K!.groupsList(i));
L:=List(L,AbelianInvariants);
L:=List(L,Length);
###################################
VectorToWord:=function(v)
local w,i;
w:=[];
for i in [1..Length(v)] do
if not v[i]=0 then Add(w,[i,v[i]]); fi;
od;
return w;
end;
###################################
M:=[];;
for i in [1..m] do
MFUN:=function(i);
M[i]:=[];
for j in [0..i] do
M[i][j+1]:=K!.boundariesList(i,j);
M[i][j+1]:=M[i][j+1]!.MappingGeneratorsImages[2];
M[i][j+1]:=StructuralCopy(M[i][j+1]);
M[i][j+1]:=List(M[i][j+1],Exponents);
M[i][j+1]:=List(M[i][j+1],v->VectorToWord(v));
od;
end;
#MFUN(i);
od;
D:=[];;
for i in [1..m] do #so we are in degree i-1
DFUN:=function(i);
D[i]:=[];
if L[i]>0 then
for j in [0..i-1] do
D[i][j+1]:=K!.degeneraciesList(i-1,j);
D[i][j+1]:=D[i][j+1]!.MappingGeneratorsImages[2];
D[i][j+1]:=StructuralCopy(D[i][j+1]);
D[i][j+1]:=List(D[i][j+1],Exponents);
D[i][j+1]:=List(D[i][j+1],v->VectorToWord(v));
od;
fi;
end;
#DFUN(i);
od;
#####################################
dimension:=function(n);
if n<0 or n>Length(L)-1 then return 0; fi;
return L[n+1];
end;
#####################################
#####################################
boundary:=function(n,j,k); #degree n, boundary map j, generator k
if n<1 or n>Length(L)-1 then return []; fi;
if not IsBound(M[n]) then MFUN(n); fi;
return 1*M[n][j+1][k];
end;
#####################################
#####################################
degeneracy:=function(n,j,k); #degree n, degeneracy map j, generator k
if n<0 or n>Length(L)-2 then return []; fi;
if not IsBound(D[n+1]) then DFUN(n+1); fi;
return 1*D[n+1][j+1][k];
end;
#####################################
return
Objectify(HapSimplicialFreeAbelianGroup,
rec(
dimension:=dimension,
boundary:=boundary,
degeneracy:=degeneracy,
properties:=
[["length",m],
["moorecomplexlength",n],
["type", "simplicialFreeAbelianGroup"],
["characteristic", 0 ] ]));
end);
###############################################################
###############################################################
###############################################################
###############################################################
InstallGlobalFunction(E1HomologyPage,
function(K,q,l)
local dimension, boundary, facemap, negativefacemap,properties, bases, dims, len, BoundRec, degs, x, y, i, n, newbases, newdims;
len:=Minimum(EvaluateProperty(K,"length") , l);
bases:=[];
dims:=[];
BoundRec:=[];
for n in [0..len] do
dims[n+1]:=NrCombinations([1..K!.dimension(n)],q);
bases[n+1]:=Combinations([1..K!.dimension(n)],q) ;
BoundRec[n+1]:=[];
od;
#################################################
############### WARNING: THIS IS ONLY VALID FOR E-M COMPLEXES!!!!
newbases:=[];
newdims:=[];
newbases[1]:=bases[1];
newdims[1]:=dims[1];
for n in [1..len] do
degs:=[];
for x in bases[n] do
for i in [0..n-1] do
y:=List(x,k->K!.degeneracy(n-1,i,k)[1][1]);
y:=SSortedList(y);
Add(degs,y);
od;
od;
degs:=SSortedList(degs);
newbases[n+1]:=Difference(bases[n+1],degs);
newbases[n+1]:=SSortedList(newbases[n+1]);
newdims[n+1]:=Length(newbases[n+1]);
od;
bases:=newbases;
dims:=newdims;
################ WARNING: FINISHED
###########################################
###########################
dimension:=function(n)
local p;
if n>len or n<0 then return 0; fi;
return dims[n+1];
end;
###########################
facemap:=function(n,i,k)
local c,d,F,newF,x,y,yy,j,m,s, z,ans,pos;
c:=bases[n+1][k];
d:=[];
for x in c do
y:=K!.boundary(n,i,x);
yy:=[];
for z in y do
s:=SignInt(z[2]);
for j in [1..AbsInt(z[2])] do
Add(yy,[z[1],s]);
od;
od;
Unbind(y);
Add(d,yy);
od;
d:=Cartesian(d);
ans:=[];
for y in d do
s:=Product(List(y,a->a[2]));
y:=List(y,a->a[1]);
yy:=y;
y:=SortedList(y);
#RT:=RT-Runtime(); #THIS TAKES A CRAZY AMOUNT OF TIME USING POSITION()
pos:=PositionSorted(bases[n],y);
if IsBound(bases[n][pos]) then
if not bases[n][pos]=y then pos:=fail; fi;
else pos:=fail;
fi;
#RT:=RT+Runtime();
if not pos=fail then
yy:=List(yy,i->PositionSorted(y,i));
s:=s*SignPerm(PermList(yy));
Add(ans, [pos,s]);
fi;
od;
return ans;
end;
###########################
negativefacemap:=function(n,i,k)
local ans;
ans:=facemap(n,i,k);
ans:=List(ans,x->[x[1],-x[2]]);
return ans;
end;
###########################
boundary:=function(n,k)
local b, i;
if not IsBound(BoundRec[n+1][k]) then
b:=[];
for i in [0..n] do
if IsEvenInt(i) then Append(b,facemap(n,i,k));
else Append(b,negativefacemap(n,i,k)); fi;
od;
BoundRec[n+1][k]:=b;
fi;
return BoundRec[n+1][k];
end;
###########################
return
Objectify(HapSparseChainComplex,
rec(
dimension:=dimension,
boundary:=boundary,
bases:=bases,
properties:=
[["length",EvaluateProperty(K,"length")],
["connected",true],
["type", "chainComplex"],
["characteristic", 0] ]));
end);
###############################################################
###############################################################
###############################################################
###############################################################
InstallGlobalFunction(HomologySimplicialFreeAbelianGroup,
function(K,n)
local p, q, H, D, ans, mlen, bool;
bool:=false;
if n<0 then return []; fi;
if n=0 then return [0]; fi;
mlen:=EvaluateProperty(K,"moorecomplexlength");
ans:=[];
for p in [0..n-1] do
q:=n-p;
if p<=q*mlen then
if p+1>EvaluateProperty(K,"length") then bool:=true; fi;
D:=ContractedComplex(E1HomologyPage(K,q,p+1));
H:= Homology(D,p) ;
if Length(H)>0 then
Append(ans,H);
fi;
fi;
od;
#if n>=EvaluateProperty(K,"length") then
if bool then
Print("WARNING: The computed answer is guaranteed only to be a summand of the correct answer. You'll need to use more terms of the simplicial abelian group to make sure there is no other summand.\n");
fi;
return ans;
end);
###############################################################
###############################################################
#####################################################################
InstallOtherMethod(Homology,
"integral homology of simplicial free abelian group",
[IsHapSimplicialFreeAbelianGroup,IsInt],
function(K,n) return HomologySimplicialFreeAbelianGroup(K,n);
end);
#####################################################################
|