Skip to content

Commit

Permalink
hookified complex of a list or hash table
Browse files Browse the repository at this point in the history
  • Loading branch information
mahrud committed Jun 2, 2024
1 parent efc62be commit 8d26a31
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 38 deletions.
2 changes: 2 additions & 0 deletions checkins
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Mahrud

2 changes: 2 additions & 0 deletions packages/Complexes.m2
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export {
"UseTarget"
}

importFrom_Core "tryHooks"

-- keys into the type `Complex`
protect modules

Expand Down
4 changes: 2 additions & 2 deletions packages/Complexes/ChainComplex.m2
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ max Complex := ZZ => C -> max concentration C
min Complex := ZZ => C -> min concentration C

complex = method(Options => {Base=>0})
complex HashTable := Complex => opts -> tryHooks((complex, HashTable), (opts, maps), (opts, maps) -> (
complex HashTable := Complex => opts -> maps -> tryHooks((complex, HashTable), (opts, maps), (opts, maps) -> (
spots := sort keys maps;
if #spots === 0 then
error "expected at least one matrix";
Expand All @@ -80,7 +80,7 @@ complex HashTable := Complex => opts -> tryHooks((complex, HashTable), (opts, ma
C.dd = map(C,C,maps,Degree=>-1);
C
))
complex List := Complex => opts -> tryHooks((complex, List), (opts, L), (opts, L) -> (
complex List := Complex => opts -> L -> tryHooks((complex, List), (opts, L), (opts, L) -> (
-- L is a list of matrices or a list of modules
if not instance(opts.Base, ZZ) then
error "expected Base to be an integer";
Expand Down
10 changes: 5 additions & 5 deletions packages/Varieties.m2
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ importFrom_Core {
"applyMethod", "applyMethod''", "functorArgs",
"toString'", "expressionValue", "unhold", -- TODO: prune these
"concatRows", "concatCols",
"tryHooks", "cacheHooks",
"addHook", "tryHooks", "cacheHooks",
"BinaryPowerMethod",
}

Expand Down Expand Up @@ -880,10 +880,10 @@ end--

uninstallPackage "Varieties"
restart
loadPackage("Truncations", FileName => currentDirectory() | "Truncations.m2", Reload => true)
loadPackage("Complexes", FileName => currentDirectory() | "Complexes.m2", Reload => true)
installPackage("Varieties", FileName => currentDirectory() | "Varieties.m2")
installPackage "Varieties"
loadPackage("Truncations", FileName => currentDirectory() | "Truncations.m2", Reload => true)
loadPackage("Complexes", FileName => currentDirectory() | "Complexes.m2", Reload => true)
loadPackage("Varieties", FileName => currentDirectory() | "Varieties.m2", Reload => true)
installPackage("Varieties", FileName => currentDirectory() | "Varieties.m2")
viewHelp "Varieties"

restart
Expand Down
40 changes: 9 additions & 31 deletions packages/Varieties/SheafComplexes.m2
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
-- override the complex to work with sheaves, already defined in Complexes
complex HashTable := Complex => opts -> maps -> (
addHook((complex, HashTable), Strategy => "sheaves", (opts, maps) -> (
spots := sort keys maps;
if #spots === 0 then
error "expected at least one matrix";
if not all(spots, k -> instance(k,ZZ)) then
error "expected matrices to be labelled by integers";
if not all(spots, k -> instance(maps#k, SheafMap)) then
error "expected hash table or list of matrices";
if not all(spots, k -> instance(maps#k, SheafMap)) then return null;
--
R := ring maps#(spots#0);
if not all(values maps, f -> ring f === R) then
error "expected all matrices to be over the same ring";
Expand All @@ -24,42 +24,20 @@ complex HashTable := Complex => opts -> maps -> (
};
C.dd = map(C,C,maps,Degree=>-1);
C
)
complex List := Complex => opts -> L -> (
-- L is a list of matrices or a list of modules
))
addHook((complex, List), Strategy => "sheaves", (opts, L) -> (
-- L is a list of sheaf maps or a list of coherent sheaves
if not instance(opts.Base, ZZ) then
error "expected Base to be an integer";
if all(L, ell -> instance(ell, SheafMap)) then (
mapHash := hashTable for i from 0 to #L-1 list opts.Base+i+1 => L#i;
return complex(mapHash, opts)
);
-- if all(L, ell -> instance(ell,Module)) then (
-- R := ring L#0;
-- if any(L, ell -> ring ell =!= R) then
-- error "expected modules all over the same ring";
-- moduleHash := hashTable for i from 0 to #L-1 list opts.Base + i => L#i;
-- C := new Complex from {
-- symbol ring => R,
-- symbol concentration => (opts.Base, opts.Base + #L - 1),
-- symbol module => moduleHash,
-- symbol cache => new CacheTable
-- };
-- C.dd = map(C,C,0,Degree=>-1);
-- return C;
-- );
error "expected a list of matrices or a list of modules";
)


-- first, try to use the complex methods in Complex, then revert to the above
addHook((complex, HashTable), Strategy => Default, maps -> if all(sort keys maps, k -> instance(maps#k, SheafMap)) then complex maps )
if not all(L, ell -> instance(ell, SheafMap)) then return null;
mapHash := hashTable for i from 0 to #L-1 list opts.Base+i+1 => L#i;
complex(mapHash, opts)))

sheaf Complex := Complex => C -> (
(lo,hi) := concentration C;
complex for i from lo+1 to hi list sheaf C.dd_i
)


-*
map(Complex, Complex, HashTable) := ComplexMap => opts -> (tar, src, maps) -> (
R := ring tar;
Expand Down

0 comments on commit 8d26a31

Please sign in to comment.