vector.html 23 KB

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