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 name=
"generator" content=
6 "HTML Tidy for Linux/x86 (vers 1st March 2004), see www.w3.org" />
7 <meta http-equiv=
"Content-Type" content=
8 "text/html; charset=us-ascii" />
9 <link rel=
"stylesheet" href=
"../../../../boost.css" type=
"text/css"/>
10 <link rel=
"stylesheet" href=
"ublas.css" type=
"text/css" />
11 <script type=
"text/javascript" src=
"js/jquery-1.3.2.min.js" async=
"async" ></script>
12 <script type=
"text/javascript" src=
"js/jquery.toc-gw.js" async=
"async" ></script>
13 <title>Vector Proxies
</title>
16 <h1><img src=
"../../../../boost.png" align=
"middle" />Vector Proxies
</h1>
17 <div class=
"toc" id=
"toc"></div>
18 <h2><a name=
"vector_range"></a>Vector Range
</h2>
20 <p>The templated class
<code>vector_range
<V
></code> allows
21 addressing a sub-range of a vector's element.
</p>
24 #include
<boost/numeric/ublas/vector.hpp
>
25 #include
<boost/numeric/ublas/vector_proxy.hpp
>
26 #include
<boost/numeric/ublas/io.hpp
>
29 using namespace boost::numeric::ublas;
30 vector
<double
> v (
3);
31 vector_range
<vector
<double
> > vr (v, range (
0,
3));
32 for (unsigned i =
0; i
< vr.size (); ++ i)
34 std::cout
<< vr
<< std::endl;
38 <p>Defined in the header vector_proxy.hpp.
</p>
39 <h4>Template parameters
</h4>
40 <table border=
"1" summary=
"parameters">
48 <td><code>V
</code></td>
49 <td>The type of vector referenced.
</td>
55 <p><a href=
"expression_concept.html#vector_expression">Vector Expression
</a>
57 <p>If the specified range falls outside that of the index range of
58 the vector, then the
<code>vector_range
</code> is not a well formed
59 Vector Expression. That is, access to an element which is outside
60 of index range of the vector is
<i>undefined
</i>.
</p>
61 <h4>Type requirements
</h4>
62 <p>None, except for those imposed by the requirements of
<a href=
63 "expression_concept.html#vector_expression">Vector Expression
</a> .
</p>
64 <h4>Public base classes
</h4>
65 <p><code>vector_expression
<vector_range
<V
> ></code></p>
67 <table border=
"1" summary=
"members">
74 <td><code>vector_range (vector_type
&data, const range
76 <td>Constructs a sub vector.
</td>
79 <td><code>size_type start () const
</code></td>
80 <td>Returns the start of the sub vector.
</td>
83 <td><code>size_type size () const
</code></td>
84 <td>Returns the size of the sub vector.
</td>
87 <td><code>const_reference operator () (size_type i)
89 <td>Returns the value of the
<code>i
</code>-th element.
</td>
92 <td><code>reference operator () (size_type i)
</code></td>
93 <td>Returns a reference of the
<code>i
</code>-th element.
</td>
96 <td><code>const_reference operator [] (size_type i)
98 <td>Returns the value of the
<code>i
</code>-th element.
</td>
101 <td><code>reference operator [] (size_type i)
</code></td>
102 <td>Returns a reference of the
<code>i
</code>-th element.
</td>
105 <td><code>vector_range
&operator = (const vector_range
107 <td>The assignment operator.
</td>
110 <td><code>vector_range
&assign_temporary (vector_range
112 <td>Assigns a temporary. May change the vector range
113 <code>vr
</code> .
</td>
116 <td><code>template
<class AE
><br />
117 vector_range
&operator = (const vector_expression
<AE
>
119 <td>The extended assignment operator.
</td>
122 <td><code>template
<class AE
><br />
123 vector_range
&assign (const vector_expression
<AE
>
125 <td>Assigns a vector expression to the sub vector. Left and right
126 hand side of the assignment should be independent.
</td>
129 <td><code>template
<class AE
><br />
130 vector_range
&operator += (const vector_expression
<AE
>
132 <td>A computed assignment operator. Adds the vector expression to
136 <td><code>template
<class AE
><br />
137 vector_range
&plus_assign (const vector_expression
<AE
>
139 <td>Adds a vector expression to the sub vector. Left and right hand
140 side of the assignment should be independent.
</td>
143 <td><code>template
<class AE
><br />
144 vector_range
&operator -= (const vector_expression
<AE
>
146 <td>A computed assignment operator. Subtracts the vector expression
147 from the sub vector.
</td>
150 <td><code>template
<class AE
><br />
151 vector_range
&minus_assign (const vector_expression
<AE
>
153 <td>Subtracts a vector expression from the sub vector. Left and
154 right hand side of the assignment should be independent.
</td>
157 <td><code>template
<class AT
><br />
158 vector_range
&operator *= (const AT
&at)
</code></td>
159 <td>A computed assignment operator. Multiplies the sub vector with
163 <td><code>template
<class AT
><br />
164 vector_range
&operator /= (const AT
&at)
</code></td>
165 <td>A computed assignment operator. Divides the sub vector through
169 <td><code>void swap (vector_range
&vr)
</code></td>
170 <td>Swaps the contents of the sub vectors.
</td>
173 <td><code>const_iterator begin () const
</code></td>
174 <td>Returns a
<code>const_iterator
</code> pointing to the beginning
175 of the
<code>vector_range
</code>.
</td>
178 <td><code>const_iterator end () const
</code></td>
179 <td>Returns a
<code>const_iterator
</code> pointing to the end of
180 the
<code>vector_range
</code>.
</td>
183 <td><code>iterator begin ()
</code></td>
184 <td>Returns a
<code>iterator
</code> pointing to the beginning of
185 the
<code>vector_range
</code>.
</td>
188 <td><code>iterator end ()
</code></td>
189 <td>Returns a
<code>iterator
</code> pointing to the end of the
190 <code>vector_range
</code>.
</td>
193 <td><code>const_reverse_iterator rbegin () const
</code></td>
194 <td>Returns a
<code>const_reverse_iterator
</code> pointing to the
195 beginning of the reversed
<code>vector_range
</code>.
</td>
198 <td><code>const_reverse_iterator rend () const
</code></td>
199 <td>Returns a
<code>const_reverse_iterator
</code> pointing to the
200 end of the reversed
<code>vector_range
</code>.
</td>
203 <td><code>reverse_iterator rbegin ()
</code></td>
204 <td>Returns a
<code>reverse_iterator
</code> pointing to the
205 beginning of the reversed
<code>vector_range
</code>.
</td>
208 <td><code>reverse_iterator rend ()
</code></td>
209 <td>Returns a
<code>reverse_iterator
</code> pointing to the end of
210 the reversed
<code>vector_range
</code>.
</td>
214 <h3>Simple Projections
</h3>
216 <p>The free
<code>subrange
</code> functions support the construction
217 of vector ranges.
</p>
220 template
<class V
>
221 vector_range
<V
> subrange (V
&data,
222 V::size_type start, V::size_type stop);
223 template
<class V
>
224 const vector_range
<const V
> subrange (const V
&data,
225 V::size_type start, V::size_type stop);
227 <h3>Generic Projections
</h3>
229 <p>The free
<code>project
</code> functions support the construction
230 of vector ranges. Existing
<code>matrix_range
</code>'s can be composed with a further range. The resulting range is computed using this existing range's
<code>compose
</code> function.
</p>
233 template
<class V
>
234 vector_range
<V
> project (V
&data, const range
&r);
235 template
<class V
>
236 const vector_range
<const V
> project (const V
&data, const range
&r);
237 template
<class V
>
238 vector_range
<V
> project (vector_range
<V
> &data, const range
&r);
239 template
<class V
>
240 const vector_range
<V
> project (const vector_range
<V
> &data, const range
&r);
243 <p>Defined in the header vector_proxy.hpp.
</p>
244 <h4>Type requirements
</h4>
246 <li><code>V
</code> is a model of
<a href=
247 "expression_concept.html#vector_expression">Vector Expression
</a> .
</li>
250 <p>Linear depending from the size of the range.
</p>
253 #include
<boost/numeric/ublas/vector.hpp
>
254 #include
<boost/numeric/ublas/vector_proxy.hpp
>
255 #include
<boost/numeric/ublas/io.hpp
>
258 using namespace boost::numeric::ublas;
259 vector
<double
> v (
3);
260 for (int i =
0; i
< 3; ++ i)
261 project (v, range (
0,
3)) (i) = i;
262 std::cout
<< project (v, range (
0,
3))
<< std::endl;
265 <h2><a name=
"vector_slice"></a>Vector Slice
</h2>
267 <p>The templated class
<code>vector_slice
<V
></code> allows
268 addressing a slice of a vector.
</p>
271 #include
<boost/numeric/ublas/vector.hpp
>
272 #include
<boost/numeric/ublas/vector_proxy.hpp
>
273 #include
<boost/numeric/ublas/io.hpp
>
276 using namespace boost::numeric::ublas;
277 vector
<double
> v (
3);
278 vector_slice
<vector
<double
> > vs (v, slice (
0,
1,
3));
279 for (unsigned i =
0; i
< vs.size (); ++ i)
281 std::cout
<< vs
<< std::endl;
285 <p>Defined in the header vector_proxy.hpp.
</p>
286 <h4>Template parameters
</h4>
287 <table border=
"1" summary=
"parameters">
295 <td><code>V
</code></td>
296 <td>The type of vector referenced.
</td>
302 <p><a href=
"expression_concept.html#vector_expression">Vector Expression
</a>
304 <p>If the specified slice falls outside that of the index range of
305 the vector, then the
<code>vector_slice
</code> is not a well formed
306 Vector Expression. That is, access to an element which is outside
307 of index range of the vector is
<i>undefined
</i>.
</p>
308 <h4>Type requirements
</h4>
309 <p>None, except for those imposed by the requirements of
<a href=
310 "expression_concept.html#vector_expression">Vector Expression
</a> .
</p>
311 <h4>Public base classes
</h4>
312 <p><code>vector_expression
<vector_slice
<V
> ></code></p>
314 <table border=
"1" summary=
"members">
321 <td><code>vector_slice (vector_type
&data, const slice
323 <td>Constructs a sub vector.
</td>
326 <td><code>size_type size () const
</code></td>
327 <td>Returns the size of the sub vector.
</td>
330 <td><code>const_reference operator () (size_type i)
332 <td>Returns the value of the
<code>i
</code>-th element.
</td>
335 <td><code>reference operator () (size_type i)
</code></td>
336 <td>Returns a reference of the
<code>i
</code>-th element.
</td>
339 <td><code>const_reference operator [] (size_type i)
341 <td>Returns the value of the
<code>i
</code>-th element.
</td>
344 <td><code>reference operator [] (size_type i)
</code></td>
345 <td>Returns a reference of the
<code>i
</code>-th element.
</td>
348 <td><code>vector_slice
&operator = (const vector_slice
350 <td>The assignment operator.
</td>
353 <td><code>vector_slice
&assign_temporary (vector_slice
355 <td>Assigns a temporary. May change the vector slice
356 <code>vs
</code> .
</td>
359 <td><code>template
<class AE
><br />
360 vector_slice
&operator = (const vector_expression
<AE
>
362 <td>The extended assignment operator.
</td>
365 <td><code>template
<class AE
><br />
366 vector_slice
&assign (const vector_expression
<AE
>
368 <td>Assigns a vector expression to the sub vector. Left and right
369 hand side of the assignment should be independent.
</td>
372 <td><code>template
<class AE
><br />
373 vector_slice
&operator += (const vector_expression
<AE
>
375 <td>A computed assignment operator. Adds the vector expression to
379 <td><code>template
<class AE
><br />
380 vector_slice
&plus_assign (const vector_expression
<AE
>
382 <td>Adds a vector expression to the sub vector. Left and right hand
383 side of the assignment should be independent.
</td>
386 <td><code>template
<class AE
><br />
387 vector_slice
&operator -= (const vector_expression
<AE
>
389 <td>A computed assignment operator. Subtracts the vector expression
390 from the sub vector.
</td>
393 <td><code>template
<class AE
><br />
394 vector_slice
&minus_assign (const vector_expression
<AE
>
396 <td>Subtracts a vector expression from the sub vector. Left and
397 right hand side of the assignment should be independent.
</td>
400 <td><code>template
<class AT
><br />
401 vector_slice
&operator *= (const AT
&at)
</code></td>
402 <td>A computed assignment operator. Multiplies the sub vector with
406 <td><code>template
<class AT
><br />
407 vector_slice
&operator /= (const AT
&at)
</code></td>
408 <td>A computed assignment operator. Divides the sub vector through
412 <td><code>void swap (vector_slice
&vs)
</code></td>
413 <td>Swaps the contents of the sub vectors.
</td>
416 <td><code>const_iterator begin () const
</code></td>
417 <td>Returns a
<code>const_iterator
</code> pointing to the beginning
418 of the
<code>vector_slice
</code>.
</td>
421 <td><code>const_iterator end () const
</code></td>
422 <td>Returns a
<code>const_iterator
</code> pointing to the end of
423 the
<code>vector_slice
</code>.
</td>
426 <td><code>iterator begin ()
</code></td>
427 <td>Returns a
<code>iterator
</code> pointing to the beginning of
428 the
<code>vector_slice
</code>.
</td>
431 <td><code>iterator end ()
</code></td>
432 <td>Returns a
<code>iterator
</code> pointing to the end of the
433 <code>vector_slice
</code>.
</td>
436 <td><code>const_reverse_iterator rbegin () const
</code></td>
437 <td>Returns a
<code>const_reverse_iterator
</code> pointing to the
438 beginning of the reversed
<code>vector_slice
</code>.
</td>
441 <td><code>const_reverse_iterator rend () const
</code></td>
442 <td>Returns a
<code>const_reverse_iterator
</code> pointing to the
443 end of the reversed
<code>vector_slice
</code>.
</td>
446 <td><code>reverse_iterator rbegin ()
</code></td>
447 <td>Returns a
<code>reverse_iterator
</code> pointing to the
448 beginning of the reversed
<code>vector_slice
</code>.
</td>
451 <td><code>reverse_iterator rend ()
</code></td>
452 <td>Returns a
<code>reverse_iterator
</code> pointing to the end of
453 the reversed
<code>vector_slice
</code>.
</td>
457 <h3>Simple Projections
</h3>
459 <p>The free
<code>subslice
</code> functions support the construction
460 of vector slices.
</p>
463 template
<class V
>
464 vector_slice
<V
> subslice (V
&data,
465 V::size_type start, V::difference_type stride, V::size_type size);
466 template
<class V
>
467 const vector_slice
<const V
> subslice (const V
&data,
468 V::size_type start, V::difference_type stride, V::size_type size);
470 <h3>Generic Projections
</h3>
472 <p>The free
<code>project
</code> functions support the construction
473 of vector slices. Existing
<code>vector_slice
</code>'s can be composed with a further range or slices. The resulting slice is computed using this existing slices's
<code>compose
</code> function.
</p>
476 template
<class V
>
477 vector_slice
<V
> project (V
&data, const slice
&s);
478 template
<class V
>
479 const vector_slice
<const V
> project (const V
&data, const slice
&s);
480 template
<class V
>
481 vector_slice
<V
> project (vector_slice
<V
> &data, const range
&r);
482 template
<class V
>
483 const vector_slice
<V
> project (const vector_slice
<V
> &data, const range
&r);
484 template
<class V
>
485 vector_slice
<V
> project (vector_slice
<V
> &data, const slice
&s);
486 template
<class V
>
487 const vector_slice
<V
> project (const vector_slice
<V
> &data, const slice
&s);
490 <p>Defined in the header vector_proxy.hpp.
</p>
491 <h4>Type requirements
</h4>
493 <li><code>V
</code> is a model of
<a href=
494 "expression_concept.html#vector_expression">Vector Expression
</a> .
</li>
497 <p>Linear depending from the size of the slice.
</p>
500 #include
<boost/numeric/ublas/vector.hpp
>
501 #include
<boost/numeric/ublas/vector_proxy.hpp
>
502 #include
<boost/numeric/ublas/io.hpp
>
505 using namespace boost::numeric::ublas;
506 vector
<double
> v (
3);
507 for (int i =
0; i
< 3; ++ i)
508 project (v, slice (
0,
1,
3)) (i) = i;
509 std::cout
<< project (v, slice (
0,
1,
3))
<< std::endl;
513 <p>Copyright (
©)
2000-
2002 Joerg Walter, Mathias Koch
<br />
514 Use, modification and distribution are subject to the
515 Boost Software License, Version
1.0.
516 (See accompanying file LICENSE_1_0.txt
517 or copy at
<a href=
"http://www.boost.org/LICENSE_1_0.txt">
518 http://www.boost.org/LICENSE_1_0.txt
521 <script type=
"text/javascript">