matrix.html 23 KB

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