{Display => "picture", Verbose => false})
--There are no maps eagonBeta(E,0) or eagonBeta(E,1); the display starts with eagonBeta(E,2).
eagonBeta(EagonData, ZZ) := o -> (E,n) -> (
if o.Display == "picture" then
picture(E#{"eagonBeta",n,0},Verbose => o.Verbose)
else if o.Display == "DisplayBlocks" then
displayBlocks E#{"eagonBeta",n,0}
else
E#{"eagonBeta",n,0}
)
eagonBeta EagonData := List => o-> E -> (
b := max apply(select(keys E, k-> k_0 === 0 and k_2 === 0), k->k_1);
netList apply(b-1, n -> eagonBeta(E,n+2,Display => o.Display, Verbose => o.Verbose))
)
extractBlocks = method()
extractBlocks(Matrix, List) := Matrix => (phi, L) -> (
--the map map(target phi, source phi, phi_[L]*(source phi)^[L], where L is a list
--of integers representing blocks in source phi.
phi1 := flattenBlocks phi;
src := source phi1;
ind := indices src;
sum(L, i->phi1_[ind_i]*src^[ind_i])
)
--eagonResolution--
eagonResolution = method()
eagonResolution EagonData := ChainComplex => E ->(
b := max apply( select(keys E, k-> k_0 === 0 and k_2 === 0), k->k_1);
chainComplex(apply(b,n->E#{"dHor",n+1,0}))
)
eagonResolution(Ring,ZZ) := ChainComplex => (R,b) ->(
eagonResolution eagon(R,b)
)
resolution EagonData := opts->E -> eagonResolution E
--res--
--resolution--
///
restart
loadPackage("EagonResolution", Reload=>true)
S = ZZ/101[a,b,c]
I = ideal"a3,b3,c3"
R = S/I
E = eagon(R,6)
eagonResolution E -- works
--resolution EagonData := E -> eagonResolution E
resolution E -- fails
eagonResolution E
res R.cache.EagonData
eagonResolution E
///
eagonSymbols = method()
eagonSymbols(ZZ,ZZ) := List => (n,i) ->(
--symbol of the module Y^n_i, as a list of pairs, defined inductively from n-1,i+1 and n-1,0
--assumes large number of vars and pd.
if n === 0 then return {(i,{})};
if i === 0 then return eagonSymbols(n-1,1);
e' := eagonSymbols (n-1,0);
e'1 := apply (e', L -> L_1|{i});
eagonSymbols(n-1,i+1)|apply (#e', j-> (e'_j_0,e'1_j))
)
componentsAndIndices = (F) -> (
if not F.cache.?components then (
-- F has no components
({F}, {null})
)
else if #F.cache.components == 1 then (
if F.cache.?indices then
({F}, F.cache.indices)
else
({F}, {null})
)
else (
a := for f in F.cache.components list componentsAndIndices f;
(flatten(a/first), flatten(a/last))
)
)
flattenBlocks = method()
flattenBlocks Module := (F) -> (
if not isFreeModule F then error "expected a free module";
(comps, inds) := componentsAndIndices F;
compsLabelled := for i from 0 to #comps-1 list (
inds#i => comps#i
);
directSum compsLabelled
)
flattenBlocks Matrix := (M) -> (
F := flattenBlocks target M;
G := flattenBlocks source M;
map(F,G,matrix M)
)
--displayBlocks--
displayBlocks = method()
displayBlocks Matrix := (M1) -> (
M := flattenBlocks M1;
src := select(indices source M, i-> i =!= null);
tar := select(indices target M, i-> i =!= null);
netList (prepend(
prepend("", src),
for t in tar list prepend(t, for s in src list (
mts := M^[t]_[s];
h := if mts == 0 then "." else if (numrows mts == numcols mts and mts == 1) then "1" else net mts
))
), Alignment=>Center)
)
displayBlocks ChainComplex := List => C -> apply(length C, i -> displayBlocks(C.dd_(i+1)))
displayBlocks EagonData := List => E -> displayBlocks eagonResolution E
--pictureList--
pictureList = method(Options => {Verbose => false, Display => "picture", Transpose => false})
pictureList Matrix := o -> (M1) -> (
M := flattenBlocks M1;
src := indices source M;
tar := indices target M;
kkk := ring M/(ideal gens ring M);
L := prepend(
prepend("", src),
for t in tar list prepend(t, for s in src list (
mts := M^[t]_[s];
nums := toString(numrows mts,numcols mts);
cont := ideal M^[t]_[s];
if o.Verbose == false then (
h := if mts == 0 then
"."
else if (numrows mts == numcols mts and mts == 1) then
"id"
else if cont == ideal(1_(ring mts)) then
toString numrows M^[t]_[s]|","|toString rank(kkk**M^[t]_[s])
else "*"
)
else (
h = if mts == 0 then
nums|" ."
else if (numrows mts == numcols mts and mts == 1) then
nums|" id"
else if cont == ideal(1_(ring mts)) then
nums|","|toString rank(kkk**M^[t]_[s])
else "*"
)
)));
if o.Transpose then transpose L else L
)
pictureList ChainComplex := List => o -> C -> apply(length C, i-> pictureList(C.dd_(i+1), o))
pictureList EagonData := List => o -> E -> pictureList (eagonResolution E, o)
--picture--
picture = method(Options => options pictureList)
picture Matrix := o -> (M1) -> (
if o.Display === "DisplayBlocks" then return displayBlocks M1;
netList (pictureList(M1,o), Alignment => Center)
)
picture ChainComplex := Net => o -> C -> netList apply(length C, i-> picture(C.dd_(i+1), o))
picture EagonData := Net => o -> E -> picture (eagonResolution E, o)
--mapComponent--
mapComponent = method()
mapComponent(Matrix, Sequence, Sequence) := Matrix => (M,tar,src) -> (
--Matrix should be one with labeled components, such as produced by
--E = eagon(R,n)
--M = E#{"dVert",4,1}
--or
--M = (eagonResolution(R,n)).dd_4
M1 := flattenBlocks M;
--use "member" and "componentsAndIndices" to check reasonableness? or try evaluating and catch error.
try (M2 := M1^[tar]_[src]) then
M2
else (
<