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 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> 14</head> 15<body> 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> 19<h4>Description</h4> 20<p>The templated class <code>vector_range<V></code> allows 21addressing a sub-range of a vector's element.</p> 22<h4>Example</h4> 23<pre> 24#include <boost/numeric/ublas/vector.hpp> 25#include <boost/numeric/ublas/vector_proxy.hpp> 26#include <boost/numeric/ublas/io.hpp> 27 28int main () { 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) 33 vr (i) = i; 34 std::cout << vr << std::endl; 35} 36</pre> 37<h4>Definition</h4> 38<p>Defined in the header vector_proxy.hpp.</p> 39<h4>Template parameters</h4> 40<table border="1" summary="parameters"> 41<tbody> 42<tr> 43<th>Parameter</th> 44<th>Description</th> 45<th>Default</th> 46</tr> 47<tr> 48<td><code>V</code></td> 49<td>The type of vector referenced.</td> 50<td></td> 51</tr> 52</tbody> 53</table> 54<h4>Model of</h4> 55<p><a href="expression_concept.html#vector_expression">Vector Expression</a> 56.</p> 57<p>If the specified range falls outside that of the index range of 58the vector, then the <code>vector_range</code> is not a well formed 59Vector Expression. That is, access to an element which is outside 60of 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> 66<h4>Members</h4> 67<table border="1" summary="members"> 68<tbody> 69<tr> 70<th>Member</th> 71<th>Description</th> 72</tr> 73<tr> 74<td><code>vector_range (vector_type &data, const range 75&r)</code></td> 76<td>Constructs a sub vector.</td> 77</tr> 78<tr> 79<td><code>size_type start () const</code></td> 80<td>Returns the start of the sub vector.</td> 81</tr> 82<tr> 83<td><code>size_type size () const</code></td> 84<td>Returns the size of the sub vector.</td> 85</tr> 86<tr> 87<td><code>const_reference operator () (size_type i) 88const</code></td> 89<td>Returns the value of the <code>i</code>-th element.</td> 90</tr> 91<tr> 92<td><code>reference operator () (size_type i)</code></td> 93<td>Returns a reference of the <code>i</code>-th element.</td> 94</tr> 95<tr> 96<td><code>const_reference operator [] (size_type i) 97const</code></td> 98<td>Returns the value of the <code>i</code>-th element.</td> 99</tr> 100<tr> 101<td><code>reference operator [] (size_type i)</code></td> 102<td>Returns a reference of the <code>i</code>-th element.</td> 103</tr> 104<tr> 105<td><code>vector_range &operator = (const vector_range 106&vr)</code></td> 107<td>The assignment operator.</td> 108</tr> 109<tr> 110<td><code>vector_range &assign_temporary (vector_range 111&vr)</code></td> 112<td>Assigns a temporary. May change the vector range 113<code>vr</code> .</td> 114</tr> 115<tr> 116<td><code>template<class AE><br /> 117vector_range &operator = (const vector_expression<AE> 118&ae)</code></td> 119<td>The extended assignment operator.</td> 120</tr> 121<tr> 122<td><code>template<class AE><br /> 123vector_range &assign (const vector_expression<AE> 124&ae)</code></td> 125<td>Assigns a vector expression to the sub vector. Left and right 126hand side of the assignment should be independent.</td> 127</tr> 128<tr> 129<td><code>template<class AE><br /> 130vector_range &operator += (const vector_expression<AE> 131&ae)</code></td> 132<td>A computed assignment operator. Adds the vector expression to 133the sub vector.</td> 134</tr> 135<tr> 136<td><code>template<class AE><br /> 137vector_range &plus_assign (const vector_expression<AE> 138&ae)</code></td> 139<td>Adds a vector expression to the sub vector. Left and right hand 140side of the assignment should be independent.</td> 141</tr> 142<tr> 143<td><code>template<class AE><br /> 144vector_range &operator -= (const vector_expression<AE> 145&ae)</code></td> 146<td>A computed assignment operator. Subtracts the vector expression 147from the sub vector.</td> 148</tr> 149<tr> 150<td><code>template<class AE><br /> 151vector_range &minus_assign (const vector_expression<AE> 152&ae)</code></td> 153<td>Subtracts a vector expression from the sub vector. Left and 154right hand side of the assignment should be independent.</td> 155</tr> 156<tr> 157<td><code>template<class AT><br /> 158vector_range &operator *= (const AT &at)</code></td> 159<td>A computed assignment operator. Multiplies the sub vector with 160a scalar.</td> 161</tr> 162<tr> 163<td><code>template<class AT><br /> 164vector_range &operator /= (const AT &at)</code></td> 165<td>A computed assignment operator. Divides the sub vector through 166a scalar.</td> 167</tr> 168<tr> 169<td><code>void swap (vector_range &vr)</code></td> 170<td>Swaps the contents of the sub vectors.</td> 171</tr> 172<tr> 173<td><code>const_iterator begin () const</code></td> 174<td>Returns a <code>const_iterator</code> pointing to the beginning 175of the <code>vector_range</code>.</td> 176</tr> 177<tr> 178<td><code>const_iterator end () const</code></td> 179<td>Returns a <code>const_iterator</code> pointing to the end of 180the <code>vector_range</code>.</td> 181</tr> 182<tr> 183<td><code>iterator begin ()</code></td> 184<td>Returns a <code>iterator</code> pointing to the beginning of 185the <code>vector_range</code>.</td> 186</tr> 187<tr> 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> 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>vector_range</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>vector_range</code>.</td> 201</tr> 202<tr> 203<td><code>reverse_iterator rbegin ()</code></td> 204<td>Returns a <code>reverse_iterator</code> pointing to the 205beginning of the reversed <code>vector_range</code>.</td> 206</tr> 207<tr> 208<td><code>reverse_iterator rend ()</code></td> 209<td>Returns a <code>reverse_iterator</code> pointing to the end of 210the reversed <code>vector_range</code>.</td> 211</tr> 212</tbody> 213</table> 214<h3>Simple Projections</h3> 215<h4>Description</h4> 216<p>The free <code>subrange</code> functions support the construction 217of vector ranges.</p> 218<h4>Prototypes</h4> 219<pre><code> 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); 226</code></pre> 227<h3>Generic Projections</h3> 228<h4>Description</h4> 229<p>The free <code>project</code> functions support the construction 230of 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> 231<h4>Prototypes</h4> 232<pre><code> 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); 241</code></pre> 242<h4>Definition</h4> 243<p>Defined in the header vector_proxy.hpp.</p> 244<h4>Type requirements</h4> 245<ul> 246<li><code>V</code> is a model of <a href= 247"expression_concept.html#vector_expression">Vector Expression</a> .</li> 248</ul> 249<h4>Complexity</h4> 250<p>Linear depending from the size of the range.</p> 251<h4>Examples</h4> 252<pre> 253#include <boost/numeric/ublas/vector.hpp> 254#include <boost/numeric/ublas/vector_proxy.hpp> 255#include <boost/numeric/ublas/io.hpp> 256 257int main () { 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; 263} 264</pre> 265<h2><a name="vector_slice"></a>Vector Slice</h2> 266<h4>Description</h4> 267<p>The templated class <code>vector_slice<V></code> allows 268addressing a slice of a vector.</p> 269<h4>Example</h4> 270<pre> 271#include <boost/numeric/ublas/vector.hpp> 272#include <boost/numeric/ublas/vector_proxy.hpp> 273#include <boost/numeric/ublas/io.hpp> 274 275int main () { 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) 280 vs (i) = i; 281 std::cout << vs << std::endl; 282} 283</pre> 284<h4>Definition</h4> 285<p>Defined in the header vector_proxy.hpp.</p> 286<h4>Template parameters</h4> 287<table border="1" summary="parameters"> 288<tbody> 289<tr> 290<th>Parameter</th> 291<th>Description</th> 292<th>Default</th> 293</tr> 294<tr> 295<td><code>V</code></td> 296<td>The type of vector referenced.</td> 297<td></td> 298</tr> 299</tbody> 300</table> 301<h4>Model of</h4> 302<p><a href="expression_concept.html#vector_expression">Vector Expression</a> 303.</p> 304<p>If the specified slice falls outside that of the index range of 305the vector, then the <code>vector_slice</code> is not a well formed 306Vector Expression. That is, access to an element which is outside 307of 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> 313<h4>Members</h4> 314<table border="1" summary="members"> 315<tbody> 316<tr> 317<th>Member</th> 318<th>Description</th> 319</tr> 320<tr> 321<td><code>vector_slice (vector_type &data, const slice 322&s)</code></td> 323<td>Constructs a sub vector.</td> 324</tr> 325<tr> 326<td><code>size_type size () const</code></td> 327<td>Returns the size of the sub vector.</td> 328</tr> 329<tr> 330<td><code>const_reference operator () (size_type i) 331const</code></td> 332<td>Returns the value of the <code>i</code>-th element.</td> 333</tr> 334<tr> 335<td><code>reference operator () (size_type i)</code></td> 336<td>Returns a reference of the <code>i</code>-th element.</td> 337</tr> 338<tr> 339<td><code>const_reference operator [] (size_type i) 340const</code></td> 341<td>Returns the value of the <code>i</code>-th element.</td> 342</tr> 343<tr> 344<td><code>reference operator [] (size_type i)</code></td> 345<td>Returns a reference of the <code>i</code>-th element.</td> 346</tr> 347<tr> 348<td><code>vector_slice &operator = (const vector_slice 349&vs)</code></td> 350<td>The assignment operator.</td> 351</tr> 352<tr> 353<td><code>vector_slice &assign_temporary (vector_slice 354&vs)</code></td> 355<td>Assigns a temporary. May change the vector slice 356<code>vs</code> .</td> 357</tr> 358<tr> 359<td><code>template<class AE><br /> 360vector_slice &operator = (const vector_expression<AE> 361&ae)</code></td> 362<td>The extended assignment operator.</td> 363</tr> 364<tr> 365<td><code>template<class AE><br /> 366vector_slice &assign (const vector_expression<AE> 367&ae)</code></td> 368<td>Assigns a vector expression to the sub vector. Left and right 369hand side of the assignment should be independent.</td> 370</tr> 371<tr> 372<td><code>template<class AE><br /> 373vector_slice &operator += (const vector_expression<AE> 374&ae)</code></td> 375<td>A computed assignment operator. Adds the vector expression to 376the sub vector.</td> 377</tr> 378<tr> 379<td><code>template<class AE><br /> 380vector_slice &plus_assign (const vector_expression<AE> 381&ae)</code></td> 382<td>Adds a vector expression to the sub vector. Left and right hand 383side of the assignment should be independent.</td> 384</tr> 385<tr> 386<td><code>template<class AE><br /> 387vector_slice &operator -= (const vector_expression<AE> 388&ae)</code></td> 389<td>A computed assignment operator. Subtracts the vector expression 390from the sub vector.</td> 391</tr> 392<tr> 393<td><code>template<class AE><br /> 394vector_slice &minus_assign (const vector_expression<AE> 395&ae)</code></td> 396<td>Subtracts a vector expression from the sub vector. Left and 397right hand side of the assignment should be independent.</td> 398</tr> 399<tr> 400<td><code>template<class AT><br /> 401vector_slice &operator *= (const AT &at)</code></td> 402<td>A computed assignment operator. Multiplies the sub vector with 403a scalar.</td> 404</tr> 405<tr> 406<td><code>template<class AT><br /> 407vector_slice &operator /= (const AT &at)</code></td> 408<td>A computed assignment operator. Divides the sub vector through 409a scalar.</td> 410</tr> 411<tr> 412<td><code>void swap (vector_slice &vs)</code></td> 413<td>Swaps the contents of the sub vectors.</td> 414</tr> 415<tr> 416<td><code>const_iterator begin () const</code></td> 417<td>Returns a <code>const_iterator</code> pointing to the beginning 418of the <code>vector_slice</code>.</td> 419</tr> 420<tr> 421<td><code>const_iterator end () const</code></td> 422<td>Returns a <code>const_iterator</code> pointing to the end of 423the <code>vector_slice</code>.</td> 424</tr> 425<tr> 426<td><code>iterator begin ()</code></td> 427<td>Returns a <code>iterator</code> pointing to the beginning of 428the <code>vector_slice</code>.</td> 429</tr> 430<tr> 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> 434</tr> 435<tr> 436<td><code>const_reverse_iterator rbegin () const</code></td> 437<td>Returns a <code>const_reverse_iterator</code> pointing to the 438beginning of the reversed <code>vector_slice</code>.</td> 439</tr> 440<tr> 441<td><code>const_reverse_iterator rend () const</code></td> 442<td>Returns a <code>const_reverse_iterator</code> pointing to the 443end of the reversed <code>vector_slice</code>.</td> 444</tr> 445<tr> 446<td><code>reverse_iterator rbegin ()</code></td> 447<td>Returns a <code>reverse_iterator</code> pointing to the 448beginning of the reversed <code>vector_slice</code>.</td> 449</tr> 450<tr> 451<td><code>reverse_iterator rend ()</code></td> 452<td>Returns a <code>reverse_iterator</code> pointing to the end of 453the reversed <code>vector_slice</code>.</td> 454</tr> 455</tbody> 456</table> 457<h3>Simple Projections</h3> 458<h4>Description</h4> 459<p>The free <code>subslice</code> functions support the construction 460of vector slices.</p> 461<h4>Prototypes</h4> 462<pre><code> 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); 469</code></pre> 470<h3>Generic Projections</h3> 471<h4>Description</h4> 472<p>The free <code>project</code> functions support the construction 473of 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> 474<h4>Prototypes</h4> 475<pre><code> 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); 488</code></pre> 489<h4>Definition</h4> 490<p>Defined in the header vector_proxy.hpp.</p> 491<h4>Type requirements</h4> 492<ul> 493<li><code>V</code> is a model of <a href= 494"expression_concept.html#vector_expression">Vector Expression</a> .</li> 495</ul> 496<h4>Complexity</h4> 497<p>Linear depending from the size of the slice.</p> 498<h4>Examples</h4> 499<pre> 500#include <boost/numeric/ublas/vector.hpp> 501#include <boost/numeric/ublas/vector_proxy.hpp> 502#include <boost/numeric/ublas/io.hpp> 503 504int main () { 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; 510} 511</pre> 512<hr /> 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 519 </a>). 520</p> 521<script type="text/javascript"> 522(function($) { 523 $('#toc').toc(); 524})(jQuery); 525</script> 526</body> 527</html> 528