2
0
mirror of https://github.com/boostorg/ublas.git synced 2026-02-13 00:42:14 +00:00
Files
ublas/doc/storage.htm
Michael Stevens 88c5caeea7 From uBLAS project. Ready for regression testing for 1.32.0
svn path=/trunk/boost/libs/numeric/ublas/; revision=23424
2004-07-10 08:40:37 +00:00

540 lines
16 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 1st March 2004), see www.w3.org" />
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii" />
<link href="ublas.css" type="text/css" />
<title>Storage</title>
</head>
<body>
<h1><img src="c++boost.gif" alt="c++boost.gif" align="middle" />
Storage</h1>
<h2><a name="unbounded_array" id="unbounded_array"></a> Unbounded
Array</h2>
<h4>Description</h4>
<p>The templated class <code>unbounded_array&lt;T&gt;</code>
implements a simple C-like array using allocation via
<code>new/delete</code>.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/storage.hpp&gt;<br />
<br />
int main () {<br />
using namespace boost::numeric::ublas;<br />
unbounded_array&lt;double&gt; a (3);<br />
for (unsigned i = 0; i &lt; a.size (); ++ i) {<br />
a [i] = i;<br />
std::cout &lt;&lt; a [i] &lt;&lt; std::endl;<br />
}<br />
}
</pre>
<h4>Definition</h4>
<p>Defined in the header storage.hpp.</p>
<h4>Template parameters</h4>
<table border="1" summary="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>T</code></td>
<td>The type of object stored in the array.</td>
<td></td>
</tr>
</tbody>
</table>
<h4>Model of</h4>
<p>Random Access Container.</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of Random
Access Container.</p>
<h4>Public base classes</h4>
<p>None.</p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>unbounded_array ()</code></td>
<td>Allocates an uninitialized <code>unbounded_array</code> that
holds at most zero elements.</td>
</tr>
<tr>
<td><code>unbounded_array (size_type size)</code></td>
<td>Allocates an uninitialized <code>unbounded_array</code> that
holds at most <code>size</code> elements.</td>
</tr>
<tr>
<td><code>unbounded_array (const unbounded_array
&amp;a)</code></td>
<td>The copy constructor.</td>
</tr>
<tr>
<td><code>~unbounded_array ()</code></td>
<td>Deallocates the <code>unbounded_array</code> itself.</td>
</tr>
<tr>
<td><code>void resize (size_type size, bool preserve =
true)</code></td>
<td>Reallocates an <code>unbounded_array</code> to hold at most
<code>size</code> elements. When <code>preserve == false</code> the
elements values after resize are undefined.</td>
</tr>
<tr>
<td><code>size_type size () const</code></td>
<td>Returns the size of the <code>unbounded_array</code>.</td>
</tr>
<tr>
<td><code>const_reference operator [] (size_type i)
const</code></td>
<td>Returns a <code>const</code> reference of the <code>i</code>
-th element.</td>
</tr>
<tr>
<td><code>reference operator [] (size_type i)</code></td>
<td>Returns a reference of the <code>i</code>-th element.</td>
</tr>
<tr>
<td><code>unbounded_array &amp;operator = (const unbounded_array
&amp;a)</code></td>
<td>The assignment operator.</td>
</tr>
<tr>
<td><code>unbounded_array &amp;assign_temporary (unbounded_array
&amp;a)</code></td>
<td>Assigns a temporary. May change the array <code>a</code>.</td>
</tr>
<tr>
<td><code>void swap (unbounded_array &amp;a)</code></td>
<td>Swaps the contents of the arrays.</td>
</tr>
<tr>
<td><code>pointer insert (pointer it, const value_type
&amp;t)</code></td>
<td>Inserts the value <code>t</code> at <code>it</code>.</td>
</tr>
<tr>
<td><code>void erase (pointer it)</code></td>
<td>Erases the value at <code>it</code>.</td>
</tr>
<tr>
<td><code>void clear ()</code></td>
<td>Clears the array.</td>
</tr>
<tr>
<td><code>const_iterator begin () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the beginning
of the <code>unbounded_array</code>.</td>
</tr>
<tr>
<td><code>const_iterator end () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the end of
the <code>unbounded_array</code>.</td>
</tr>
<tr>
<td><code>iterator begin ()</code></td>
<td>Returns a <code>iterator</code> pointing to the beginning of
the <code>unbounded_array</code>.</td>
</tr>
<tr>
<td><code>iterator end ()</code></td>
<td>Returns a <code>iterator</code> pointing to the end of the
<code>unbounded_array</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rbegin () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
beginning of the reversed <code>unbounded_array</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rend () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
end of the reversed <code>unbounded_array</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator rbegin ()</code></td>
<td>Returns a <code>reverse_iterator</code> pointing to the
beginning of the reversed <code>unbounded_array</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator rend ()</code></td>
<td>Returns a <code>reverse_iterator</code> pointing to the end of
the reversed <code>unbounded_array</code>.</td>
</tr>
</tbody>
</table>
<h2><a name="bounded_array" id="bounded_array"></a> Bounded
Array</h2>
<h4>Description</h4>
<p>The templated class <code>bounded_array&lt;T, N&gt;</code>
implements a simple C-like array.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/storage.hpp&gt;<br />
<br />
int main () {<br />
using namespace boost::numeric::ublas;<br />
bounded_array&lt;double, 3&gt; a (3);<br />
for (unsigned i = 0; i &lt; a.size (); ++ i) {<br />
a [i] = i;<br />
std::cout &lt;&lt; a [i] &lt;&lt; std::endl;<br />
}<br />
}<br />
</pre>
<h4>Definition</h4>
<p>Defined in the header storage.hpp.</p>
<h4>Template parameters</h4>
<table border="1" summary="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>T</code></td>
<td>The type of object stored in the array.</td>
<td></td>
</tr>
<tr>
<td><code>N</code></td>
<td>The allocation size of the array.</td>
<td></td>
</tr>
</tbody>
</table>
<h4>Model of</h4>
<p>Random Access Container.</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of Random
Access Container.</p>
<h4>Public base classes</h4>
<p>None.</p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>bounded_array ()</code></td>
<td>Allocates an uninitialized <code>bounded_array</code> that
holds at most zero elements.</td>
</tr>
<tr>
<td><code>bounded_array (size_type size)</code></td>
<td>Allocates an uninitialized <code>bounded_array</code> that
holds at most <code>size</code> elements.</td>
</tr>
<tr>
<td><code>bounded_array (const bounded_array &amp;a)</code></td>
<td>The copy constructor.</td>
</tr>
<tr>
<td><code>~bounded_array ()</code></td>
<td>Deallocates the <code>bounded_array</code> itself.</td>
</tr>
<tr>
<td><code>void resize (size_type size)</code></td>
<td>Reallocates a <code>bounded_array</code> to hold at most
<code>size</code> elements. When <code>preserve == false</code> the
elements values after resize are undefined.</td>
</tr>
<tr>
<td><code>size_type size () const</code></td>
<td>Returns the size of the <code>bounded_array</code>.</td>
</tr>
<tr>
<td><code>const_reference operator [] (size_type i)
const</code></td>
<td>Returns a <code>const</code> reference of the <code>i</code>
-th element.</td>
</tr>
<tr>
<td><code>reference operator [] (size_type i)</code></td>
<td>Returns a reference of the <code>i</code>-th element.</td>
</tr>
<tr>
<td><code>bounded_array &amp;operator = (const bounded_array
&amp;a)</code></td>
<td>The assignment operator.</td>
</tr>
<tr>
<td><code>bounded_array &amp;assign_temporary (bounded_array
&amp;a)</code></td>
<td>Assigns a temporary. May change the array <code>a</code>.</td>
</tr>
<tr>
<td><code>void swap (bounded_array &amp;a)</code></td>
<td>Swaps the contents of the arrays.</td>
</tr>
<tr>
<td><code>pointer insert (pointer it, const value_type
&amp;t)</code></td>
<td>Inserts the value <code>t</code> at <code>it</code>.</td>
</tr>
<tr>
<td><code>void erase (pointer it)</code></td>
<td>Erases the value at <code>it</code>.</td>
</tr>
<tr>
<td><code>void clear ()</code></td>
<td>Clears the array.</td>
</tr>
<tr>
<td><code>const_iterator begin () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the beginning
of the <code>bounded_array</code>.</td>
</tr>
<tr>
<td><code>const_iterator end () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the end of
the <code>bounded_array</code>.</td>
</tr>
<tr>
<td><code>iterator begin ()</code></td>
<td>Returns a <code>iterator</code> pointing to the beginning of
the <code>bounded_array</code>.</td>
</tr>
<tr>
<td><code>iterator end ()</code></td>
<td>Returns a <code>iterator</code> pointing to the end of the
<code>bounded_array</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rbegin () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
beginning of the reversed <code>bounded_array</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rend () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
end of the reversed <code>bounded_array</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator rbegin ()</code></td>
<td>Returns a <code>reverse_iterator</code> pointing to the
beginning of the reversed <code>bounded_array</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator rend ()</code></td>
<td>Returns a <code>reverse_iterator</code> pointing to the end of
the reversed <code>bounded_array</code>.</td>
</tr>
</tbody>
</table>
<h2><a name="range" id="range"></a> Range</h2>
<h4>Description</h4>
<p>The class <code>range</code> implements base functionality
needed to address ranges of vectors and matrices.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/storage.hpp&gt;<br />
<br />
int main () {<br />
using namespace boost::numeric::ublas;<br />
range r (0, 3);<br />
for (unsigned i = 0; i &lt; r.size (); ++ i) {<br />
std::cout &lt;&lt; r (i) &lt;&lt; std::endl;<br />
}<br />
}<br />
</pre>
<h4>Definition</h4>
<p>Defined in the header storage.hpp.</p>
<h4>Model of</h4>
<p>Reversible Container.</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of Reversible
Container.</p>
<h4>Public base classes</h4>
<p>None.</p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>range (size_type start, size_type stop)</code></td>
<td>Constructs a range from <code>start</code> to <code>stop</code>
.</td>
</tr>
<tr>
<td><code>size_type start () const</code></td>
<td>Returns the beginning of the <code>range</code>.</td>
</tr>
<tr>
<td><code>size_type size () const</code></td>
<td>Returns the size of the <code>range</code>.</td>
</tr>
<tr>
<td><code>const_reference operator [] (size_type i)
const</code></td>
<td>Returns the value <code>start + i</code> of the <code>i</code>
-th element.</td>
</tr>
<tr>
<td><code>range compose (const range &amp;r) const</code></td>
<td>Returns the composite range from <code>start + r.start
()</code> to <code>start + r.start () + r.size ()</code>.</td>
</tr>
<tr>
<td><code>bool operator == (const range &amp;r) const</code></td>
<td>Tests two ranges for equality.</td>
</tr>
<tr>
<td><code>bool operator != (const range &amp;r) const</code></td>
<td>Tests two ranges for inequality.</td>
</tr>
<tr>
<td><code>const_iterator begin () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the beginning
of the <code>range</code>.</td>
</tr>
<tr>
<td><code>const_iterator end () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the end of
the <code>range</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rbegin () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
beginning of the reversed <code>range</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rend () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
end of the reversed <code>range</code>.</td>
</tr>
</tbody>
</table>
<h4>Preconditions</h4>
<ul>
<li><code>start () &lt;= stop ()</code></li>
</ul>
<h2><a name="slice" id="slice"></a> Slice</h2>
<h4>Description</h4>
<p>The class <code>slice</code> implements base functionality
needed to address slices of vectors and matrices.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/storage.hpp&gt;<br />
<br />
int main () {<br />
using namespace boost::numeric::ublas;<br />
slice s (0, 1, 3);<br />
for (unsigned i = 0; i &lt; s.size (); ++ i) {<br />
std::cout &lt;&lt; s (i) &lt;&lt; std::endl;<br />
}<br />
}<br />
</pre>
<h4>Definition</h4>
<p>Defined in the header storage.hpp.</p>
<h4>Model of</h4>
<p>Reversible Container.</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of Reversible
Container.</p>
<h4>Public base classes</h4>
<p>None.</p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>slice (size_type start, size_type stride, size_type
size)</code></td>
<td>Constructs a slice from <code>start</code> to <code>start +
size</code> with stride <code>stride</code>.</td>
</tr>
<tr>
<td><code>size_type start () const</code></td>
<td>Returns the beginning of the <code>slice</code>.</td>
</tr>
<tr>
<td><code>size_type stride () const</code></td>
<td>Returns the stride of the <code>slice</code>.</td>
</tr>
<tr>
<td><code>size_type size () const</code></td>
<td>Returns the size of the <code>slice</code>.</td>
</tr>
<tr>
<td><code>const_reference operator [] (size_type i)
const</code></td>
<td>Returns the value <code>start + i * stride</code> of the
<code>i</code>-th element.</td>
</tr>
<tr>
<td><code>slice compose (const range &amp;r) const</code></td>
<td>Returns the composite slice from <code>start + stride * r.start
()</code> to <code>start + stride * (r.start () + r.size ())</code>
with stride <code>stride</code>.</td>
</tr>
<tr>
<td><code>slice compose (const slice &amp;s) const</code></td>
<td>Returns the composite slice from <code>start + stride * s.start
()</code> to <code>start + stride * s.stride () * (s.start () +
s.size ())</code> with stride <code>stride * s.stride ()</code>
.</td>
</tr>
<tr>
<td><code>bool operator == (const slice &amp;s) const</code></td>
<td>Tests two slices for equality.</td>
</tr>
<tr>
<td><code>bool operator != (const slice &amp;s) const</code></td>
<td>Tests two slices for inequality.</td>
</tr>
<tr>
<td><code>const_iterator begin () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the beginning
of the <code>slice</code>.</td>
</tr>
<tr>
<td><code>const_iterator end () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the end of
the <code>slice</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rbegin () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
beginning of the reversed <code>slice</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rend () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
end of the reversed <code>slice</code>.</td>
</tr>
</tbody>
</table>
<h4>Preconditions</h4>
<ul>
<li><code>start () + i *.stride () &gt;= 0 &amp;&amp; start () + i
* stride () &lt;= <i>maximum value</i>(difference_type)</code> for
all <code>0 &lt;= i &lt; size ()</code></li>
</ul>
<hr />
<p>Copyright (&copy;) 2000-2002 Joerg Walter, Mathias Koch<br />
Permission to copy, use, modify, sell and distribute this document
is granted provided this copyright notice appears in all copies.
This document is provided ``as is'' without express or implied
warranty, and with no claim as to its suitability for any
purpose.</p>
<p>Last revised: 24/06/2004</p>
</body>
</html>