<?xml version="1.0" encoding="utf-8" ?> <!-- for emacs: -*- coding: utf-8 -*- --> <!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head><title>extracting information about a matrix</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="_basic_sparithmetic_spof_spmatrices.html">next</a> | <a href="_random_spand_spgeneric_spmatrices.html">previous</a> | <a href="_basic_sparithmetic_spof_spmatrices.html">forward</a> | <a href="_random_spand_spgeneric_spmatrices.html">backward</a> | <a href="_matrices.html">up</a> | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div> </td> </tr> </table> <div><a href="index.html" title="">Macaulay2Doc</a> > <a href="_matrices.html" title="">matrices</a> > <a href="_extracting_spinformation_spabout_spa_spmatrix.html" title="">extracting information about a matrix</a></div> <hr/> <div><h1>extracting information about a matrix</h1> <div>Consider the ring <tt>R</tt> and the matrix <tt>f</tt>.<table class="examples"><tr><td><pre>i1 : R = QQ[x,y,z];</pre> </td></tr> <tr><td><pre>i2 : f = matrix{{2,x,y,x^2},{z,32,2,x}} o2 = | 2 x y x2 | | z 32 2 x | 2 4 o2 : Matrix R <--- R</pre> </td></tr> </table> <h2>target</h2> From the above output, one sees that Macaulay2 considers <tt>f</tt> as a linear transformation. Use the <a href="_target.html" title="target of a map">target</a> command to obtain the target of the linear transformation <tt>f</tt>.<table class="examples"><tr><td><pre>i3 : target f 2 o3 = R o3 : R-module, free</pre> </td></tr> </table> <h2>source</h2> Likewise, to obtain the source of our linear transformation, use the <a href="_source.html" title="source of a map">source</a> command.<table class="examples"><tr><td><pre>i4 : source f 4 o4 = R o4 : R-module, free, degrees {1, 1, 1, 2}</pre> </td></tr> </table> <h2>number of rows or columns</h2> Use <a href="_numgens.html" title="the number of generators">numgens</a> to obtain the rank of a free module. Combining it with the commands <a href="_target.html" title="target of a map">target</a> or <a href="_source.html" title="source of a map">source</a> gives us a way to determine the number of rows or columns of a matrix <tt>f</tt>.<table class="examples"><tr><td><pre>i5 : numgens target f o5 = 2</pre> </td></tr> <tr><td><pre>i6 : numgens source f o6 = 4</pre> </td></tr> </table> <h2>extracting an element from a matrix</h2> To extract the <tt>(i,j)</tt>-th element of a matrix, type <tt>f_(i,j)</tt>.<table class="examples"><tr><td><pre>i7 : f_(1,3) o7 = x o7 : R</pre> </td></tr> </table> Note that the first number selects the row, starting at <tt>0</tt> and the second number selects the column, also starting at <tt>0</tt>.<h2>entries of a matrix</h2> To obtain the entries of a matrix in the form of a list of lists, use the <a href="_entries.html" title="lists the entries of a matrix">entries</a> command.<table class="examples"><tr><td><pre>i8 : entries f 2 o8 = {{2, x, y, x }, {z, 32, 2, x}} o8 : List</pre> </td></tr> </table> Note that each inner list is a list of elements from a row of <tt>f</tt>.<h2>ring</h2> The <a href="_ring.html" title="get the associated ring of an object">ring</a> command can be used to return the ring of the matrix, that is, the ring containing entries of the matrix.<table class="examples"><tr><td><pre>i9 : ring f o9 = R o9 : PolynomialRing</pre> </td></tr> </table> Use the <a href="_describe.html" title="real description">describe</a> command to recover how the ring of <tt>f</tt> was constructed.<table class="examples"><tr><td><pre>i10 : describe ring f o10 = QQ[x..z, Degrees => {3:1}, Heft => {1}, MonomialOrder => ----------------------------------------------------------------------- {MonomialSize => 32}, DegreeRank => 1] {GRevLex => {3:1} } {Position => Up }</pre> </td></tr> </table> </div> </div> </body> </html>