Brian Silverman | dc6866b | 2018-08-05 00:18:23 -0700 | [diff] [blame^] | 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</title> |
| 14 | </head> |
| 15 | <body> |
| 16 | <h1><img src="../../../../boost.png" align="middle" />Vector</h1> |
| 17 | <div class="toc" id="toc"></div> |
| 18 | <h2><a name="vector"></a>Vector</h2> |
| 19 | <h4>Description</h4> |
| 20 | <p>The templated class <code>vector<T, A></code> is the base |
| 21 | container adaptor for dense vectors. For a <em>n</em>-dimensional |
| 22 | vector and <em>0 <= i < n</em> every element |
| 23 | <em>v</em><sub><em>i</em></sub> is mapped to the <em>i-</em>th |
| 24 | element of the container.</p> |
| 25 | <h4>Example</h4> |
| 26 | <pre> |
| 27 | #include <boost/numeric/ublas/vector.hpp> |
| 28 | #include <boost/numeric/ublas/io.hpp> |
| 29 | |
| 30 | int main () { |
| 31 | using namespace boost::numeric::ublas; |
| 32 | vector<double> v (3); |
| 33 | for (unsigned i = 0; i < v.size (); ++ i) |
| 34 | v (i) = i; |
| 35 | std::cout << v << std::endl; |
| 36 | } |
| 37 | </pre> |
| 38 | <h4>Definition</h4> |
| 39 | <p>Defined in the header vector.hpp.</p> |
| 40 | <h4>Template parameters</h4> |
| 41 | <table border="1" summary="parameters"> |
| 42 | <tbody> |
| 43 | <tr> |
| 44 | <th>Parameter</th> |
| 45 | <th>Description</th> |
| 46 | <th>Default</th> |
| 47 | </tr> |
| 48 | <tr> |
| 49 | <td><code>T</code></td> |
| 50 | <td>The type of object stored in the vector.</td> |
| 51 | <td></td> |
| 52 | </tr> |
| 53 | <tr> |
| 54 | <td><code>A</code></td> |
| 55 | <td>The type of the <a href="storage_concept.html">Storage</a> array. <a href="#vector_1">[1]</a></td> |
| 56 | <td><code>unbounded_array<T></code></td> |
| 57 | </tr> |
| 58 | </tbody> |
| 59 | </table> |
| 60 | <h4>Model of</h4> |
| 61 | <p><a href="container_concept.html#vector">Vector</a>, |
| 62 | <a href="http://www.sgi.com/tech/stl/RandomAccessContainer.html">RandomAccessContainer</a> |
| 63 | </p> |
| 64 | <h4>Type requirements</h4> |
| 65 | <p>None, except for those imposed by the requirements of <a href= |
| 66 | "container_concept.html#vector">Vector</a> |
| 67 | and <a href="http://www.sgi.com/tech/stl/RandomAccessContainer.html">RandomAccessContainer</a>.</p> |
| 68 | <h4>Public base classes</h4> |
| 69 | <p><code>vector_container<vector<T, A> ></code></p> |
| 70 | <h4>Members</h4> |
| 71 | <table border="1" summary="members"> |
| 72 | <tbody> |
| 73 | <tr> |
| 74 | <th>Member</th> |
| 75 | <th>Where defined</th> |
| 76 | <th>Description</th> |
| 77 | </tr> |
| 78 | <tr> |
| 79 | <td><code>value_type</code> |
| 80 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 81 | <td></td> |
| 82 | </tr> |
| 83 | <tr> |
| 84 | <td><code>reference</code> |
| 85 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 86 | <td></td> |
| 87 | </tr> |
| 88 | <tr> |
| 89 | <td><code>const_reference</code> |
| 90 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 91 | <td></td> |
| 92 | </tr> |
| 93 | <tr> |
| 94 | <td><code>size_type</code> |
| 95 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 96 | <td></td> |
| 97 | </tr> |
| 98 | <tr> |
| 99 | <td><code>difference_type</code> |
| 100 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 101 | <td></td> |
| 102 | </tr> |
| 103 | <tr> |
| 104 | <td><code>const_iterator</code> |
| 105 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 106 | <td></td> |
| 107 | </tr> |
| 108 | <tr> |
| 109 | <td><code>iterator</code> |
| 110 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 111 | <td></td> |
| 112 | </tr> |
| 113 | <tr> |
| 114 | <td><code>const_reverse_iterator</code> |
| 115 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 116 | <td></td> |
| 117 | </tr> |
| 118 | <tr> |
| 119 | <td><code>reverse_iterator</code> |
| 120 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 121 | <td></td> |
| 122 | </tr> |
| 123 | <tr> |
| 124 | <td><code>array_type</code> |
| 125 | <td><a href="container_concept.html#vector">Vector</a></td> |
| 126 | <td></td> |
| 127 | </tr> |
| 128 | <tr> |
| 129 | <td><code>vector ()</code></td> |
| 130 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 131 | <td>Allocates an uninitialized <code>vector</code> that holds zero |
| 132 | elements.</td> |
| 133 | </tr> |
| 134 | <tr> |
| 135 | <td><code>vector (size_type size)</code></td> |
| 136 | <td><a href="container_concept.html#vector">Vector</a></td> |
| 137 | <td>Allocates an uninitialized <code>vector</code> that holds |
| 138 | <code>size</code> elements.</td> |
| 139 | </tr> |
| 140 | <tr> |
| 141 | <td><code>vector (const vector &v)</code></td> |
| 142 | <td></td> |
| 143 | <td>The copy constructor.</td> |
| 144 | </tr> |
| 145 | <tr> |
| 146 | <td><code>template<class AE><br /> |
| 147 | vector (const vector_expression<AE> &ae)</code></td> |
| 148 | <td></td> |
| 149 | <td>The extended copy constructor.</td> |
| 150 | </tr> |
| 151 | <tr> |
| 152 | <td><code>void resize (size_type size, bool preserve = |
| 153 | true)</code></td> |
| 154 | <td><a href="container_concept.html#vector">Vector</a></td> |
| 155 | <td>Reallocates a <code>vector</code> to hold <code>size</code> |
| 156 | elements. The existing elements of the <code>vector</code> are |
| 157 | preseved when specified.</td> |
| 158 | </tr> |
| 159 | <tr> |
| 160 | <td><code>size_type size () const</code></td> |
| 161 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 162 | <td>Returns the size of the <code>vector</code>.</td> |
| 163 | </tr> |
| 164 | <tr> |
| 165 | <td><code>size_type max_size () const</code></td> |
| 166 | <td><a href="http://www.sgi.com/tech/stl/RandomAccessContainer.html">RandomAccessContainer</a></td> |
| 167 | <td>Returns the upper bound on the size of the <code>vector</code>.</td> |
| 168 | </tr> |
| 169 | <tr> |
| 170 | <td><code>bool empty () const</code></td> |
| 171 | <td><a href="http://www.sgi.com/tech/stl/RandomAccessContainer.html">RandomAccessContainer</a></td> |
| 172 | <td>Equivilent to <code>size () == 0</code>.</td> |
| 173 | </tr> |
| 174 | <tr> |
| 175 | <td><code>const array_type& data () const</code></td> |
| 176 | <td><a href="container_concept.html#vector">Vector</a></td> |
| 177 | <td></td> |
| 178 | </tr> |
| 179 | <tr> |
| 180 | <td><code>array_type& data ()</code></td> |
| 181 | <td><a href="container_concept.html#vector">Vector</a></td> |
| 182 | <td></td> |
| 183 | </tr> |
| 184 | <tr> |
| 185 | <td><code>const_reference operator () (size_type i) |
| 186 | const</code></td> |
| 187 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 188 | <td>Returns a <code>const</code> reference of the <code>i</code> |
| 189 | -th element.</td> |
| 190 | </tr> |
| 191 | <tr> |
| 192 | <td><code>reference operator () (size_type i)</code></td> |
| 193 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 194 | <td>Returns a reference of the <code>i</code>-th element.</td> |
| 195 | </tr> |
| 196 | <tr> |
| 197 | <td><code>const_reference operator [] (size_type i) const</code></td> |
| 198 | <td><a href="container_concept.html#vector">Vector</a></td> |
| 199 | <td>Returns a <code>const</code> reference of the <code>i</code> |
| 200 | -th element.</td> |
| 201 | </tr> |
| 202 | <tr> |
| 203 | <td><code>reference operator [] (size_type i)</code></td> |
| 204 | <td><a href="container_concept.html#vector">Vector</a></td> |
| 205 | <td>Returns a reference of the <code>i</code>-th element.</td> |
| 206 | </tr> |
| 207 | <tr> |
| 208 | <td><code>vector &operator = (const vector &v)</code></td> |
| 209 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 210 | <td>The assignment operator.</td> |
| 211 | </tr> |
| 212 | <tr> |
| 213 | <td><code>vector &assign_temporary (vector &v)</code></td> |
| 214 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 215 | <td>Assigns a temporary. May change the vector <code>v</code>.</td> |
| 216 | </tr> |
| 217 | <tr> |
| 218 | <td><code>template<class AE><br /> |
| 219 | vector &operator = (const vector_expression<AE> |
| 220 | &ae)</code></td> |
| 221 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 222 | <td>The extended assignment operator.</td> |
| 223 | </tr> |
| 224 | <tr> |
| 225 | <td><code>template<class AE><br /> |
| 226 | vector &assign (const vector_expression<AE> |
| 227 | &ae)</code></td> |
| 228 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 229 | <td>Assigns a vector expression to the vector. Left and right hand |
| 230 | side of the assignment should be independent.</td> |
| 231 | </tr> |
| 232 | <tr> |
| 233 | <td><code>template<class AE><br /> |
| 234 | vector &operator += (const vector_expression<AE> |
| 235 | &ae)</code></td> |
| 236 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 237 | <td>A computed assignment operator. Adds the vector expression to |
| 238 | the vector.</td> |
| 239 | </tr> |
| 240 | <tr> |
| 241 | <td><code>template<class AE><br /> |
| 242 | vector &plus_assign (const vector_expression<AE> |
| 243 | &ae)</code></td> |
| 244 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 245 | <td>Adds a vector expression to the vector. Left and right hand |
| 246 | side of the assignment should be independent.</td> |
| 247 | </tr> |
| 248 | <tr> |
| 249 | <td><code>template<class AE><br /> |
| 250 | vector &operator -= (const vector_expression<AE> |
| 251 | &ae)</code></td> |
| 252 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 253 | <td>A computed assignment operator. Subtracts the vector expression |
| 254 | from the vector.</td> |
| 255 | </tr> |
| 256 | <tr> |
| 257 | <td><code>template<class AE><br /> |
| 258 | vector &minus_assign (const vector_expression<AE> |
| 259 | &ae)</code></td> |
| 260 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 261 | <td>Subtracts a vector expression from the vector. Left and right |
| 262 | hand side of the assignment should be independent.</td> |
| 263 | </tr> |
| 264 | <tr> |
| 265 | <td><code>template<class AT><br /> |
| 266 | vector &operator *= (const AT &at)</code></td> |
| 267 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 268 | <td>A computed assignment operator. Multiplies the vector with a |
| 269 | scalar.</td> |
| 270 | </tr> |
| 271 | <tr> |
| 272 | <td><code>template<class AT><br /> |
| 273 | vector &operator /= (const AT &at)</code></td> |
| 274 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 275 | <td>A computed assignment operator. Divides the vector through a |
| 276 | scalar.</td> |
| 277 | </tr> |
| 278 | <tr> |
| 279 | <td><code>void swap (vector &v)</code></td> |
| 280 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 281 | <td>Swaps the contents of the vectors.</td> |
| 282 | </tr> |
| 283 | <tr> |
| 284 | <td><code>void insert_element (size_type i, const_reference t)</code></td> |
| 285 | <td><a href="container_concept.html#vector">Vector</a></td> |
| 286 | <td>Inserts the value <code>t</code> at the <code>i</code>-th |
| 287 | element.</td> |
| 288 | </tr> |
| 289 | <tr> |
| 290 | <td><code>void erase_element (size_type i)</code></td> |
| 291 | <td><a href="container_concept.html#vector">Vector</a></td> |
| 292 | <td>Erases the value at the <code>i</code>-th element.</td> |
| 293 | </tr> |
| 294 | <tr> |
| 295 | <td><code>void clear ()</code></td> |
| 296 | <td><a href="container_concept.html#vector">Vector</a></td> |
| 297 | <td>Clears the vector.</td> |
| 298 | </tr> |
| 299 | <tr> |
| 300 | <td><code>const_iterator begin () const</code></td> |
| 301 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 302 | <td>Returns a <code>const_iterator</code> pointing to the beginning |
| 303 | of the <code>vector</code>.</td> |
| 304 | </tr> |
| 305 | <tr> |
| 306 | <td><code>const_iterator end () const</code></td> |
| 307 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 308 | <td>Returns a <code>const_iterator</code> pointing to the end of |
| 309 | the <code>vector</code>.</td> |
| 310 | </tr> |
| 311 | <tr> |
| 312 | <td><code>iterator begin ()</code></td> |
| 313 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 314 | <td>Returns a <code>iterator</code> pointing to the beginning of |
| 315 | the <code>vector</code>.</td> |
| 316 | </tr> |
| 317 | <tr> |
| 318 | <td><code>iterator end ()</code></td> |
| 319 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 320 | <td>Returns a <code>iterator</code> pointing to the end of the |
| 321 | <code>vector</code>.</td> |
| 322 | </tr> |
| 323 | <tr> |
| 324 | <td><code>const_reverse_iterator rbegin () const</code></td> |
| 325 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 326 | <td>Returns a <code>const_reverse_iterator</code> pointing to the |
| 327 | beginning of the reversed <code>vector</code>.</td> |
| 328 | </tr> |
| 329 | <tr> |
| 330 | <td><code>const_reverse_iterator rend () const</code></td> |
| 331 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 332 | <td>Returns a <code>const_reverse_iterator</code> pointing to the |
| 333 | end of the reversed <code>vector</code>.</td> |
| 334 | </tr> |
| 335 | <tr> |
| 336 | <td><code>reverse_iterator rbegin ()</code></td> |
| 337 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 338 | <td>Returns a <code>reverse_iterator</code> pointing to the |
| 339 | beginning of the reversed <code>vector</code>.</td> |
| 340 | </tr> |
| 341 | <tr> |
| 342 | <td><code>reverse_iterator rend ()</code></td> |
| 343 | <td><a href="expression_concept.html#vector_expression">VectorExpression</a></td> |
| 344 | <td>Returns a <code>reverse_iterator</code> pointing to the end of |
| 345 | the reversed <code>vector</code>.</td> |
| 346 | </tr> |
| 347 | </tbody> |
| 348 | </table> |
| 349 | <h4>Notes</h4> |
| 350 | <p><a name="vector_1">[1]</a> Common parameters |
| 351 | for the Storage array are <code>unbounded_array<T></code> , |
| 352 | <code>bounded_array<T></code> and |
| 353 | <code>std::vector<T></code> .</p> |
| 354 | <h2><a name="unit_vector"></a>Unit Vector</h2> |
| 355 | <h4>Description</h4> |
| 356 | <p>The templated class <code>unit_vector<T, ALLOC></code> represents |
| 357 | canonical unit vectors. For the <em>k</em>-th |
| 358 | <em>n</em>-dimensional canonical unit vector and <em>0 <= i < |
| 359 | n</em> holds <em>u</em><sup><em>k</em></sup><sub><em>i</em></sub> |
| 360 | <em>= 0</em>, if <em>i <> k</em>, and |
| 361 | <em>u</em><sup><em>k</em></sup><sub><em>i</em></sub> <em>= |
| 362 | 1</em>.</p> |
| 363 | <h4>Example</h4> |
| 364 | <pre> |
| 365 | #include <boost/numeric/ublas/vector.hpp> |
| 366 | #include <boost/numeric/ublas/io.hpp> |
| 367 | |
| 368 | int main () { |
| 369 | using namespace boost::numeric::ublas; |
| 370 | for (int i = 0; i < 3; ++ i) { |
| 371 | unit_vector<double> v (3, i); |
| 372 | std::cout << v << std::endl; |
| 373 | } |
| 374 | } |
| 375 | </pre> |
| 376 | <h4>Definition</h4> |
| 377 | <p>Defined in the header vector.hpp.</p> |
| 378 | <h4>Template parameters</h4> |
| 379 | <table border="1" summary="parameters"> |
| 380 | <tbody> |
| 381 | <tr> |
| 382 | <th>Parameter</th> |
| 383 | <th>Description</th> |
| 384 | <th>Default</th> |
| 385 | </tr> |
| 386 | <tr> |
| 387 | <td><code>T</code></td> |
| 388 | <td>The type of object stored in the vector.</td> |
| 389 | <td><code>int</code></td> |
| 390 | </tr> |
| 391 | <tr> |
| 392 | <td><code>ALLOC</code></td> |
| 393 | <td>An STL Allocator for size_type and difference_type.</td> |
| 394 | <td>std::allocator</td> |
| 395 | </tr> |
| 396 | </tbody> |
| 397 | </table> |
| 398 | <h4>Model of</h4> |
| 399 | <p><a href="container_concept.html#vector">Vector</a> .</p> |
| 400 | <h4>Type requirements</h4> |
| 401 | <p>None, except for those imposed by the requirements of |
| 402 | <a href="container_concept.html#vector">Vector</a> .</p> |
| 403 | <h4>Public base classes</h4> |
| 404 | <p><code>vector_container<unit_vector<T> ></code></p> |
| 405 | <h4>Members</h4> |
| 406 | <table border="1" summary="members"> |
| 407 | <tbody> |
| 408 | <tr> |
| 409 | <th>Member</th> |
| 410 | <th>Description</th> |
| 411 | </tr> |
| 412 | <tr> |
| 413 | <td><code>unit_vector ()</code></td> |
| 414 | <td>Constructs an <code>unit_vector</code> that holds zero |
| 415 | elements.</td> |
| 416 | </tr> |
| 417 | <tr> |
| 418 | <td><code>unit_vector (size_type size, size_type index)</code></td> |
| 419 | <td>Constructs the <code>index</code>-th <code>unit_vector</code> |
| 420 | that holds <code>size</code> elements.</td> |
| 421 | </tr> |
| 422 | <tr> |
| 423 | <td><code>unit_vector (const unit_vector &v)</code></td> |
| 424 | <td>The copy constructor.</td> |
| 425 | </tr> |
| 426 | <tr> |
| 427 | <td><code>void resize (size_type size, bool preserve = |
| 428 | true)</code></td> |
| 429 | <td>Resizes a <code>unit_vector</code> to hold <code>size</code> |
| 430 | elements. Therefore the existing elements of the |
| 431 | <code>unit_vector</code> are always preseved.</td> |
| 432 | </tr> |
| 433 | <tr> |
| 434 | <td><code>size_type size () const</code></td> |
| 435 | <td>Returns the size of the <code>unit_vector</code>.</td> |
| 436 | </tr> |
| 437 | <tr> |
| 438 | <td><code>size_type index () const</code></td> |
| 439 | <td>Returns the index of the <code>unit_vector</code>.</td> |
| 440 | </tr> |
| 441 | <tr> |
| 442 | <td><code>const_reference operator () (size_type i) |
| 443 | const</code></td> |
| 444 | <td>Returns the value of the <code>i</code>-th element.</td> |
| 445 | </tr> |
| 446 | <tr> |
| 447 | <td><code>const_reference operator [] (size_type i) |
| 448 | const</code></td> |
| 449 | <td>Returns the value of the <code>i</code>-th element.</td> |
| 450 | </tr> |
| 451 | <tr> |
| 452 | <td><code>unit_vector &operator = (const unit_vector |
| 453 | &v)</code></td> |
| 454 | <td>The assignment operator.</td> |
| 455 | </tr> |
| 456 | <tr> |
| 457 | <td><code>unit_vector &assign_temporary (unit_vector |
| 458 | &v)</code></td> |
| 459 | <td>Assigns a temporary. May change the unit vector <code>v</code> |
| 460 | .</td> |
| 461 | </tr> |
| 462 | <tr> |
| 463 | <td><code>void swap (unit_vector &v)</code></td> |
| 464 | <td>Swaps the contents of the unit vectors.</td> |
| 465 | </tr> |
| 466 | <tr> |
| 467 | <td><code>const_iterator begin () const</code></td> |
| 468 | <td>Returns a <code>const_iterator</code> pointing to the beginning |
| 469 | of the <code>unit_vector</code>.</td> |
| 470 | </tr> |
| 471 | <tr> |
| 472 | <td><code>const_iterator end () const</code></td> |
| 473 | <td>Returns a <code>const_iterator</code> pointing to the end of |
| 474 | the <code>unit_vector</code>.</td> |
| 475 | </tr> |
| 476 | <tr> |
| 477 | <td><code>const_reverse_iterator rbegin () const</code></td> |
| 478 | <td>Returns a <code>const_reverse_iterator</code> pointing to the |
| 479 | beginning of the reversed <code>unit_vector</code>.</td> |
| 480 | </tr> |
| 481 | <tr> |
| 482 | <td><code>const_reverse_iterator rend () const</code></td> |
| 483 | <td>Returns a <code>const_reverse_iterator</code> pointing to the |
| 484 | end of the reversed <code>unit_vector</code>.</td> |
| 485 | </tr> |
| 486 | </tbody> |
| 487 | </table> |
| 488 | <h2><a name="zero_vector"></a>Zero Vector</h2> |
| 489 | <h4>Description</h4> |
| 490 | <p>The templated class <code>zero_vector<T, ALLOC></code> represents |
| 491 | zero vectors. For a <em>n</em>-dimensional zero vector and <em>0 |
| 492 | <= i < n</em> holds <em>z</em><sub><em>i</em></sub> <em>= |
| 493 | 0</em>.</p> |
| 494 | <h4>Example</h4> |
| 495 | <pre> |
| 496 | #include <boost/numeric/ublas/vector.hpp> |
| 497 | #include <boost/numeric/ublas/io.hpp> |
| 498 | |
| 499 | int main () { |
| 500 | using namespace boost::numeric::ublas; |
| 501 | zero_vector<double> v (3); |
| 502 | std::cout << v << std::endl; |
| 503 | } |
| 504 | </pre> |
| 505 | <h4>Definition</h4> |
| 506 | <p>Defined in the header vector.hpp.</p> |
| 507 | <h4>Template parameters</h4> |
| 508 | <table border="1" summary="parameters"> |
| 509 | <tbody> |
| 510 | <tr> |
| 511 | <th>Parameter</th> |
| 512 | <th>Description</th> |
| 513 | <th>Default</th> |
| 514 | </tr> |
| 515 | <tr> |
| 516 | <td><code>T</code></td> |
| 517 | <td>The type of object stored in the vector.</td> |
| 518 | <td><code>int</code></td> |
| 519 | </tr> |
| 520 | <tr> |
| 521 | <td><code>ALLOC</code></td> |
| 522 | <td>An STL Allocator for size_type and difference_type.</td> |
| 523 | <td>std::allocator</td> |
| 524 | </tr> |
| 525 | </tbody> |
| 526 | </table> |
| 527 | <h4>Model of</h4> |
| 528 | <p><a href="container_concept.html#vector">Vector</a> .</p> |
| 529 | <h4>Type requirements</h4> |
| 530 | <p>None, except for those imposed by the requirements of |
| 531 | <a href="container_concept.html#vector">Vector</a> .</p> |
| 532 | <h4>Public base classes</h4> |
| 533 | <p><code>vector_container<zero_vector<T> ></code></p> |
| 534 | <h4>Members</h4> |
| 535 | <table border="1" summary="members"> |
| 536 | <tbody> |
| 537 | <tr> |
| 538 | <th>Member</th> |
| 539 | <th>Description</th> |
| 540 | </tr> |
| 541 | <tr> |
| 542 | <td><code>zero_vector ()</code></td> |
| 543 | <td>Constructs a <code>zero_vector</code> that holds zero |
| 544 | elements.</td> |
| 545 | </tr> |
| 546 | <tr> |
| 547 | <td><code>zero_vector (size_type size)</code></td> |
| 548 | <td>Constructs a <code>zero_vector</code> that holds |
| 549 | <code>size</code> elements.</td> |
| 550 | </tr> |
| 551 | <tr> |
| 552 | <td><code>zero_vector (const zero_vector &v)</code></td> |
| 553 | <td>The copy constructor.</td> |
| 554 | </tr> |
| 555 | <tr> |
| 556 | <td><code>void resize (size_type size, bool preserve = |
| 557 | true)</code></td> |
| 558 | <td>Resizes a <code>zero_vector</code> to hold <code>size</code> |
| 559 | elements. Therefore the existing elements of the |
| 560 | <code>zero_vector</code> are always preseved.</td> |
| 561 | </tr> |
| 562 | <tr> |
| 563 | <td><code>size_type size () const</code></td> |
| 564 | <td>Returns the size of the <code>zero_vector</code>.</td> |
| 565 | </tr> |
| 566 | <tr> |
| 567 | <td><code>const_reference operator () (size_type i) |
| 568 | const</code></td> |
| 569 | <td>Returns the value of the <code>i</code>-th element.</td> |
| 570 | </tr> |
| 571 | <tr> |
| 572 | <td><code>const_reference operator [] (size_type i) |
| 573 | const</code></td> |
| 574 | <td>Returns the value of the <code>i</code>-th element.</td> |
| 575 | </tr> |
| 576 | <tr> |
| 577 | <td><code>zero_vector &operator = (const zero_vector |
| 578 | &v)</code></td> |
| 579 | <td>The assignment operator.</td> |
| 580 | </tr> |
| 581 | <tr> |
| 582 | <td><code>zero_vector &assign_temporary (zero_vector |
| 583 | &v)</code></td> |
| 584 | <td>Assigns a temporary. May change the zero vector <code>v</code> |
| 585 | .</td> |
| 586 | </tr> |
| 587 | <tr> |
| 588 | <td><code>void swap (zero_vector &v)</code></td> |
| 589 | <td>Swaps the contents of the zero vectors.</td> |
| 590 | </tr> |
| 591 | <tr> |
| 592 | <td><code>const_iterator begin () const</code></td> |
| 593 | <td>Returns a <code>const_iterator</code> pointing to the beginning |
| 594 | of the <code>zero_vector</code>.</td> |
| 595 | </tr> |
| 596 | <tr> |
| 597 | <td><code>const_iterator end () const</code></td> |
| 598 | <td>Returns a <code>const_iterator</code> pointing to the end of |
| 599 | the <code>zero_vector</code>.</td> |
| 600 | </tr> |
| 601 | <tr> |
| 602 | <td><code>const_reverse_iterator rbegin () const</code></td> |
| 603 | <td>Returns a <code>const_reverse_iterator</code> pointing to the |
| 604 | beginning of the reversed <code>zero_vector</code>.</td> |
| 605 | </tr> |
| 606 | <tr> |
| 607 | <td><code>const_reverse_iterator rend () const</code></td> |
| 608 | <td>Returns a <code>const_reverse_iterator</code> pointing to the |
| 609 | end of the reversed <code>zero_vector</code>.</td> |
| 610 | </tr> |
| 611 | </tbody> |
| 612 | </table> |
| 613 | <h2><a name="scalar_vector"></a>Scalar Vector</h2> |
| 614 | <h4>Description</h4> |
| 615 | <p>The templated class <code>scalar_vector<T, ALLOC></code> |
| 616 | represents scalar vectors. For a <em>n</em>-dimensional scalar |
| 617 | vector and <em>0 <= i < n</em> holds |
| 618 | <em>z</em><sub><em>i</em></sub> <em>= s</em>.</p> |
| 619 | <h4>Example</h4> |
| 620 | <pre> |
| 621 | #include <boost/numeric/ublas/vector.hpp> |
| 622 | #include <boost/numeric/ublas/io.hpp> |
| 623 | |
| 624 | int main () { |
| 625 | using namespace boost::numeric::ublas; |
| 626 | scalar_vector<double> v (3); |
| 627 | std::cout << v << std::endl; |
| 628 | } |
| 629 | </pre> |
| 630 | <h4>Definition</h4> |
| 631 | <p>Defined in the header vector.hpp.</p> |
| 632 | <h4>Template parameters</h4> |
| 633 | <table border="1" summary="parameters"> |
| 634 | <tbody> |
| 635 | <tr> |
| 636 | <th>Parameter</th> |
| 637 | <th>Description</th> |
| 638 | <th>Default</th> |
| 639 | </tr> |
| 640 | <tr> |
| 641 | <td><code>T</code></td> |
| 642 | <td>The type of object stored in the vector.</td> |
| 643 | <td><code>int</code></td> |
| 644 | </tr> |
| 645 | <tr> |
| 646 | <td><code>ALLOC</code></td> |
| 647 | <td>An STL Allocator for size_type and difference_type.</td> |
| 648 | <td>std::allocator</td> |
| 649 | </tr> |
| 650 | </tbody> |
| 651 | </table> |
| 652 | <h4>Model of</h4> |
| 653 | <p><a href="container_concept.html#vector">Vector</a> .</p> |
| 654 | <h4>Type requirements</h4> |
| 655 | <p>None, except for those imposed by the requirements of |
| 656 | <a href="container_concept.html#vector">Vector</a> .</p> |
| 657 | <h4>Public base classes</h4> |
| 658 | <p><code>vector_container<scalar_vector<T> |
| 659 | ></code></p> |
| 660 | <h4>Members</h4> |
| 661 | <table border="1" summary="members"> |
| 662 | <tbody> |
| 663 | <tr> |
| 664 | <th>Member</th> |
| 665 | <th>Description</th> |
| 666 | </tr> |
| 667 | <tr> |
| 668 | <td><code>scalar_vector ()</code></td> |
| 669 | <td>Constructs a <code>scalar_vector</code> that holds zero |
| 670 | elements.</td> |
| 671 | </tr> |
| 672 | <tr> |
| 673 | <td><code>scalar_vector (size_type size, const value_type |
| 674 | &value)</code></td> |
| 675 | <td>Constructs a <code>scalar_vector</code> that holds |
| 676 | <code>size</code> elements each of the specified value.</td> |
| 677 | </tr> |
| 678 | <tr> |
| 679 | <td><code>scalar_vector (const scalar_vector &v)</code></td> |
| 680 | <td>The copy constructor.</td> |
| 681 | </tr> |
| 682 | <tr> |
| 683 | <td><code>void resize (size_type size, bool preserve = |
| 684 | true)</code></td> |
| 685 | <td>Resizes a <code>scalar_vector</code> to hold <code>size</code> |
| 686 | elements. Therefore the existing elements of the |
| 687 | <code>scalar_vector</code> are always preseved.</td> |
| 688 | </tr> |
| 689 | <tr> |
| 690 | <td><code>size_type size () const</code></td> |
| 691 | <td>Returns the size of the <code>scalar_vector</code>.</td> |
| 692 | </tr> |
| 693 | <tr> |
| 694 | <td><code>const_reference operator () (size_type i) |
| 695 | const</code></td> |
| 696 | <td>Returns the value of the <code>i</code>-th element.</td> |
| 697 | </tr> |
| 698 | <tr> |
| 699 | <td><code>const_reference operator [] (size_type i) |
| 700 | const</code></td> |
| 701 | <td>Returns the value of the <code>i</code>-th element.</td> |
| 702 | </tr> |
| 703 | <tr> |
| 704 | <td><code>scalar_vector &operator = (const scalar_vector |
| 705 | &v)</code></td> |
| 706 | <td>The assignment operator.</td> |
| 707 | </tr> |
| 708 | <tr> |
| 709 | <td><code>scalar_vector &assign_temporary (scalar_vector |
| 710 | &v)</code></td> |
| 711 | <td>Assigns a temporary. May change the scalar vector |
| 712 | <code>v</code> .</td> |
| 713 | </tr> |
| 714 | <tr> |
| 715 | <td><code>void swap (scalar_vector &v)</code></td> |
| 716 | <td>Swaps the contents of the scalar vectors.</td> |
| 717 | </tr> |
| 718 | <tr> |
| 719 | <td><code>const_iterator begin () const</code></td> |
| 720 | <td>Returns a <code>const_iterator</code> pointing to the beginning |
| 721 | of the <code>scalar_vector</code>.</td> |
| 722 | </tr> |
| 723 | <tr> |
| 724 | <td><code>const_iterator end () const</code></td> |
| 725 | <td>Returns a <code>const_iterator</code> pointing to the end of |
| 726 | the <code>scalar_vector</code>.</td> |
| 727 | </tr> |
| 728 | <tr> |
| 729 | <td><code>const_reverse_iterator rbegin () const</code></td> |
| 730 | <td>Returns a <code>const_reverse_iterator</code> pointing to the |
| 731 | beginning of the reversed <code>scalar_vector</code>.</td> |
| 732 | </tr> |
| 733 | <tr> |
| 734 | <td><code>const_reverse_iterator rend () const</code></td> |
| 735 | <td>Returns a <code>const_reverse_iterator</code> pointing to the |
| 736 | end of the reversed <code>scalar_vector</code>.</td> |
| 737 | </tr> |
| 738 | </tbody> |
| 739 | </table> |
| 740 | <hr /> |
| 741 | <p>Copyright (©) 2000-2002 Joerg Walter, Mathias Koch<br /> |
| 742 | Use, modification and distribution are subject to the |
| 743 | Boost Software License, Version 1.0. |
| 744 | (See accompanying file LICENSE_1_0.txt |
| 745 | or copy at <a href="http://www.boost.org/LICENSE_1_0.txt"> |
| 746 | http://www.boost.org/LICENSE_1_0.txt |
| 747 | </a>). |
| 748 | </p> |
| 749 | <script type="text/javascript"> |
| 750 | (function($) { |
| 751 | $('#toc').toc(); |
| 752 | })(jQuery); |
| 753 | </script> |
| 754 | </body> |
| 755 | </html> |