source: project/sparse-vectors/sparse-vectors.html @ 4140

Last change on this file since 4140 was 4140, checked in by felix winkelmann, 13 years ago

added sparse vectors

File size: 4.2 KB
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><!-- Generated by egg-post-commit from the wiki, revision $Rev: 4035 $ --><html><head><title>Eggs Unlimited - sparse-vectors</title><link rel="stylesheet" type="text/css" href="http://www.call-with-current-continuation.org/eggs/style.css"/><base href="http://chicken.wiki.br"/></head><body><div id="header"><h2>sparse-vectors</h2><div id="eggheader"><a href="http://www.call-with-current-continuation.org/eggs/index.html"><img src="http://www.call-with-current-continuation.org/eggs/egg.jpg" alt="egg"/></a></div></div><div id="body"><p><b>Note: </b>This is taken from <a href="http://chicken.wiki.br/sparse-vectors">the Chicken Wiki</a>, where a more recent version could be available.</p><p> </p><a name='Introduction'><h1>Introduction</h1></a><p>Sparse vectors are vectors that grow as large as they need to. That is, they can be indexed by arbitrarily large nonnegative integers. The implementation allows for arbitrarily large gaps by arranging the entries in a tree.</p><a name='Usage'><h1>Usage</h1></a><pre>(require-extension sparse-vectors)</pre><p>If you have the <a href='http://www.call-with-current-continuation.org/eggs/numbers.html' class='external'>numbers</a> extension installed then this extension will be built with an additional variant that supports bignum indices:</p><pre>(require-extension big-sparse-vectors)</pre><a name='API'><h1>API</h1></a><pre>[procedure] (make-sparse-vector) -&gt; sparse-vector
2[procedure] (sparse-vector? x) -&gt; boolean
3[procedure] (sparse-vector-ref sparse-vector k) -&gt; value
4[procedure] (sparse-vector-set! sparse-vector k value)
5[procedure] (sparse-vector-&gt;list sparse-vector) -&gt; list  </pre><p><tt>make-sparse-vector</tt>, <tt>sparse-vector-ref</tt> and <tt>sparse-vector-set!</tt> are analogous to <tt>make-vector</tt>, <tt>vector-ref</tt> and <tt>vector-set!</tt>, except that the indices passed to <tt>sparse-vector-ref</tt> and <tt>sparse-vector-set!</tt> can be arbitrarily large. For indices whose elements have not been set in a sparse vector, <tt>sparse-vector-ref</tt> returns #f.</p><p><tt>sparse-vector-&gt;list</tt> is for debugging: It returns a list of the consecutive elements in a sparse vector from 0 to the highest element that has been set. Note that the list will also include all the #f elements for the unset elements.</p><a name='Authors'><h1>Authors</h1></a><p>Richard Kelsey and Jonathan Rees</p><a name='License'><h1>License</h1></a><pre>Copyright (c) 1993-2006 Richard Kelsey and Jonathan Rees
6All rights reserved.
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions
10are met:
111. Redistributions of source code must retain the above copyright
12   notice, this list of conditions and the following disclaimer.
132. Redistributions in binary form must reproduce the above copyright
14   notice, this list of conditions and the following disclaimer in the
15   documentation and/or other materials provided with the distribution.
163. The name of the authors may not be used to endorse or promote products
17   derived from this software without specific prior written permission.
18
19THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
20IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</pre><a name='History'><h1>History</h1></a><dl><dt>0.1</dt><dd>Initial release</dd></dl></div><div id="footer"><hr/><a href="http://www.call-with-current-continuation.org/eggs/index.html">&lt; Egg index</a><div id="revision-history">$Id: egg-post-commit.scm 4035 2007-05-04 20:13:46Z kon $</div>&nbsp;</div></body></html>
Note: See TracBrowser for help on using the repository browser.