Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » debugging » on
next | previous | forward | backward | up | index | toc

on -- trace a function each time it's run

Description

Ideally, this function would replace f, i.e., we would write f = on f. Unfortunately, all the pre-installed system functions are write-protected; fortunately, their methods are not, and can be replaced.

i1 : ker Matrix := on(lookup(ker,Matrix),GenerateAssertions=>true,Name=>"ker"); 
i2 : f = x -> kernel (x|x);
i3 : R = QQ[a..c];
i4 : f vars R
-- ker (1) called with OptionTable: OptionTable{DegreeLimit => {}       }
--                                              Strategy => {}
--                                              SubringLimit => infinity
-- ker (1) returned FunctionClosure: FunctionClosure[${prefix}/share/Macaulay2/Core/matrix1.m2:592:35-602:58]
-- ker (1) called with Matrix: | a b c a b c |
-- ker (1) returned Module: image {1} | -1 0  0  -b 0  -c |
--                                {1} | 0  -1 0  a  -c 0  |
--                                {1} | 0  0  -1 0  b  a  |
--                                {1} | 1  0  0  0  0  0  |
--                                {1} | 0  1  0  0  0  0  |
--                                {1} | 0  0  1  0  0  0  |
assert( ker(map(R^1,R^{6:{-1}},{{a, b, c, a, b, c}})) === (image(map(R^{6:{-1}},R^{3:{-1}, 3:{-2}},{{-1, 0, 0, -b, 0, -c}, {0, -1, 0, a, -c, 0}, {0, 0, -1, 0, b, a}, {1, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 0}}))))

o4 = image {1} | -1 0  0  -b 0  -c |
           {1} | 0  -1 0  a  -c 0  |
           {1} | 0  0  -1 0  b  a  |
           {1} | 1  0  0  0  0  0  |
           {1} | 0  1  0  0  0  0  |
           {1} | 0  0  1  0  0  0  |

                             6
o4 : R-module, submodule of R

See also

For the programmer

The object on is a function closure.


The source of this document is in Macaulay2Doc/ov_debugging.m2:442:0.