Imported Upstream version 1.51.0
[platform/upstream/boost.git] / libs / numeric / ublas / doc / range.htm
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 rel="stylesheet" href="../../../../boost.css" type="text/css"/>
7 <link rel="stylesheet" href="ublas.css" type="text/css" />
8 <script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
9 <script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
10 <title>Range and slice</title>
11 </head>
12 <body>
13 <h1><img src="../../../../boost.png" align="middle" />Range and Slice Storage</h1>
14 <div class="toc" id="toc"></div>
15 <h2><a name="range"></a>Range&lt;SizeType,DistanceType&gt;</h2>
16 <h4>Description</h4>
17 <p>The class <code>range</code> specifies a range of indicies. The range is a sequence of indices
18 from a start value to stop value. The indices increase by one and exlude the stop value.
19 <code>range</code> can therefore be used to specify ranges of elements from vectors and matrices.</p>
20 <h4>Example</h4>
21 <pre>
22 #include &lt;boost/numeric/ublas/storage.hpp&gt;
23
24 int main () {
25     using namespace boost::numeric::ublas;
26     range r (0, 3);
27     for (unsigned i = 0; i &lt; r.size (); ++ i) {
28         std::cout &lt;&lt; r (i) &lt;&lt; std::endl;
29     }
30 }
31 </pre>
32 <h4>Definition</h4>
33 <p>Defined in the header storage.hpp.</p>
34 <h4>Model of</h4>
35 <p>Reversible Container.</p>
36 <h4>Type requirements</h4>
37 <p>None, except for those imposed by the requirements of Reversible
38 Container.</p>
39 <h4>Public base classes</h4>
40 <p>None.</p>
41 <h4>Members</h4>
42 <table border="1" summary="members">
43 <tbody>
44 <tr>
45 <th>Member</th>
46 <th>Description</th>
47 </tr>
48 <tr>
49 <td><code>range (size_type start, size_type stop)</code></td>
50 <td>Constructs a range of indicies from <code>start</code> to <code>stop (excluded)</code>
51 .</td>
52 </tr>
53 <tr>
54 <td><code>size_type start () const</code></td>
55 <td>Returns the beginning of the <code>range</code>.</td>
56 </tr>
57 <tr>
58 <td><code>size_type size () const</code></td>
59 <td>Returns the size of the <code>range</code>.</td>
60 </tr>
61 <tr>
62 <td><code>const_reference operator [] (size_type i)
63 const</code></td>
64 <td>Returns the value <code>start + i</code> of the <code>i</code>
65 -th element.</td>
66 </tr>
67 <tr>
68 <td><code>range compose (const range &amp;r) const</code></td>
69 <td>Returns the composite range from <code>start + r.start
70 ()</code> to <code>start + r.start () + r.size ()</code>.</td>
71 </tr>
72 <tr>
73 <td><code>bool operator == (const range &amp;r) const</code></td>
74 <td>Tests two ranges for equality.</td>
75 </tr>
76 <tr>
77 <td><code>bool operator != (const range &amp;r) const</code></td>
78 <td>Tests two ranges for inequality.</td>
79 </tr>
80 <tr>
81 <td><code>const_iterator begin () const</code></td>
82 <td>Returns a <code>const_iterator</code> pointing to the beginning
83 of the <code>range</code>.</td>
84 </tr>
85 <tr>
86 <td><code>const_iterator end () const</code></td>
87 <td>Returns a <code>const_iterator</code> pointing to the end of
88 the <code>range</code>.</td>
89 </tr>
90 <tr>
91 <td><code>const_reverse_iterator rbegin () const</code></td>
92 <td>Returns a <code>const_reverse_iterator</code> pointing to the
93 beginning of the reversed <code>range</code>.</td>
94 </tr>
95 <tr>
96 <td><code>const_reverse_iterator rend () const</code></td>
97 <td>Returns a <code>const_reverse_iterator</code> pointing to the
98 end of the reversed <code>range</code>.</td>
99 </tr>
100 </tbody>
101 </table>
102 <h4>Preconditions</h4>
103 <ul>
104 <li><code>start () &lt;= stop ()</code></li>
105 </ul>
106
107 <h2><a name="slice"></a>Slice&lt;SizeType,DistanceType&gt;</h2>
108 <h4>Description</h4>
109 <p>The class <code>slice</code> specifies a 'slice' of indicies. Slices are more general
110 then ranges, the stride allows the sequence of indicies to increase and decrease by the specified amount between element.
111 <code>slice</code> can therefore be used to specify slices of element from vectors and matrices.</p>
112 <h4>Example</h4>
113 <pre>
114 #include &lt;boost/numeric/ublas/storage.hpp&gt;
115
116 int main () {
117     using namespace boost::numeric::ublas;
118     slice s (0, 1, 3);
119     for (unsigned i = 0; i &lt; s.size (); ++ i) {
120         std::cout &lt;&lt; s (i) &lt;&lt; std::endl;
121     }
122 }
123 </pre>
124 <h4>Definition</h4>
125 <p>Defined in the header storage.hpp.</p>
126 <h4>Model of</h4>
127 <p>Reversible Container.</p>
128 <h4>Type requirements</h4>
129 <p>None, except for those imposed by the requirements of Reversible
130 Container.</p>
131 <h4>Public base classes</h4>
132 <p>None.</p>
133 <h4>Members</h4>
134 <table border="1" summary="members">
135 <tbody>
136 <tr>
137 <th>Member</th>
138 <th>Description</th>
139 </tr>
140 <tr>
141 <td><code>slice (size_type start, size_type stride, size_type
142 size)</code></td>
143 <td>Constructs a slice <code>start,start+stride,start+2*stride...</code> with 
144 <code>size</code> elements.</td>
145 </tr>
146 <tr>
147 <td><code>size_type start () const</code></td>
148 <td>Returns the beginning of the <code>slice</code>.</td>
149 </tr>
150 <tr>
151 <td><code>size_type stride () const</code></td>
152 <td>Returns the stride of the <code>slice</code>.</td>
153 </tr>
154 <tr>
155 <td><code>size_type size () const</code></td>
156 <td>Returns the size of the <code>slice</code>.</td>
157 </tr>
158 <tr>
159 <td><code>const_reference operator [] (size_type i)
160 const</code></td>
161 <td>Returns the value <code>start + i * stride</code> of the
162 <code>i</code>-th element.</td>
163 </tr>
164 <tr>
165 <td><code>slice compose (const range &amp;r) const</code></td>
166 <td>Returns the composite slice from <code>start + stride * r.start
167 ()</code> to <code>start + stride * (r.start () + r.size ())</code>
168 with stride <code>stride</code>.</td>
169 </tr>
170 <tr>
171 <td><code>slice compose (const slice &amp;s) const</code></td>
172 <td>Returns the composite slice from <code>start + stride * s.start
173 ()</code> to <code>start + stride * s.stride () * (s.start () +
174 s.size ())</code> with stride <code>stride * s.stride ()</code>
175 .</td>
176 </tr>
177 <tr>
178 <td><code>bool operator == (const slice &amp;s) const</code></td>
179 <td>Tests two slices for equality.</td>
180 </tr>
181 <tr>
182 <td><code>bool operator != (const slice &amp;s) const</code></td>
183 <td>Tests two slices for inequality.</td>
184 </tr>
185 <tr>
186 <td><code>const_iterator begin () const</code></td>
187 <td>Returns a <code>const_iterator</code> pointing to the beginning
188 of the <code>slice</code>.</td>
189 </tr>
190 <tr>
191 <td><code>const_iterator end () const</code></td>
192 <td>Returns a <code>const_iterator</code> pointing to the end of
193 the <code>slice</code>.</td>
194 </tr>
195 <tr>
196 <td><code>const_reverse_iterator rbegin () const</code></td>
197 <td>Returns a <code>const_reverse_iterator</code> pointing to the
198 beginning of the reversed <code>slice</code>.</td>
199 </tr>
200 <tr>
201 <td><code>const_reverse_iterator rend () const</code></td>
202 <td>Returns a <code>const_reverse_iterator</code> pointing to the
203 end of the reversed <code>slice</code>.</td>
204 </tr>
205 </tbody>
206 </table>
207 <h4>Preconditions</h4>
208 <ul>
209 <li>None all strides are vaild. However when an index is returned or an iterator is dereferenced its
210 value must be representable as the size_type.</li>
211 </ul>
212    <hr/>
213    <p>
214       Copyright (&copy;) 2000-2004 Michael Stevens, Mathias Koch,
215       Joerg Walter, Gunter Winkler<br />
216       Use, modification and distribution are subject to the
217       Boost Software License, Version 1.0.
218       (See accompanying file LICENSE_1_0.txt
219       or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
220          http://www.boost.org/LICENSE_1_0.txt
221       </a>).
222    </p>
223 <script type="text/javascript">
224 (function($) {
225     $('#toc').toc();
226 })(jQuery);
227 </script>
228 </body>
229 </html>