From 8d26a31cd0b6520318be9784aab7d10e25262548 Mon Sep 17 00:00:00 2001 From: Mahrud Sayrafi Date: Sun, 2 Jun 2024 16:30:44 -0600 Subject: [PATCH] hookified complex of a list or hash table --- checkins | 2 ++ packages/Complexes.m2 | 2 ++ packages/Complexes/ChainComplex.m2 | 4 +-- packages/Varieties.m2 | 10 +++---- packages/Varieties/SheafComplexes.m2 | 40 +++++++--------------------- 5 files changed, 20 insertions(+), 38 deletions(-) create mode 100644 checkins diff --git a/checkins b/checkins new file mode 100644 index 0000000..b30a8e6 --- /dev/null +++ b/checkins @@ -0,0 +1,2 @@ +Mahrud + diff --git a/packages/Complexes.m2 b/packages/Complexes.m2 index 8d25be1..2987d9c 100644 --- a/packages/Complexes.m2 +++ b/packages/Complexes.m2 @@ -69,6 +69,8 @@ export { "UseTarget" } +importFrom_Core "tryHooks" + -- keys into the type `Complex` protect modules diff --git a/packages/Complexes/ChainComplex.m2 b/packages/Complexes/ChainComplex.m2 index 1f7ac09..3ea0e8d 100644 --- a/packages/Complexes/ChainComplex.m2 +++ b/packages/Complexes/ChainComplex.m2 @@ -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"; @@ -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"; diff --git a/packages/Varieties.m2 b/packages/Varieties.m2 index e071f0d..0b99860 100644 --- a/packages/Varieties.m2 +++ b/packages/Varieties.m2 @@ -81,7 +81,7 @@ importFrom_Core { "applyMethod", "applyMethod''", "functorArgs", "toString'", "expressionValue", "unhold", -- TODO: prune these "concatRows", "concatCols", - "tryHooks", "cacheHooks", + "addHook", "tryHooks", "cacheHooks", "BinaryPowerMethod", } @@ -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 diff --git a/packages/Varieties/SheafComplexes.m2 b/packages/Varieties/SheafComplexes.m2 index ff9f41e..441a9ab 100644 --- a/packages/Varieties/SheafComplexes.m2 +++ b/packages/Varieties/SheafComplexes.m2 @@ -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"; @@ -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;