Skip to content

Commit 3b41b17

Browse files
mahrudd-torrance
authored andcommitted
added options and hookified kernel
1 parent 731b558 commit 3b41b17

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

M2/Macaulay2/m2/matrix1.m2

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,28 @@ Ideal ^ Array := (I, e) -> (
578578
ideal phi generators I
579579
)
580580

581+
-----------------------------------------------------------------------------
582+
-- kernel and homology
583+
-----------------------------------------------------------------------------
584+
585+
kernel = method(Options => {
586+
DegreeLimit => {},
587+
Strategy => {},
588+
SubringLimit => infinity, -- stop after finding enough elements of a subring
589+
})
590+
kernel Matrix := Module => opts -> g -> g.cache.kernel ??= if g == 0 then source g else tryHooks(
591+
(kernel, Matrix), (opts, g), (opts, g) -> (
592+
-- this is the default algorithm
593+
-- compare with homology below
594+
N := source g;
595+
P := target g;
596+
g = matrix g;
597+
if P.?generators then g = P.generators * g;
598+
h := modulo(g, if P.?relations then P.relations);
599+
if N.?generators then h = N.generators * h;
600+
subquotient(h, if N.?relations then N.relations)))
601+
kernel RingElement := Module => opts -> f -> kernel(matrix {{f}}, opts)
602+
581603
homology(Matrix,Matrix) := Module => opts -> (g,f) -> (
582604
if g == 0 then cokernel f
583605
else if f == 0 then kernel g

M2/Macaulay2/m2/pushforward.m2

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -227,22 +227,13 @@ scan({Default, Quotient}, strategy ->
227227
-- kernel
228228
-----------------------------------------------------------------------------
229229

230-
kernel Matrix := Module => opts -> (cacheValue symbol kernel) ((m) -> (
231-
N := source m;
232-
if m == 0 then return N;
233-
P := target m;
234-
if m.?RingMap then (
235-
f := m.RingMap;
236-
n := map(target m,f source m,raw m);
237-
p := pushNonLinear(options pushForward, f, coimage n);
238-
image p)
239-
else (
240-
m = matrix m;
241-
if P.?generators then m = P.generators * m;
242-
h := modulo(m, if P.?relations then P.relations);
243-
if N.?generators then h = N.generators * h;
244-
subquotient( h, if N.?relations then N.relations))))
245-
kernel RingElement := Module => options -> (m) -> kernel (matrix {{m}},options)
230+
addHook((kernel, Matrix), Strategy => "PushForward",
231+
(opts, m) -> if m.?RingMap then (
232+
N := source m;
233+
P := target m;
234+
f := m.RingMap;
235+
M := coimage map(target m, f ** source m, raw m);
236+
image pushNonLinear(options pushForward, f, M)))
246237

247238
-- Local Variables:
248239
-- compile-command: "make -C $M2BUILDDIR/Macaulay2/m2 "

M2/Macaulay2/m2/ringmap.m2

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ RingMap \ VisibleList := VisibleList => (f,v) -> apply(v,x -> f x)
228228
-- kernel
229229
-----------------------------------------------------------------------------
230230

231-
kernel = method(Options => { SubringLimit => infinity })
232231
kernel RingMap := Ideal => opts -> (cacheValue (symbol kernel => opts)) (f -> (
233232
(F, R) := (target f, source f);
234233
if 0_F == 1_F then return ideal 1_R;

M2/Macaulay2/packages/Macaulay2Doc/functions/kernel-doc.m2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
--- author(s):
44
--- notes:
55

6+
undocumented {
7+
[kernel, DegreeLimit],
8+
[kernel, Strategy],
9+
}
10+
611
doc ///
712
Node
813
Key

0 commit comments

Comments
 (0)