Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/numeric/ublas/doc/range.htm @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 6.5 KB
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
6<link href="ublas.css" type="text/css" />
7<title>Range and slice</title>
8</head>
9<body>
10<h1><img src="../../../../boost.png" align="middle" />
11Range and Slice Storage</h1>
12<h2><a name="range" id="range"></a>Range&lt;SizeType,DistanceType&gt;</h2>
13<h4>Description</h4>
14<p>The class <code>range</code> specifies a range of indicies. The range is a sequence of indices
15from a start value to stop value. The indices increase by one and exlude the stop value.
16<code>range</code> can therefore be used to specify ranges of elements from vectors and matrices.</p>
17<h4>Example</h4>
18<pre>
19#include &lt;boost/numeric/ublas/storage.hpp&gt;
20
21int main () {
22    using namespace boost::numeric::ublas;
23    range r (0, 3);
24    for (unsigned i = 0; i &lt; r.size (); ++ i) {
25        std::cout &lt;&lt; r (i) &lt;&lt; std::endl;
26    }
27}
28</pre>
29<h4>Definition</h4>
30<p>Defined in the header storage.hpp.</p>
31<h4>Model of</h4>
32<p>Reversible Container.</p>
33<h4>Type requirements</h4>
34<p>None, except for those imposed by the requirements of Reversible
35Container.</p>
36<h4>Public base classes</h4>
37<p>None.</p>
38<h4>Members</h4>
39<table border="1" summary="members">
40<tbody>
41<tr>
42<th>Member</th>
43<th>Description</th>
44</tr>
45<tr>
46<td><code>range (size_type start, size_type stop)</code></td>
47<td>Constructs a range of indicies from <code>start</code> to <code>stop (excluded)</code>
48.</td>
49</tr>
50<tr>
51<td><code>size_type start () const</code></td>
52<td>Returns the beginning of the <code>range</code>.</td>
53</tr>
54<tr>
55<td><code>size_type size () const</code></td>
56<td>Returns the size of the <code>range</code>.</td>
57</tr>
58<tr>
59<td><code>const_reference operator [] (size_type i)
60const</code></td>
61<td>Returns the value <code>start + i</code> of the <code>i</code>
62-th element.</td>
63</tr>
64<tr>
65<td><code>range compose (const range &amp;r) const</code></td>
66<td>Returns the composite range from <code>start + r.start
67()</code> to <code>start + r.start () + r.size ()</code>.</td>
68</tr>
69<tr>
70<td><code>bool operator == (const range &amp;r) const</code></td>
71<td>Tests two ranges for equality.</td>
72</tr>
73<tr>
74<td><code>bool operator != (const range &amp;r) const</code></td>
75<td>Tests two ranges for inequality.</td>
76</tr>
77<tr>
78<td><code>const_iterator begin () const</code></td>
79<td>Returns a <code>const_iterator</code> pointing to the beginning
80of the <code>range</code>.</td>
81</tr>
82<tr>
83<td><code>const_iterator end () const</code></td>
84<td>Returns a <code>const_iterator</code> pointing to the end of
85the <code>range</code>.</td>
86</tr>
87<tr>
88<td><code>const_reverse_iterator rbegin () const</code></td>
89<td>Returns a <code>const_reverse_iterator</code> pointing to the
90beginning of the reversed <code>range</code>.</td>
91</tr>
92<tr>
93<td><code>const_reverse_iterator rend () const</code></td>
94<td>Returns a <code>const_reverse_iterator</code> pointing to the
95end of the reversed <code>range</code>.</td>
96</tr>
97</tbody>
98</table>
99<h4>Preconditions</h4>
100<ul>
101<li><code>start () &lt;= stop ()</code></li>
102</ul>
103
104<h2><a name="slice" id="slice"></a>Slice&lt;SizeType,DistanceType&gt;</h2>
105<h4>Description</h4>
106<p>The class <code>slice</code> specifies a 'slice' of indicies. Slices are more general
107then ranges, the stride allows the sequence of indicies to increase and decrease by the specified amount between element.
108<code>slice</code> can therefore be used to specify slices of element from vectors and matrices.</p>
109<h4>Example</h4>
110<pre>
111#include &lt;boost/numeric/ublas/storage.hpp&gt;
112
113int main () {
114    using namespace boost::numeric::ublas;
115    slice s (0, 1, 3);
116    for (unsigned i = 0; i &lt; s.size (); ++ i) {
117        std::cout &lt;&lt; s (i) &lt;&lt; std::endl;
118    }
119}
120</pre>
121<h4>Definition</h4>
122<p>Defined in the header storage.hpp.</p>
123<h4>Model of</h4>
124<p>Reversible Container.</p>
125<h4>Type requirements</h4>
126<p>None, except for those imposed by the requirements of Reversible
127Container.</p>
128<h4>Public base classes</h4>
129<p>None.</p>
130<h4>Members</h4>
131<table border="1" summary="members">
132<tbody>
133<tr>
134<th>Member</th>
135<th>Description</th>
136</tr>
137<tr>
138<td><code>slice (size_type start, size_type stride, size_type
139size)</code></td>
140<td>Constructs a slice <code>start,start+stride,start+2*stride...</code> with
141<code>size</code> elements.</td>
142</tr>
143<tr>
144<td><code>size_type start () const</code></td>
145<td>Returns the beginning of the <code>slice</code>.</td>
146</tr>
147<tr>
148<td><code>size_type stride () const</code></td>
149<td>Returns the stride of the <code>slice</code>.</td>
150</tr>
151<tr>
152<td><code>size_type size () const</code></td>
153<td>Returns the size of the <code>slice</code>.</td>
154</tr>
155<tr>
156<td><code>const_reference operator [] (size_type i)
157const</code></td>
158<td>Returns the value <code>start + i * stride</code> of the
159<code>i</code>-th element.</td>
160</tr>
161<tr>
162<td><code>slice compose (const range &amp;r) const</code></td>
163<td>Returns the composite slice from <code>start + stride * r.start
164()</code> to <code>start + stride * (r.start () + r.size ())</code>
165with stride <code>stride</code>.</td>
166</tr>
167<tr>
168<td><code>slice compose (const slice &amp;s) const</code></td>
169<td>Returns the composite slice from <code>start + stride * s.start
170()</code> to <code>start + stride * s.stride () * (s.start () +
171s.size ())</code> with stride <code>stride * s.stride ()</code>
172.</td>
173</tr>
174<tr>
175<td><code>bool operator == (const slice &amp;s) const</code></td>
176<td>Tests two slices for equality.</td>
177</tr>
178<tr>
179<td><code>bool operator != (const slice &amp;s) const</code></td>
180<td>Tests two slices for inequality.</td>
181</tr>
182<tr>
183<td><code>const_iterator begin () const</code></td>
184<td>Returns a <code>const_iterator</code> pointing to the beginning
185of the <code>slice</code>.</td>
186</tr>
187<tr>
188<td><code>const_iterator end () const</code></td>
189<td>Returns a <code>const_iterator</code> pointing to the end of
190the <code>slice</code>.</td>
191</tr>
192<tr>
193<td><code>const_reverse_iterator rbegin () const</code></td>
194<td>Returns a <code>const_reverse_iterator</code> pointing to the
195beginning of the reversed <code>slice</code>.</td>
196</tr>
197<tr>
198<td><code>const_reverse_iterator rend () const</code></td>
199<td>Returns a <code>const_reverse_iterator</code> pointing to the
200end of the reversed <code>slice</code>.</td>
201</tr>
202</tbody>
203</table>
204<h4>Preconditions</h4>
205<ul>
206<li>None all strides are vaild. However when an index is returned or an iterator is dereferenced its
207value must be representable as the size_type.</li>
208</ul>
209</body>
210</html>
Note: See TracBrowser for help on using the repository browser.