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
|
#RT:=0;
###################################################
###################################################
InstallGlobalFunction(PersistentBettiNumbersViaContractions,
function(arg)
local F,N,p,n, W, L, E, chnmap, cwmap, map, ln, k, f, homs,bool;
N:=arg[2];
p:=arg[3];
if Length(arg)=4 then bool:=true; else bool:=false; fi;
if not (IsInt(N) or IsList(N)) then return fail; fi;
if IsInt(N) then n:=N; fi;
F:=arg[1];
ln:=EvaluateProperty(F,"filtration_length");
W:=[];
for k in [1..ln] do
Add(W,FiltrationTerm(F,k));
od;
L:=[];
for k in [1..ln-1] do
map:=function(n,i); return i; end;
cwmap:=Objectify( HapRegularCWMap,
rec(
source:=W[k],
target:=W[k+1],
mapping:=map));
Add(L,ChainMapOfRegularCWMap(cwmap));
od;
E:=[];
for k in [1..ln] do
Add(E,ChainComplexEquivalenceOfRegularCWComplex(W[k]));
od;
if IsInt(N) then
homs:=[];
for k in [1..ln-1] do
f:=Compose( E[k+1][1], Compose(L[k],E[k][2]) );
Add(homs,HomologyVectorSpace(TensorWithIntegersModP(f,p),n));
od;
if bool then return homs; fi;
return LinearHomomorphismsPersistenceMat(homs);
fi;
homs:=[];
for n in N do
homs[n+1]:=[];
od;
N:=SortedList(N);
for k in [1..ln-1] do
f:=Compose( E[k+1][1], Compose(L[k],E[k][2]) );
for n in N do
#RT:=0-Runtime();
Add(homs[n+1],HomologyVectorSpace(TensorWithIntegersModP(f,p),n));
#RT:=RT+Runtime(); Print([k,n,RT],"\n");
od;
od;
if bool then return homs; fi;
homs:=List(N,n-> LinearHomomorphismsPersistenceMat(homs[n+1]) );
return homs;
end);
###################################################
###################################################
|