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">
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>
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
<SizeType,DistanceType
></h2>
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>
22 #include
<boost/numeric/ublas/storage.hpp
>
25 using namespace boost::numeric::ublas;
27 for (unsigned i =
0; i
< r.size (); ++ i) {
28 std::cout
<< r (i)
<< std::endl;
33 <p>Defined in the header storage.hpp.
</p>
35 <p>Reversible Container.
</p>
36 <h4>Type requirements
</h4>
37 <p>None, except for those imposed by the requirements of Reversible
39 <h4>Public base classes
</h4>
42 <table border=
"1" summary=
"members">
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>
54 <td><code>size_type start () const
</code></td>
55 <td>Returns the beginning of the
<code>range
</code>.
</td>
58 <td><code>size_type size () const
</code></td>
59 <td>Returns the size of the
<code>range
</code>.
</td>
62 <td><code>const_reference operator [] (size_type i)
64 <td>Returns the value
<code>start + i
</code> of the
<code>i
</code>
68 <td><code>range compose (const range
&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>
73 <td><code>bool operator == (const range
&r) const
</code></td>
74 <td>Tests two ranges for equality.
</td>
77 <td><code>bool operator != (const range
&r) const
</code></td>
78 <td>Tests two ranges for inequality.
</td>
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>
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>
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>
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>
102 <h4>Preconditions
</h4>
104 <li><code>start ()
<= stop ()
</code></li>
107 <h2><a name=
"slice"></a>Slice
<SizeType,DistanceType
></h2>
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>
114 #include
<boost/numeric/ublas/storage.hpp
>
117 using namespace boost::numeric::ublas;
119 for (unsigned i =
0; i
< s.size (); ++ i) {
120 std::cout
<< s (i)
<< std::endl;
125 <p>Defined in the header storage.hpp.
</p>
127 <p>Reversible Container.
</p>
128 <h4>Type requirements
</h4>
129 <p>None, except for those imposed by the requirements of Reversible
131 <h4>Public base classes
</h4>
134 <table border=
"1" summary=
"members">
141 <td><code>slice (size_type start, size_type stride, size_type
143 <td>Constructs a slice
<code>start,start+stride,start+
2*stride...
</code> with
144 <code>size
</code> elements.
</td>
147 <td><code>size_type start () const
</code></td>
148 <td>Returns the beginning of the
<code>slice
</code>.
</td>
151 <td><code>size_type stride () const
</code></td>
152 <td>Returns the stride of the
<code>slice
</code>.
</td>
155 <td><code>size_type size () const
</code></td>
156 <td>Returns the size of the
<code>slice
</code>.
</td>
159 <td><code>const_reference operator [] (size_type i)
161 <td>Returns the value
<code>start + i * stride
</code> of the
162 <code>i
</code>-th element.
</td>
165 <td><code>slice compose (const range
&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>
171 <td><code>slice compose (const slice
&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>
178 <td><code>bool operator == (const slice
&s) const
</code></td>
179 <td>Tests two slices for equality.
</td>
182 <td><code>bool operator != (const slice
&s) const
</code></td>
183 <td>Tests two slices for inequality.
</td>
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>
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>
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>
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>
207 <h4>Preconditions
</h4>
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>
214 Copyright (
©)
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
223 <script type=
"text/javascript">