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 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
|
#(C) Graham Ellis, 2005-2006
#RT:=0;
#####################################################################
InstallGlobalFunction(IntegralHomology,
function(X,n)
local
Homology_Obj,
Homology_Arr,
HomologyAsFpGroup, xx;
#####################################################################
#####################################################################
Homology_Obj:=function(C,n)
local
M1, M2,
dim,
BasisKerd1, BasisImaged2, BasisKerd1cp, BasisImaged2cp,
Rels, Smith, TorsionCoefficients,
Dimension, Boundary,
i;
if n <0 then return false; fi;
Dimension:=C!.dimension;
Boundary:=C!.boundary;
########################
if n=0 or Dimension(n-1)=0 then #CHANGED March 2023
BasisKerd1:=IdentityMat(Dimension(n));
else
M1:=[];
for i in [1..Dimension(n)] do
M1[i]:=Boundary(n,i);
od;
ConvertToMatrixRep(M1);
BasisKerd1:=LLLReducedBasis(M1,"linearcomb").relations;
M1:=0;
fi;
#######################
M2:=[];
for i in [1..Dimension(n+1)] do
M2[i]:=Boundary(n+1,i);
od;
ConvertToMatrixRep(M2);
if M2=[[]] then BasisImaged2:=[]; else
BasisImaged2:=BaseIntMat(M2); fi; #CHANGED 2023
dim:=Length(BasisImaged2);
M2:=0;
BasisImaged2:=MutableCopyMat(List([1..dim],i->BasisImaged2[i]));
#!!!!!!!!!!!!!!!CHANGE IT
if Length(BasisImaged2)>0 then
Rels:=SolutionsMatDestructive(BasisKerd1, BasisImaged2);
else
Rels:=[];
fi;
Smith:= SmithNormalFormIntegerMat(Rels);
TorsionCoefficients:=[];
for i in [1..Length(BasisKerd1)] do
if i<=Length(Smith) then
TorsionCoefficients[i]:=Smith[i][i];
else
TorsionCoefficients[i]:=0;
fi;
od;
return rec(
torsionCoefficients:=Filtered(TorsionCoefficients, i-> not (i=1)),
rels:=Rels,
basisKerd1:=BasisKerd1);
end;
#####################################################################
#####################################################################
#####################################################################
#####################################################################
HomologyAsFpGroup:=function(C,n)
local
F, H, HH, HHhomH, nn, expH,
Rels, Fgens, FhomFH, FHhomH, FhomH,
FH, Frels, Hgens, FHgens, IHC, HhomC, ChomH,
Vector2Word, BasisKerd1, rel, i, j, Htmp,HtmphomH,
sem, z1,sol1,lngm , epim;
if not "fpIntHom" in NamesOfComponents(C) then
C!.fpIntHom:=[1..1000]; #SLOPPPY! Some one might ask for
#the 1000-dimensional homology
fi;
if n=0 then nn:=1000; else nn:=n; fi;
if IsInt(C!.fpIntHom[nn]) then
IHC:=Homology_Obj(C,n);
BasisKerd1:=IHC.basisKerd1;
Rels:=IHC.rels;
if Length(IHC.torsionCoefficients)>0 then #changed August 2017
expH:=Lcm(IHC.torsionCoefficients);
else expH:=0;
fi;
F:=FreeGroup(Length(BasisKerd1));
Fgens:=GeneratorsOfGroup(F);
Frels:=[];
#####################################################################
Vector2Word:=function(rel)
local w,i;
w:=Identity(F);
for i in [1..Length(Fgens)] do
w:=w*Fgens[i]^rel[i];
od;
return w;
end;
#####################################################################
for rel in Rels do
Append(Frels,[Vector2Word(rel)]);
od;
################################# #Should make "abelian groups"
for i in [1..Length(Fgens)] do #type in GAP
for j in [i..Length(Fgens)] do
Append(Frels,[Fgens[i]*Fgens[j]*Fgens[i]^-1*Fgens[j]^-1]);
od;
od;
FH:=F/Frels;
FHgens:=GeneratorsOfGroup(FH);
#if 0 in AbelianInvariants(FH) then
FHhomH:=NqEpimorphismNilpotentQuotient(FH,1);
#else
#FHhomH:=EpimorphismNilpotentQuotient(FH); #Commented out 20 June 2018
#fi;
H:=Range(FHhomH);
Hgens:=GeneratorsOfGroup(H);
################################
epim:=EpimorphismFromFreeGroup(FH);
#####################################################################
HhomC:=function(w)
local ww,v,i,s;
ww:=PreImagesRepresentative(FHhomH,Hgens[w]);
ww:=PreImagesRepresentative(epim,ww);
v:=BasisKerd1[1]*0;
for i in [1..Length(BasisKerd1)] do
s:=ExponentSumWord(ww,PreImagesRepresentative(epim,FHgens[i]));
v:=v+s*BasisKerd1[i];
od;
return v ;
end;
#####################################################################
if Length(BasisKerd1)=0 then
#####################################################################
ChomH:=function(v) #Am I sure about this fix?
return Identity(H);
end;
#####################################################################
else
z1 := Zero(BasisKerd1[1][1]);
sol1:=ListWithIdenticalEntries(Length(BasisKerd1),z1);
lngm:=Length(BasisKerd1[1]);
sem := SemiEchelonMatTransformationDestructive(1*BasisKerd1);
#####################################################################
ChomH:=function(v)
local w,i,xx, vno, z,x, row, ncols,sol,vec,solmat;
### thenw:=SolutionMat(BasisKerd1,v) mod expH;
ncols := Length(BasisKerd1[1]);
vec:=v;
z := StructuralCopy(z1);
sol := StructuralCopy(sol1);
ConvertToVectorRepNC(sol);
for i in [1..ncols] do
vno := sem.heads[i];
if vno <> 0 then
x := vec[i];
if x <> z then
AddRowVector(vec, sem.vectors[vno], -x);
AddRowVector(sol, sem.coeffs[vno], x);
fi;
fi;
od;
if expH>0 then sol:=sol mod expH; fi;
xx:=Identity(H);
for i in [1..Length(FHgens)] do
xx:=xx*Image(FHhomH,FHgens[i])^sol[i];
od;
return xx;
end;
#####################################################################
fi;
C!.fpIntHom[nn]:=rec(
fpgroup:=H,
h2c:=HhomC,
c2h:=ChomH );
fi;
return C!.fpIntHom[nn];
end;
#####################################################################
#####################################################################
#####################################################################
#####################################################################
Homology_Arr:=function(f,n)
local
C,D,ChomD,
HC, HChomC, ChomHC, IHC,
HD, HDhomD, DhomHD, IHD,
HChomHD, gensHC, imageGensHC,
x;
C:=f!.source;
D:=f!.target;
#################################### ADDED MARCH 2023
if C!.dimension(n)=0 then
HC:=FreeGroup(0);
fi;
if D!.dimension(n)=0 then
HD:=FreeGroup(0);
fi;
if IsBound(HC) and not IsBound(HD) then
HD:=HomologyAsFpGroup(D); #NEED TO FIX THIS
fi;
if IsBound(HD) and not IsBound(HC) then
HC:=HomologyAsFpGroup(D); #AND THIS
fi;
if IsBound(HC) and IsBound(HD) then return
GroupHomomorphismByFunction(HC,HD,x->x);
fi;
####################################
ChomD:=f!.mapping;
IHC:=HomologyAsFpGroup(C,n);
HC:=IHC.fpgroup;
gensHC:=GeneratorsOfGroup(HC);
HChomC:=IHC.h2c;
ChomHC:=IHC.c2h;
IHD:=HomologyAsFpGroup(D,n);
HD:=IHD.fpgroup;
HDhomD:=IHD.h2c;
DhomHD:=IHD.c2h;
imageGensHC:=[];
for x in [1..Length(gensHC)] do
Append(imageGensHC,[ DhomHD(ChomD(HChomC(x),n)) ] );
od;
HChomHD:=GroupHomomorphismByImagesNC(HC,HD,gensHC,imageGensHC);
return HChomHD;
end;
#####################################################################
#####################################################################
if X="HomologyAsFpGroup" then return HomologyAsFpGroup; fi;
if not EvaluateProperty(X,"characteristic")=0 then
Print("ERROR: There is an inconsitency with characteristic of Z. \n");
return fail; fi;
if EvaluateProperty(X,"type")="chainComplex" then
xx:=IntegralHomologyOfChainComplex(X,n);
return xx; fi;
if EvaluateProperty(X,"type")="chainMap" then
xx:=Homology_Arr(X,n);
return xx; fi;
Print("ERROR: Input should be a chain complex or chain map.\n");
end );
|