Skip to content

Commit

Permalink
added ways to avoid gb calls in inducedMap
Browse files Browse the repository at this point in the history
  • Loading branch information
mahrud committed Oct 29, 2024
1 parent fbc3bac commit 81d77e7
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions M2/Macaulay2/m2/matrix.m2
Original file line number Diff line number Diff line change
Expand Up @@ -625,11 +625,28 @@ isSubquotient(Module,Module) := (M,N) -> (
relations N % relations M == 0
)

-----------------------------------------------------------------------------
-- inducedMap
-----------------------------------------------------------------------------

inducedMap = method (
Options => {
Verify => true,
Degree => null
})
-- TODO: hookify this, so people can add more application specific induced maps
inducedMap(Module, Module) := Matrix => opts -> (M, N) -> (
if ambient M =!= ambient N then error "inducedMap: expected modules with same ambient free module";
-- e.g. avoid a gb computation for inducedMap(M, image basis(d, M))
if N.cache.?Monomials and M === target N.cache.Monomials
then map(M, N, N.cache.Monomials, Degree => opts.Degree)
else inducedMap(M, N, id_(ambient N), opts))
inducedMap(Module, Nothing, Matrix) := Matrix => opts -> (M, N, f) -> (
B := image f;
-- e.g. avoid a gb computation for inducedMap(image f, , f)
if M === target B.cache.Monomials
then map(M, source B.cache.Monomials, B.cache.Monomials, Degree => opts.Degree)
else inducedMap(M, source f, f, opts))
inducedMap(Module,Module,Matrix) := Matrix => opts -> (N',M',f) -> (
N := target f;
M := source f;
Expand All @@ -651,7 +668,6 @@ inducedMap(Module,Module,Matrix) := Matrix => opts -> (N',M',f) -> (
if not isWellDefined f' then error "inducedMap: expected matrix to induce a well-defined map";
);
f')
inducedMap(Module,Nothing,Matrix) := o -> (M,N,f) -> inducedMap(M,source f, f,o)
inducedMap(Nothing,Module,Matrix) := o -> (M,N,f) -> inducedMap(target f,N, f,o)
inducedMap(Nothing,Nothing,Matrix) := o -> (M,N,f) -> inducedMap(target f,source f, f,o)

Expand All @@ -665,10 +681,6 @@ addHook((inducedMap, Module, Module, Matrix), Strategy => Default, (opts, N', M'
f' = map(N',M',f',Degree => if opts.Degree === null then degree f else opts.Degree);
(f', g, gbN', gbM)))

inducedMap(Module,Module) := Matrix => o -> (M,N) -> (
if ambient M =!= ambient N then error "inducedMap: expected modules with same ambient free module";
inducedMap(M,N,id_(ambient N),o))

-- TODO: deprecate this in favor of isWellDefined
inducesWellDefinedMap = method(TypicalValue => Boolean)
inducesWellDefinedMap(Module,Module,Matrix) := (M,N,f) -> (
Expand All @@ -685,6 +697,8 @@ inducesWellDefinedMap(Module,Nothing,Matrix) := (M,N,f) -> inducesWellDefinedMap
inducesWellDefinedMap(Nothing,Module,Matrix) := (M,N,f) -> inducesWellDefinedMap(target f,N,f)
inducesWellDefinedMap(Nothing,Nothing,Matrix) := (M,N,f) -> true

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

vars Ring := Matrix => R -> (
g := generators R;
if R.?vars then R.vars else R.vars =
Expand Down

0 comments on commit 81d77e7

Please sign in to comment.