Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 7ebd25ac536d248d499a3ce2acda963a > files > 4869

Macaulay2-1.3.1-8.fc15.i686.rpm

<?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>packing monomials for efficiency</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="___G__Rev__Lex.html">next</a> | <a href="___Schreyer_sporders.html">previous</a> | <a href="___G__Rev__Lex.html">forward</a> | <a href="_monomial_sporders_spfor_spfree_spmodules.html">backward</a> | <a href="_monomial_sporderings.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="_rings.html" title="">rings</a> > <a href="_monomial_sporderings.html" title="">monomial orderings</a> > <a href="_packing_spmonomials_spfor_spefficiency.html" title="">packing monomials for efficiency</a></div>
<hr/>
<div><h1>packing monomials for efficiency</h1>
<div>Sometimes for efficiency reasons, it is important to pack exponent vectors several exponents per machine word.  Polynomials take less space, and monomial operations such as comparison and multiplication become faster.<p/>
The monomial order keys <a href="___Lex.html" title="lexicographical monomial order.">Lex</a> and <a href="___G__Rev__Lex.html" title="graded reverse lexicographical monomial order.">GRevLex</a> allow packing.  The <tt>MonomialSize => n</tt> option allows one to set the minimum packing size, in number of bits.  Monomials are stored as signed exponent vectors, so maximum exponents of 2^(n-1)-1 are possible for packed variables.  Useful values include 8, 16, 32, and (on 64-bit machines) 64.  The default monomial size is 32.<table class="examples"><tr><td><pre>i1 : A = QQ[a..d,MonomialSize=>8]

o1 = A

o1 : PolynomialRing</pre>
</td></tr>
<tr><td><pre>i2 : B = QQ[x,y,z,w,MonomialSize=>16,MonomialOrder=>Lex]     

o2 = B

o2 : PolynomialRing</pre>
</td></tr>
</table>
The maximum degree for monomials in A is 127.  Monomials of higher degree will encounter a monomial overflow.  In the second example, the maximum exponent is 32767 (2^15-1).<p/>
It is possible to pack different parts of the monomial with different sizes.  For example, the following order has two blocks: a graded reverse lexicographic block of 3 variables, packed into one 32-bit word, and a second lexicographic block for 4 variables, taking 4 32-bit words.  Each monomial will be packed into 5 32-bit words (on a computer with a 32-bit word size).<table class="examples"><tr><td><pre>i3 : C = QQ[a,b,c,x,y,z,w,MonomialOrder=>{MonomialSize=>8,3,MonomialSize=>32,Lex=>4}];</pre>
</td></tr>
</table>
<p/>
<table class="examples"><tr><td><pre>i4 : D = QQ[a..d,MonomialOrder=>Lex];</pre>
</td></tr>
<tr><td><pre>i5 : a^1000000000

      1000000000
o5 = a

o5 : D</pre>
</td></tr>
</table>
<p/>
This exponent would give a monomial overflow error in the next two rings.<table class="examples"><tr><td><pre>i6 : E = QQ[a..d,MonomialSize=>16,MonomialOrder=>Lex];</pre>
</td></tr>
<tr><td><pre>i7 : F = QQ[a..d,MonomialSize=>8,MonomialOrder=>Lex];</pre>
</td></tr>
</table>
</div>
</div>
</body>
</html>