<?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>random and generic matrices</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="_extracting_spinformation_spabout_spa_spmatrix.html">next</a> | <a href="_projections_cm_spinclusions_cm_spand_sppermutations.html">previous</a> | <a href="_extracting_spinformation_spabout_spa_spmatrix.html">forward</a> | <a href="_projections_cm_spinclusions_cm_spand_sppermutations.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="_random_spand_spgeneric_spmatrices.html" title="">random and generic matrices</a></div> <hr/> <div><h1>random and generic matrices</h1> <div><h2>random matrices</h2> To construct a random m by n matrix with entries in a ring R use the function <a href="_random.html" title="get a random element">random</a> by typing <tt>random(R^m,R^n)</tt>.<table class="examples"><tr><td><pre>i1 : R = GF(3^2,Variable => a);</pre> </td></tr> <tr><td><pre>i2 : random(R^3,R^4) o2 = | 1 1 1 -a | | -a+1 a -1 -a | | -1 a+1 0 a-1 | 3 4 o2 : Matrix R <--- R</pre> </td></tr> </table> Over a polynomial ring, this will select elements in the base ring or field. TO obtain a matrix of (say) linear polynomials, use<table class="examples"><tr><td><pre>i3 : T = R[x,y];</pre> </td></tr> <tr><td><pre>i4 : random(T^3,T^{4:-1}) o4 = | (a+1)x+(-a-1)y -ax+(-a-1)y -x+(-a-1)y (a-1)x+(a+1)y | | (a-1)x+ay -ax+(a+1)y ax+(-a-1)y (-a+1)x-ay | | -ax+(-a+1)y (-a+1)y ax+ay (-a+1)x+(a+1)y | 3 4 o4 : Matrix T <--- T</pre> </td></tr> </table> <h2>matrices of variables</h2> To build an m by n matrix of variables drawn from the ring R, use <a href="_generic__Matrix.html" title="make a generic matrix of variables">genericMatrix</a>. The syntax is <tt>genericMatrix(R,x,m,n)</tt> where R is the ring, x is the variable where we start and m and n specify the size of the matrix.<table class="examples"><tr><td><pre>i5 : S = R[p..z];</pre> </td></tr> <tr><td><pre>i6 : genericMatrix(S,t,3,2) o6 = | t w | | u x | | v y | 3 2 o6 : Matrix S <--- S</pre> </td></tr> </table> Note that to use the function genericMatrix the number of variables in the ring R must be at least as large as <tt>m*n</tt>.<h2>genericSymmetricMatrix</h2> To construct an n by n symmetric matrix whose entries on and above the diagonal are the variables of R use <a href="_generic__Symmetric__Matrix.html" title="make a generic symmetric matrix">genericSymmetricMatrix</a>. The syntax is <tt>genericSymmetricMatrix(R,x,n)</tt> where R is the ring, x is the variable you want to start with and n is the size of the matrix.<table class="examples"><tr><td><pre>i7 : genericSymmetricMatrix(S,s,3) o7 = | s t u | | t v w | | u w x | 3 3 o7 : Matrix S <--- S</pre> </td></tr> </table> <h2>genericSkewMatrix</h2> To construct an n by n skew symmetric matrix whose entries above the diagonal are the variables of R use <a href="_generic__Skew__Matrix.html" title="make a generic skew symmetric matrix of variables">genericSkewMatrix</a>. The syntax is <tt>genericSkewMatrix(R,x,n)</tt> where R is the ring, x is the variable you want to start with and n is the size of the matrix.<table class="examples"><tr><td><pre>i8 : genericSymmetricMatrix(S,u,3) o8 = | u v w | | v x y | | w y z | 3 3 o8 : Matrix S <--- S</pre> </td></tr> </table> </div> </div> </body> </html>