Macaulay2 » Documentation
Packages » map > map(Module,Module,Function)
next | previous | forward | backward | up | index | toc

map(Module,Module,Function) -- create a matrix by specifying a function that gives each entry

Synopsis

Description

Recall that all indices in Macaulay2 start at 0, so the upper left-most entry of a matrix f is f_(0,0).

This function is often used when you already know the source and target modules, including their gradings. If you wish Macaulay2 to compute the column degrees for you (so the resulting matrix will be homogeneous if possible), use map(Module,ZZ,Function).
i1 : R = ZZ[a..c];
i2 : f = map(R^3,R^{0,-1,-2,-3},(i,j) -> R_i^j)

o2 = | 1 a a2 a3 |
     | 1 b b2 b3 |
     | 1 c c2 c3 |

             3      4
o2 : Matrix R  <-- R
We specified the degrees of the source basis elements explicitly to ensure the matrix would be homogeneous.
i3 : isHomogeneous f

o3 = true

Alternate approaches

We could have let Macaulay2 take care of that for us, by replacing the source module by its desired rank.
i4 : g = map(R^3,4,(i,j) -> R_i^j)

o4 = | 1 a a2 a3 |
     | 1 b b2 b3 |
     | 1 c c2 c3 |

             3      4
o4 : Matrix R  <-- R
i5 : degrees g

o5 = {{{0}, {0}, {0}}, {{0}, {1}, {2}, {3}}}

o5 : List
i6 : isHomogeneous g

o6 = true

Another way would be to let matrix take care of that for us.
i7 : h = matrix table(3,4,(i,j) -> R_i^j)

o7 = | 1 a a2 a3 |
     | 1 b b2 b3 |
     | 1 c c2 c3 |

             3      4
o7 : Matrix R  <-- R
i8 : degrees h

o8 = {{{0}, {0}, {0}}, {{0}, {1}, {2}, {3}}}

o8 : List
i9 : isHomogeneous h

o9 = true

Ways to use this method: