Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to Simplicial Toric Varieties #3582

Open
wants to merge 227 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
227 commits
Select commit Hold shift + click to select a range
165b363
added hook for non-free maps in quotient & quotient'
mahrud Apr 24, 2024
2331a04
commented a few methods of \\
mahrud Apr 25, 2024
67e2a49
updated docs for quotient and quotient'
mahrud Apr 25, 2024
cd6b0b9
changed BettiCharacters to use left factorization via \\
mahrud Apr 29, 2024
c842e52
fixed a test based on the augmented form of \\
mahrud Apr 30, 2024
a664af1
added tests for quotient' for non-free maps
mahrud May 10, 2024
fececd7
separated ZZ and InexactField strategies for (quotient, Matrix, Matrix)
mahrud May 21, 2024
2d96ad6
added slight optimization for quotient and quotient'
mahrud May 21, 2024
65b995d
added length limits for connectingExtMap
Devlin-Mallory Mar 27, 2024
dbc0c9d
added method for truncating source of map more than target
mahrud Mar 1, 2022
2cabe60
fixed bug in prune for coherent sheaves on toric varieties
mahrud Mar 5, 2024
51d1710
cached the output of nefGenerators
mahrud Mar 5, 2024
88df62f
cached variety of a ring in R.variety
mahrud Feb 13, 2024
298966f
cached minimal presentation of SheafMap
mahrud Apr 4, 2024
30cda95
preserved components after sheafification
mahrud Mar 6, 2024
af50a3c
added check that rings of projective varieties are standard graded
mahrud Feb 13, 2024
95c08e4
added extra constructors for SheafMap
mahrud Apr 4, 2024
58f4486
added isIsomorphic for CoherentSheaf and SheafMap
mahrud Jan 29, 2024
8fa584c
changed "isIsomorphic" to prune rather than truncate, as discussed today
Devlin-Mallory Feb 28, 2024
07e08b1
added SheafMap == SheafMap
mahrud Jan 29, 2024
0544a67
improved global Ext of sheaves
mahrud Feb 8, 2024
182494a
avoided minimization of truncations for sheaf map algorithms
mahrud Feb 8, 2024
0f51b3a
added Complexes to dependencies of Varieties
mahrud Oct 15, 2024
8a73de9
added yonedaSheafExtension
mahrud Feb 8, 2024
040acc0
changed sheaf map composition, SheafMap == ZZ, and started connecting
Devlin-Mallory Feb 28, 2024
225f94f
added concatenation (| and ||) for sheaf maps
Devlin-Mallory Feb 28, 2024
d2b2c2e
fixed composition, homology, homomorphism, symmetricPower
Devlin-Mallory Mar 6, 2024
0a666ec
moved sheaf map tests to tests-maps.m2
mahrud Apr 4, 2024
1035eb4
added test for isIsomorphism with timing
mahrud Mar 9, 2024
b1c0360
reverted to the previous isIsomorphic code
mahrud Mar 9, 2024
7e65b01
added one to regularity for == and isIsomorphic
mahrud Apr 4, 2024
ac9c70f
minimalGenerators => false and added some tests
Devlin-Mallory Mar 13, 2024
4f50099
fixed an issue with pruning sheafMaps
Devlin-Mallory Mar 13, 2024
17e867c
first working connectingExtMap version + test
Devlin-Mallory Mar 20, 2024
2504128
added tests for consistent truncations
mahrud Mar 23, 2024
4fb7835
fixed bug in isWellDefined for inverse of sheaf maps
mahrud Oct 18, 2024
b4bcf4b
passed LengthLimit in connectingExtMap
mahrud Oct 18, 2024
1345d22
fixed some tests, removed bug we introduced in homology
Devlin-Mallory Mar 27, 2024
4413f1b
added ^** for Matrix and SheafMap and a non-working test
mahrud Apr 3, 2024
df52935
added (broken) potential fix for tensor
Devlin-Mallory Apr 3, 2024
ea05b6c
added twisted cubic test
mahrud Apr 4, 2024
fefa397
added basic arithmetic ops for SheafMap
mahrud Apr 4, 2024
33aedc5
added helper for truncating sheaf maps to common degree
mahrud Apr 4, 2024
192721b
fixed a test for connectingExtMap
mahrud Apr 4, 2024
bed38b4
fixed inducedMap for coherent sheaves and added a test
mahrud Apr 4, 2024
a627e5b
changed needs to load for package subfiles
mahrud Apr 4, 2024
2219ba1
fixed a bug in global Ext and set it to truncate
mahrud Apr 10, 2024
7523218
fixed the target sheaf in the SheafMap constructor
mahrud Apr 10, 2024
e7192b7
fixed == for SheafMap with conservative pruning
mahrud Apr 11, 2024
1fce076
fixed tensor of sheaf maps, with some caveats
mahrud Apr 11, 2024
0f0b809
fixed the source of dual SheafMap (but not target)
mahrud Apr 11, 2024
82ada31
added random(CoherentSheaf,CoherentSheaf)
mahrud Apr 11, 2024
8fa61cd
changed variety R to return Proj R if no variety is defined yet
mahrud Apr 11, 2024
85f9e3d
added sheaf Ideal which returns a coherent sheaf
mahrud Apr 11, 2024
b0e0d7e
replaced sheafMap with sheaf
mahrud Apr 24, 2024
3fc3704
added factoring of sheaf maps (f // g)
mahrud Apr 24, 2024
5e6de44
separated quotient and quotient' for sheaf maps
mahrud Apr 24, 2024
0433238
specified variety in calls to sheaf
mahrud Apr 25, 2024
a19ff6f
added sheafMap back with a deprecation warning
mahrud Apr 25, 2024
c4accf8
stashed the variety directly in sheaf maps
mahrud Apr 25, 2024
8386522
removed degree SheafMap
mahrud Feb 13, 2024
105d83c
fixed bug in isIsomorphic
mahrud May 2, 2024
398cad6
added exterior/symmetric powers of sheaf maps
mahrud May 2, 2024
8131f8a
added isLocallyFree CoherentSheaf
Devlin-Mallory May 1, 2024
94b51ce
added eulerSequence and cotangentSurjection
Devlin-Mallory May 1, 2024
966d16d
replaced M~ with M^~ for sheafification
mahrud May 8, 2024
a5227c9
added deprecation warning for ~
mahrud May 8, 2024
a32be1f
fixed tests broken by Complexes
mahrud Apr 28, 2024
857ed30
wip: added complexes of sheaves
mahrud Feb 8, 2024
78e3d96
wip: added yonedaSheafExtension'
mahrud Feb 8, 2024
176a296
wip: cache Hom info in target of homomorphism'
mahrud Apr 4, 2024
30e05ce
added embeddedToAbstract and tests
Devlin-Mallory May 8, 2024
7b224df
simplified subtruncate
mahrud Mar 1, 2022
4b47698
added benchmark test for prune
Devlin-Mallory May 11, 2024
b0ddcd5
added CoherentSheaf ? CoherentSheaf for sorting
mahrud May 15, 2024
fd2aa14
testing Keller's methods
Devlin-Mallory May 11, 2024
48d3936
first attempt at ExtLongExactSequence
Devlin-Mallory May 15, 2024
963e472
documented isProjective
mahrud May 15, 2024
9906355
added isSmooth(Variety)
mahrud May 15, 2024
6de5e9d
documented isSmooth(Variety)
mahrud May 15, 2024
631dbc0
documented AffineVariety ** AffineVariety
mahrud May 15, 2024
842df68
added doc stub for singularLocus of varieties
mahrud May 15, 2024
4874a69
added doc stub ambient for varieties
mahrud May 15, 2024
3aa2745
added doc stub for isWellDefined for varieties
mahrud May 15, 2024
3d54e24
added initial documentation nodes for SheafMap and constructors
mahrud May 16, 2024
ecf98b4
documented isWellDefined for coherent sheaves
mahrud May 16, 2024
63998fe
documented rank for coherent sheaves
mahrud May 16, 2024
91fd97e
documented degrees of a coherent sheaf
mahrud May 16, 2024
0879733
documented random for morphisms of coherent sheaves
mahrud May 16, 2024
fbc77c4
documented isWellDefined for morphisms of coherent sheaves
mahrud May 16, 2024
e93aeda
documented variety(SheafMap)
mahrud May 16, 2024
e5e8cbb
documented matrix(SheafMap)
mahrud May 16, 2024
29809e1
documented sheaf(Ideal)
mahrud May 16, 2024
2655a96
(un)documented arithmetic operations for sheaf maps
mahrud May 16, 2024
d3bb051
(un)documented some arithmetic methods for coherent sheaves
mahrud May 16, 2024
05bd772
documented stub for sheafHom of sheaf maps
mahrud May 16, 2024
617417f
documented sheaf(Variety,Ideal)
mahrud May 16, 2024
6d77383
documented stub for induced maps of sheaf maps
mahrud May 16, 2024
91fd86e
potential fix for concentration problems
Devlin-Mallory May 16, 2024
aa199c8
added isSurjective(SheafMap)
Devlin-Mallory May 16, 2024
bb3412e
split map and sheaf constructor of sheaf maps
mahrud May 17, 2024
6a5c33d
added documentation stub for canonicalBundle
mahrud May 17, 2024
3c213a3
moved the documentation of tangentSheaf
mahrud May 17, 2024
4cef3e5
moved the documentation of cotangentSheaf
mahrud May 17, 2024
73e5b76
added degree(SheafMap) as degree matrix phi
mahrud May 17, 2024
6afa0a2
changed synonym of SheafMap to lowercase
mahrud Oct 29, 2024
c7284fc
fixed pluralize for sheaves and varieties
mahrud May 17, 2024
203684c
used pluralsynonym in directSum
mahrud May 17, 2024
aa332c0
added applyUniformMethod for directSum and pullback/pushout
mahrud May 17, 2024
79948fc
added pullback/pushout for list of sheaf maps
mahrud May 17, 2024
f59f587
unexported isLiftable
mahrud May 17, 2024
d9312ad
added documentation stubs for special sheaf maps
mahrud May 17, 2024
3d89e4a
added an affine test and moved varieties tests
mahrud May 17, 2024
2c0f93f
expanded isLocallyFree
mahrud May 17, 2024
224928a
documented isLocallyFree
mahrud May 17, 2024
c2315c5
unexported TruncateDegree
mahrud May 17, 2024
5f8287f
added doc stub for prune(SheafMap)
mahrud May 17, 2024
079f02e
improved documentation of sheafHom
mahrud May 18, 2024
db34433
added helper 'syn' for documentation
mahrud May 20, 2024
0f40caa
improved docs for (Ext, ZZ, CoherentSheaf, SumOfTwists)
mahrud May 18, 2024
c298fe2
improved docs for (cohomology, ZZ, SheafOfRings)
mahrud May 20, 2024
19bbfd1
improved docs for (cohomology, ZZ, SumOfTwists)
mahrud May 20, 2024
421b4e1
improved docs for (cohomology, ZZ, CoherentSheaf)
mahrud May 20, 2024
1e75e66
improved docs for (Ext, ZZ, CoherentSheaf, CoherentSheaf)
mahrud May 20, 2024
a8ee82f
improved docs for (sheafExt, ZZ, CoherentSheaf, CoherentSheaf)
mahrud May 20, 2024
f660f09
improved docs for (hh, Sequence, ProjectiveVariety)
mahrud May 20, 2024
d5d81b4
improved docs for (Hom, CoherentSheaf, CoherentSheaf)
mahrud May 20, 2024
2a40156
added various doc stubs for Varieties
mahrud May 20, 2024
4a4a2f8
undocumented SheafExpression
mahrud May 20, 2024
9d0e8ec
fixed char ProjectiveVariety
Devlin-Mallory May 27, 2024
9456cb9
added test for saturation in char
Devlin-Mallory May 27, 2024
cd24fe3
hookified pdim CoherentSheaf
mahrud Dec 31, 2023
9bea366
added compatibility functions for 1.24.05
mahrud May 31, 2024
8346e33
added global assignment function for sheaves
mahrud Jun 5, 2024
8aa9040
fixed load paths in SheafMaps
mahrud May 31, 2024
b544647
added (sheaf, Complex)
kellerlv Jun 1, 2024
d450810
added miscellaneous fixes for complexes of sheaves
kellerlv Jun 1, 2024
664d07c
removed basis from Varieties
mahrud Jun 2, 2024
8e15e48
moved component of CoherentSheaf to Varieties
mahrud Jun 2, 2024
f36df51
connectingExtMap gives an error!
johndcobb Jun 2, 2024
04adbec
hookified complex of a list or hash table
johndcobb Jun 2, 2024
04bc838
fixed tensor of complexes of sheaves
johndcobb Jun 3, 2024
1fc8b24
removed hooks from Complexes
mahrud Jun 3, 2024
7b327be
added preliminary code for RHom
kellerlv Jun 3, 2024
24a3a3c
added global Ext of complex
kellerlv Jun 3, 2024
1c87781
simplified constructor of complexes
mahrud Jun 3, 2024
f5f03e9
reordered exports in Varieties
mahrud Jun 3, 2024
5ac589c
added Euler sequence as a test of sheaf complexes
mahrud Jun 3, 2024
f68ba7e
changed yonedaSheafExtension to return a complex
mahrud Jun 3, 2024
0768cbf
moved docs for eulerSequence and yonedaSheafExtension
mahrud Jun 3, 2024
2496427
added additional methods for RHom
kellerlv Jun 3, 2024
e92207f
added more sheafHom methods
johndcobb Jun 3, 2024
3d73a0a
fixed sheafHom of complexes
mahrud Jun 16, 2024
414bcf2
added (complex, CoherentSheaf)
mahrud Jun 3, 2024
1f23a40
simplified tensor of complexes of sheaves
mahrud Jun 3, 2024
e0d3a1b
added helper methods for maps of sheaves
johndcobb Jun 3, 2024
f6f522c
added potential fix for installPackage issue
mahrud Jun 3, 2024
56ab612
added more tests
DanielApsley Jun 3, 2024
81c8ce0
added to tests
kellerlv Jun 3, 2024
cd492ab
added idealSheaf
johndcobb Jun 3, 2024
1ac2f22
documented idealSheaf
johndcobb Jun 3, 2024
911a295
added name to authors
johndcobb Jun 3, 2024
a3dd074
deleted sheafOf
kellerlv Jun 3, 2024
39a461a
added (euler, Complex)
DanielApsley Jun 3, 2024
70179f4
added idealSheafSequence
johndcobb Jun 3, 2024
69ea77f
fixed syntax errors
johndcobb Jun 3, 2024
6ac405c
allow quick documentation loading
johndcobb Jun 3, 2024
7f9a2ac
updated documentation of idealSheafSequence
johndcobb Jun 3, 2024
47760b0
added commutativity to RingElement * SheafMap
DanielApsley Jun 4, 2024
4c2b208
documented ^, ^**, ++
johndcobb Jun 4, 2024
5fb2539
added code for tensoring a complex of sheaves by a sheaf
johndcobb Jun 4, 2024
484a65b
fixed prune for zero sheaf maps
mahrud Jun 4, 2024
6609559
flattened complexes and modules in RHom and Ext of sheaf complexes
mahrud Jun 4, 2024
d6a110d
simplified some sheaf complex constructors
mahrud Jun 4, 2024
f7c5d2a
added more tests
DanielApsley Jun 4, 2024
c7746c0
added sheaf and module for a map of complexes
johndcobb Jun 4, 2024
3960858
fixed flattenComplex in Varieties
mahrud Jun 4, 2024
da5de65
simplified RHom for complexes of sheaves
mahrud Jun 4, 2024
ea47864
simplified cohomology of complexes of sheaves
mahrud Jun 4, 2024
8a05cef
removed backported section from workshop
mahrud Jun 7, 2024
ecf8c73
fixed (matrix, List) and added isMorphism, isAbelianCategory
mahrud Jun 7, 2024
59b38c0
fixed canonicalBundle in the singular case
Devlin-Mallory Jun 10, 2024
7c6a785
added failing test for Hom
Devlin-Mallory Jun 10, 2024
79e3d76
commented some sheafHom methods
mahrud Jun 16, 2024
df4d937
fixed bug in truncation degree in Hom
Devlin-Mallory Jul 3, 2024
7a56293
switched to part instead of cxToField basis
mahrud Jul 4, 2024
82fb5e4
removed some sheafHom methods
mahrud Jul 4, 2024
e09c4ff
simplified tensor of sheaf maps and complexes
mahrud Jul 4, 2024
56ca4da
switched to using complex applyValues in Ext
mahrud Jul 4, 2024
67db95a
added part for modules, matrices, ideals, and rings
mahrud Jul 4, 2024
3eb98c2
switched to using part instead of moveToField
mahrud Jul 4, 2024
8fd4baa
added part for ring maps
mahrud Jul 4, 2024
c16a941
changed ring of sheaves to return OO_X
mahrud Jul 4, 2024
15ec629
simplified commonRing so it can handle a SheafMap (temporary fix)
mahrud Jul 7, 2024
484ae9a
changed SheafOfRings to inherit from Ring
mahrud Jul 7, 2024
cd761c7
added isWellDefined and isCommutative for SheafOfRings
mahrud Jul 7, 2024
53d7916
changed a line in documentation of basis
mahrud Jul 8, 2024
e6d514f
removed HH^ZZ Complex from Varieties
mahrud Jul 9, 2024
f17d11d
Small documentation addition
kellerlv Jul 10, 2024
3cab22a
small fix to documentation
Devlin-Mallory Jul 10, 2024
7f23f83
some changes to canonicalBundle
Devlin-Mallory Jul 10, 2024
12ea63c
some changes; bug left to be fixed though
Devlin-Mallory Jul 10, 2024
cc11f10
added HH^i(F(*)) to usage for cohomology
mahrud Aug 15, 2024
a6c7d28
removed DegreeLimit in Hom, which causes issues in inverse
Devlin-Mallory Oct 2, 2024
8b3de82
temporarily disable SheafComplexes
mahrud Oct 15, 2024
82c516b
bumped version of Varieties
mahrud Oct 15, 2024
aff801a
added test for truncation in presence of torsion
mahrud Aug 20, 2022
01f0ac9
added support for partial multidegrees in basis'
mahrud Jun 13, 2021
bb3fc42
added test for basis'
mahrud Nov 15, 2024
78a47de
fixed caching in Truncations
mahrud Feb 14, 2023
fc52de8
added caching for coneFromVData(Matrix)
mahrud Nov 12, 2024
1f6ff53
added isQQFano in NormalToricVarieties
mahrud Nov 13, 2024
83016b6
cached isFano for NormalToricVariety
mahrud Nov 13, 2024
3c630f2
simplified classGroup and picardGroup for ToricMap
mahrud Nov 8, 2024
fbaeb47
fixed a bug in picardGroup ToricMap
mahrud Nov 8, 2024
0fe9fbb
added test for classGroup and picardGroup for ToricMap
mahrud Nov 8, 2024
40488e9
fixed a bug in inducedMap for simplicial toric varieties
mahrud Nov 9, 2024
ce24360
changed vertices ToricDivisor to always return a matrix
mahrud Nov 10, 2024
4176564
fixed cohomology for simplicial toric varieties
mahrud Nov 10, 2024
ab9f206
added basis' as new basis strategy over toric varieties
mahrud Nov 11, 2024
6a146c1
added test for basis' in Truncations
mahrud Nov 11, 2024
2644292
added temporary workaround for rawSelectByDegrees bug
mahrud Nov 11, 2024
032643d
added tests for basis in presense of torsion
mahrud Nov 14, 2024
d650557
fixed minor bug in basis with torsion degrees
mahrud Nov 13, 2024
4de178a
fixed a couple of bugs in basis'
mahrud Nov 13, 2024
a7adc8c
fixed the documentation of vertices and latticePoints
mahrud Nov 16, 2024
b137b77
fixed a bug in basis'
mahrud Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion M2/Macaulay2/m2/basis.m2
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ findHeftandVars := (R, varlist, ndegs) -> (

-- TODO: can this be done via a tensor or push forward?
-- c.f. https://github.com/Macaulay2/M2/issues/1522
-- TODO: think about how this compares with part
liftBasis = (M, phi, B, offset) -> (
-- lifts a basis B of M via a ring map phi
(R, S) := (phi.target, phi.source);
Expand Down Expand Up @@ -221,6 +222,25 @@ basis(Sequence, RingMap) := Matrix => opts -> (degs, f) -> (

-----------------------------------------------------------------------------

-- Note: f needs to be homogeneous, otherwise returns nonsense
basis(ZZ, RingMap) :=
basis(List, RingMap) := Matrix => opts -> (degs, f) -> basis((degs, degs), f, opts)
basis(Sequence, RingMap) := Matrix => opts -> (degs, f) -> (
-- if not isHomogeneous f then error "expected a graded ring map (try providing a DegreeMap)";
if #degs != 2 then error "expected a sequence (tardeg, srcdeg) of degrees for target and source rings";
(T, S) := (target f, source f);
(tardeg, srcdeg) := degs;
if tardeg === null then tardeg = f.cache.DegreeMap srcdeg;
if srcdeg === null then srcdeg = f.cache.DegreeLift tardeg;
targens := basis(tardeg, T);
srcgens := basis(srcdeg, S);
-- TODO: should matrix RingMap return this map instead?
-- mon := map(module T, image matrix(S, { S.FlatMonoid_* }), f, matrix f)
mat := last coefficients(f cover srcgens, Monomials => targens);
map(image targens, image srcgens, f, mat))

-----------------------------------------------------------------------------

basisHelper = (opts, lo, hi, M) -> (
R := ring M;
n := degreeLength R;
Expand Down Expand Up @@ -300,7 +320,7 @@ algorithms#(basis, List, List, Module) = new MutableHashTable from {
G := degreeGroup(R := ring M);
if G == 0 or isFreeModule G then return null;
(S, phi, psi, p, f) := permuteDegreeGroup R;
B := psi map_S basisDefaultStrategy(opts, f lo, f hi, phi M);
B := psi map_S basisDefaultStrategy(opts, f lo, f hi, phi ** M);
L := positions(degrees source B, deg -> lo <= deg and deg <= hi);
raw submatrix(B, , L)),
-- TODO: add separate strategies for skew commutative rings, vector spaces, and ZZ-modules
Expand All @@ -309,3 +329,26 @@ algorithms#(basis, List, List, Module) = new MutableHashTable from {
-- Installing hooks for resolution
scan({Default, Torsion}, strategy ->
addHook(key := (basis, List, List, Module), algorithms#key#strategy, Strategy => strategy))

-----------------------------------------------------------------------------
-- part
-----------------------------------------------------------------------------
-- returns the graded component of an object in a specific degree

-- gives a map back to the coefficient ring
residueMap = (cacheValue symbol residueMap) (R -> map(A := coefficientRing R, R, DegreeMap => d -> take(d, - degreeLength A)))

-- TODO: document these
part(ZZ, Ring) :=
part(List, Ring) := Module => (deg, R) -> (residueMap R) source basis(deg, deg, module R)

part(ZZ, Ideal) :=
part(ZZ, Module) :=
part(List, Ideal) :=
part(List, Module) := Module => (deg, M) -> (residueMap ring M) source basis(deg, deg, M)

part(ZZ, Matrix) :=
part(List, Matrix) := Matrix => (deg, f) -> (residueMap ring f) cover basis(deg, f)

-- TODO: currently doesn't work unless source f === target f
part(Sequence, RingMap) := Matrix => (degs, f) -> (residueMap target f) cover basis(degs, f)
11 changes: 11 additions & 0 deletions M2/Macaulay2/m2/chaincomplexes.m2
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ needs "Hom.m2"
union := (x,y) -> keys(set x + set y)
intersection := (x,y) -> keys(set x * set y)

-----------------------------------------------------------------------------
-- Categories for which complexes are currently implemented in Macaulay2
-----------------------------------------------------------------------------
-- SheafMap and CoherentSheaf are added later in Varieties

isMorphism Thing := x -> false
isMorphism Matrix := f -> true

isAbelianCategory Thing := x -> false
isAbelianCategory Module := M -> true

-----------------------------------------------------------------------------
-- ChainComplex, ChainComplexMap, and Resolution type declarations and basic constructors
-----------------------------------------------------------------------------
Expand Down
13 changes: 13 additions & 0 deletions M2/Macaulay2/m2/classes.m2
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ ancestors' = T -> unique join({T}, while (T = class T) =!= Type list T, {Type}

-- TODO: make this TT toString X later?
synonym = X -> if X.?synonym then X.synonym else "object of class " | toString X
-- TODO: find a more permanent solution
plurals = new MutableHashTable from {
"body" => "bodies",
"dictionary" => "dictionaries",
"matrix" => "matrices",
"sheaf" => "sheaves",
"variety" => "varieties",
}
pluralize = s -> demark_" " append(
drop(ws := separate_" " s, -1),
if plurals#?(last ws)
then plurals#(last ws) else last ws | "s")
pluralsynonym = T -> if T.?synonym then pluralize T.synonym else "objects of class " | toString T

Time.synonym = "timing result"
Boolean.synonym = "Boolean value"
Expand Down
27 changes: 16 additions & 11 deletions M2/Macaulay2/m2/matrix.m2
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ isHomogeneous Matrix := (cacheValue symbol isHomogeneous) ( m -> ( isHomogeneous

isWellDefined Matrix := f -> matrix f * presentation source f % presentation target f == 0

-----------------------------------------------------------------------------
-- directSum and friends
-----------------------------------------------------------------------------

ggConcatCols := (tar,src,mats) -> (
map(tar,src,if mats#0 .?RingMap then mats#0 .RingMap,rawConcatColumns (raw\mats),Degree => if same(degree \ mats) then degree mats#0)
)
Expand Down Expand Up @@ -318,28 +322,29 @@ indices HashTable := X -> (
else error "expected an object with components"
)

-- This is used for methods like directSum or pullback/pushout
-- which accept an arbitrary list of objects of the same type.
applyUniformMethod = (symb, name) -> args -> (
if #args === 0 then error("expected at least one argument for ", name);
type := if uniform args then class args#0 else error("expected uniform objects for ", name);
meth := lookup(symb, type) ?? error("no method for ", name, " of ", pluralsynonym type);
if (Y := youngest args) =!= null and Y.?cache
then Y.cache#(symb, args) ??= meth args else meth args)

directSum List := args -> directSum toSequence args
directSum Sequence := args -> (
if #args === 0 then error "expected more than 0 arguments";
type := if uniform args then class args#0 else error "incompatible objects in direct sum";
meth := lookup(symbol directSum, type);
if meth === null then error "no method for direct sum";
Y := youngest args;
key := (directSum, args);
if Y === null or not Y.?cache then meth args else
if Y.cache#?key then Y.cache#key else Y.cache#key = meth args)
directSum Sequence := applyUniformMethod(symbol directSum, "direct sum")

-- Number.directSum = v -> directSum apply(v, a -> matrix{{a}})

Option ++ Option := directSum
directSum Option := o -> directSum(1 : o)
Option.directSum = args -> (
if #args === 0 then error "expected more than 0 arguments";
if #args === 0 then error "expected at least one argument";
objects := apply(args,last);
labels := toList args/first;
type := if uniform objects then class objects#0 else error "incompatible objects in direct sum";
meth := lookup(symbol directSum, type);
if meth === null then error "no method for direct sum";
if meth === null then error("no method for direct sum of ", pluralsynonym type);
M := meth objects;
M.cache.indices = labels;
ic := M.cache.indexComponents = new HashTable from apply(#labels, i -> labels#i => i);
Expand Down
56 changes: 23 additions & 33 deletions M2/Macaulay2/m2/matrix1.m2
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ needs "matrix.m2"
needs "modules.m2"
needs "quotient.m2"

plurals := hashTable { "matrix" => "matrices" }
pluralize := s -> if plurals#?s then plurals#s else s|"s"
pluralsynonym := T -> try pluralize T.synonym else "objects of class "|toString T;
notsamering := (X,Y) -> (
if X === Y then error("expected ",pluralsynonym X, " for the same ring")
else error("expected ",X.synonym," and ",Y.synonym," for the same ring"))
Expand Down Expand Up @@ -178,25 +175,22 @@ concatBlocks = mats -> (
Matrix.matrix = options -> (f) -> concatBlocks f

commonRing = method()
trythese := rings -> ring try sum apply(rings, R -> 0_R) else error "common ring not found"
commonRing List := f -> (
f = flatten f;
if #f == 0 then return ZZ;
types := unique apply(f, class);
if # types === 1 and instance(types#0,Ring) then return types#0;
rings := if all(types, T -> instance(T,Ring)) then types else unique apply(f,ring);
ring try sum apply(rings, R -> 0_R) else error "common ring not found")

matrixTable := opts -> (f) -> (
commonRing List := L -> (
rings := unique apply(flatten L, ring);
if #rings === 0 then ZZ else
if #rings === 1 then rings#0 else
ring try sum apply(rings, R -> 0_R) else error "common ring not found")

matrixTable = opts -> (f) -> (
R := commonRing f;
havemat := false;
f = applyTable(f, x -> (
if instance(x,Matrix) then havemat = true
else if not ( instance(x,RingElement) or instance(x,Number) )
then error "expected numbers, ring elements, and matrices";
promote(x,R)));
if not havemat then return map(R^#f,, f, opts);
f = applyTable(f,
x -> if isMorphism x then (havemat = true; promote(x, R))
else if instance(x, RingElement) or instance(x, Number) then promote(x, R)
else error "expected numbers, ring elements, and matrices");
if not havemat then return map(R^#f, , f, opts);
types := unique apply(flatten f, class);
-- Note: we use Matrix.matrix here, which is different from Matrix#matrix
if # types === 1 and types#0 .?matrix then return ( types#0 .matrix opts)(f);
f = apply(f, row -> new MutableList from row);
m := #f;
Expand Down Expand Up @@ -274,20 +268,16 @@ matrix(Matrix) := Matrix => opts -> (m) -> (

matrix RingElement := matrix Number := opts -> r -> matrix({{r}}, opts)

matrix(List) := Matrix => opts -> (m) -> (
if #m === 0 then return matrix(ZZ, {});
mm := apply(splice m,splice);
if #mm === 0 then error "expected nonempty list";
types := unique apply(mm,class);
if #types === 1 then (
type := types#0;
if instance(type,Module) then matrix { apply(mm, v -> new Matrix from v) }
else if ancestor(List, type) then (
if isTable mm then (matrixTable opts)(mm)
else error "expected rows all to be the same length"
)
else error "expected a table of ring elements or matrices, or a list of elements of the same module")
else error "expected a table of ring elements or matrices, or a list of elements of the same module")
matrix List := Matrix => opts -> L -> (
if #L === 0 then return matrix(ZZ, {});
L = apply(splice L, splice); -- TODO: is this deepSplice?
if not uniform L and not isTable L
then error "expected a list of vectors or a table of entries or maps";
-- construct a matrix by concatenating column vectors
if instance(L#0, Vector) then matrix { apply(L, matrix) } else
-- construct a matrix from a table of entries or maps
if isTable L then (matrixTable opts)(L)
else error "expected a rows all to be the same length")

align := g -> (
-- generator and relation maps can just as well have a nonzero degree
Expand Down
92 changes: 60 additions & 32 deletions M2/Macaulay2/m2/matrix2.m2
Original file line number Diff line number Diff line change
Expand Up @@ -325,32 +325,40 @@ quotientRemainder(Matrix,Matrix) := Matrix => (f,g) -> (
map(M, L, rem)
))

leftQuotientWarn = true

Matrix // Matrix := Matrix => (f,g) -> quotient(f,g)
Matrix \\ Matrix := (g,f) -> (if leftQuotientWarn then (leftQuotientWarn = false; printerr "Warning: 'm \\\\ n' is deprecated; use 'n // m' instead."); f // g)
quotient'(Matrix,Matrix) := Matrix => (f,g) -> (
if not isFreeModule source f or not isFreeModule target f
or not isFreeModule source g or not isFreeModule target g then error "expected maps between free modules";
dual quotient(dual f, dual g))
quotient(Matrix,Matrix) := Matrix => opts -> (f,g) -> (
if target f != target g then error "quotient: expected maps with the same target";
c := runHooks((quotient, Matrix, Matrix), (opts, f, g));
if c =!= null then c else error "quotient: no method implemented for this type of input")

addHook((quotient, Matrix, Matrix), Strategy => Default, (opts, f, g) -> (
--------------------------------------------------------------------------------
-- factoring of a matrix through another

-- Note: when f and g are endomorphisms, the sources and targets all agree,
-- so we need both functions quotient and quotient' to distinguish them.

-- factor matrices with same targets
Matrix // Matrix := Matrix => (f, g) -> quotient(f, g)
Number // Matrix := RingElement // Matrix := Matrix => (r, g) -> map(source g, target g, map(target g, cover target g, r) // g)
Matrix // Number := Matrix // RingElement := Matrix => (f, r) -> map(target f, source f, f // map(target f, cover target f, r))

-- factor matrices with same sources
Matrix \\ Matrix := Matrix => (g, f) -> quotient'(f, g)
-- commented because they don't seem very meaningful
--Matrix \\ Number := Matrix \\ RingElement := Matrix => (g, r) -> map(source g, target g, g \\ map(cover source g, source g, r))
--Number \\ Matrix := RingElement \\ Matrix := Matrix => (r, f) -> map(target g, source g, map(cover source g, source g, r) \\ f)

quotient(Matrix, Matrix) := Matrix => opts -> (f, g) -> (
-- given f: A-->C and g: B-->C, then find (f//g): A-->B such that g o (f//g) + r = f
if target f != target g then error "quotient: expected maps with the same target";
c := runHooks((quotient, Matrix, Matrix), (opts, f, g), Strategy => opts.Strategy);
if c =!= null then c else error "quotient: no method implemented for this type of input")

addHook((quotient, Matrix, Matrix), Strategy => Default,
-- Note: this strategy only works if the remainder is zero, i.e.:
-- homomorphism' f % image Hom(source f, g) == 0
-- TODO: should we pass MinimalGenerators => false to Hom and homomorphism'?
(opts, f, g) -> map(source g, source f, homomorphism(homomorphism' f // Hom(source f, g))))

-- FIXME: this is still causing unreasonable slow downs, e.g. for (large m) // (scalar)
addHook((quotient, Matrix, Matrix), Strategy => "Reflexive", (opts, f, g) -> if f == 0 or isFreeModule source f then (
L := source f; -- result may not be well-defined if L is not free
M := target f;
N := source g;
if instance(ring M, InexactField)
and numRows g === numColumns g
and isFreeModule source g and isFreeModule source f
then return solve(g,f);
local retVal;
if isQuotientOf(ZZ,ring target f)
and isFreeModule source g and isFreeModule source f
then retVal = solve(g,f);
if retVal =!= null then return retVal;
if M.?generators then (
M = cokernel presentation M; -- this doesn't change the cover
);
Expand All @@ -368,16 +376,36 @@ addHook((quotient, Matrix, Matrix), Strategy => Default, (opts, f, g) -> (
Degree => degree f' - degree g' -- set the degree in the engine instead
)))

Number // Matrix :=
RingElement // Matrix := (r,f) -> (r * id_(target f)) // f
Matrix \\ Number :=
Matrix \\ RingElement := (f,r) -> r // f

Matrix // Number :=
Matrix // RingElement := (f,r) -> f // (r * id_(target f))
Number \\ Matrix :=
RingElement \\ Matrix := (r,f) -> f // r
addHook((quotient, Matrix, Matrix), Strategy => InexactField, (opts, f, g) ->
if instance(ring target f, InexactField)
-- TODO: c.f. https://github.com/Macaulay2/M2/issues/3252
and numRows g === numColumns g
and isFreeModule source g
and isFreeModule source f
then solve(g, f))

addHook((quotient, Matrix, Matrix), Strategy => ZZ, (opts, f, g) ->
if isQuotientOf(ZZ, ring target f)
and isFreeModule source g
and isFreeModule source f
then solve(g, f))

quotient'(Matrix, Matrix) := Matrix => opts -> (f, g) -> (
-- given f: A-->C and g: A-->B, then finds (g\\f): B-->C such that (g\\f) o g + r = f
if source f != source g then error "quotient': expected maps with the same source";
c := runHooks((quotient', Matrix, Matrix), (opts, f, g), Strategy => opts.Strategy);
if c =!= null then c else error "quotient': no method implemented for this type of input")

addHook((quotient', Matrix, Matrix), Strategy => Default,
-- Note: this strategy only works if the remainder is zero, i.e.:
-- homomorphism' f % image Hom(g, target f) == 0
-- TODO: should we pass MinimalGenerators => false to Hom and homomorphism'?
(opts, f, g) -> map(target f, target g, homomorphism(homomorphism' f // Hom(g, target f))))

addHook((quotient', Matrix, Matrix), Strategy => "Reflexive",
(opts, f, g) -> if all({source f, target f, source g, target g}, isFreeModule) then dual quotient(dual f, dual g, opts))

--------------------

remainder'(Matrix,Matrix) := Matrix => (f,g) -> (
if not isFreeModule source f or not isFreeModule source g
Expand Down
2 changes: 1 addition & 1 deletion M2/Macaulay2/m2/methods.m2
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ setupMethods((), {
koszul, target, source,
getChangeMatrix, cover, coverMap, super, terms,
cokernel, coimage, comodule, image, someTerms, scanKeys, scanValues,
substitute, complete, ambient, remainder, quotientRemainder, remainder', quotientRemainder', quotient',
substitute, complete, ambient, remainder, quotientRemainder, remainder', quotientRemainder',
coefficients, monomials, size, sum, product, nullhomotopy, module, raw,
content, leadTerm, leadCoefficient, leadMonomial, components,
assign, realPart, imaginaryPart, conjugate,
Expand Down
Loading
Loading