Sophie

Sophie

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

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>ImmutableType -- the class of immutable types</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="_in.html">next</a> | <a href="_imaginary__Part.html">previous</a> | <a href="_in.html">forward</a> | <a href="_imaginary__Part.html">backward</a> | up | <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>
<hr/>
<div><h1>ImmutableType -- the class of immutable types</h1>
<div class="single"><h2>Description</h2>
<div>All types are implemented as hash tables.  Most types are mutable, so that additional methods for handling their instances can be added at any time.  However, if a type has an ancestor where the methods can be stored, then mutability is not needed.<p/>
When a type is used to represent a mathematical object, then immutability is desirable, in order to make the strict equality operator work on it.  For example, a module <tt>M</tt> is a type, with its elements are its instances, but we would like to be able to compare two modules quickly, and form sets of modules.  This is possible, because we have implemented modules as immutable types, and we have put the methods for adding and subtracting elements of <tt>M</tt> into the class <a href="___Vector.html" title="the class of all elements of free modules that are handled by the engine">Vector</a>.<table class="examples"><tr><td><pre>i1 : F = ZZ^3

       3
o1 = ZZ

o1 : ZZ-module, free</pre>
</td></tr>
<tr><td><pre>i2 : class F

o2 = Module

o2 : Type</pre>
</td></tr>
<tr><td><pre>i3 : parent class F

o3 = ImmutableType

o3 : Type</pre>
</td></tr>
<tr><td><pre>i4 : showStructure class F

o4 = Thing : HashTable : ImmutableType : Module

o4 : Descent</pre>
</td></tr>
<tr><td><pre>i5 : showStructure F

o5 = Thing : BasicList : Vector : F

o5 : Descent</pre>
</td></tr>
<tr><td><pre>i6 : v = F_0 + 3*F_2

o6 = | 1 |
     | 0 |
     | 3 |

       3
o6 : ZZ</pre>
</td></tr>
<tr><td><pre>i7 : F === ZZ^3

o7 = true</pre>
</td></tr>
<tr><td><pre>i8 : set (ZZ^3, ZZ^2, ZZ^3)

            2    3
o8 = set {ZZ , ZZ }

o8 : Set</pre>
</td></tr>
<tr><td><pre>i9 : peek F

o9 = Module of Vector{cache => CacheTable{...2...}                     }
                      numgens => 3
                      RawFreeModule => free(rank 3 degrees = {1, 1, 1})
                      ring => ZZ</pre>
</td></tr>
</table>
Another advantage of immutability of modules is that there is no particular reason, aside from efficiency, to avoid creating a given module multiple times, as one copy of the module is as good as another.<table class="examples"><tr><td><pre>i10 : ZZ^3_0 + ZZ^3_2

o10 = | 1 |
      | 0 |
      | 1 |

        3
o10 : ZZ</pre>
</td></tr>
</table>
</div>
</div>
<div class="single"><h2>See also</h2>
<ul><li><span><a href="_show__Structure.html" title="display parent structure">showStructure</a> -- display parent structure</span></li>
<li><span><a href="_parent.html" title="parent type of an object">parent</a> -- parent type of an object</span></li>
<li><span><a href="_class.html" title="class of an object">class</a> -- class of an object</span></li>
</ul>
</div>
<div class="waystouse"><h2>Types of immutable type :</h2>
<ul><li><span><a href="___Module.html" title="the class of all modules">Module</a> -- the class of all modules</span></li>
</ul>
<h2>Methods that use an immutable type :</h2>
<ul><li><span>ofClass(ImmutableType), see <span><a href="_of__Class.html" title="English phrases for types">ofClass</a> -- English phrases for types</span></span></li>
</ul>
</div>
<div class="waystouse"><h2>For the programmer</h2>
<p>The object <a href="___Immutable__Type.html" title="the class of immutable types">ImmutableType</a> is <span>a <a href="___Type.html">type</a></span>, with ancestor classes <a href="___Hash__Table.html" title="the class of all hash tables">HashTable</a> &lt; <a href="___Thing.html" title="the class of all things">Thing</a>.</p>
</div>
</div>
</body>
</html>