matrix_proxy.html 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428
  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 Proxies</title>
  14. </head>
  15. <body>
  16. <h1><img src="../../../../boost.png" align="middle" />Matrix Proxies</h1>
  17. <div class="toc" id="toc"></div>
  18. <h2><a name="matrix_row"></a>Matrix Row</h2>
  19. <h4>Description</h4>
  20. <p>The templated class <code>matrix_row&lt;M&gt;</code> allows
  21. addressing a row of a matrix.</p>
  22. <h4>Example</h4>
  23. <pre>
  24. #include &lt;boost/numeric/ublas/matrix.hpp&gt;
  25. #include &lt;boost/numeric/ublas/matrix_proxy.hpp&gt;
  26. #include &lt;boost/numeric/ublas/io.hpp&gt;
  27. int main () {
  28. using namespace boost::numeric::ublas;
  29. matrix&lt;double&gt; m (3, 3);
  30. for (unsigned i = 0; i &lt; m.size1 (); ++ i) {
  31. matrix_row&lt;matrix&lt;double&gt; &gt; mr (m, i);
  32. for (unsigned j = 0; j &lt; mr.size (); ++ j)
  33. mr (j) = 3 * i + j;
  34. std::cout &lt;&lt; mr &lt;&lt; std::endl;
  35. }
  36. }
  37. </pre>
  38. <h4>Definition</h4>
  39. <p>Defined in the header matrix_proxy.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>M</code></td>
  50. <td>The type of matrix referenced.</td>
  51. <td></td>
  52. </tr>
  53. </tbody>
  54. </table>
  55. <h4>Model of</h4>
  56. <p><a href="expression_concept.html#vector_expression">Vector Expression</a>
  57. .</p>
  58. <p>If the specified row falls outside that of the row index range
  59. of the matrix, then the <code>matrix_row</code> is not a well
  60. formed Vector Expression. That is, access to an element which is
  61. outside of the matrix is <i>undefined</i>.</p>
  62. <h4>Type requirements</h4>
  63. <p>None, except for those imposed by the requirements of <a href=
  64. "expression_concept.html#vector_expression">Vector Expression</a> .</p>
  65. <h4>Public base classes</h4>
  66. <p><code>vector_expression&lt;matrix_row&lt;M&gt; &gt;</code></p>
  67. <h4>Members</h4>
  68. <table border="1" summary="members">
  69. <tbody>
  70. <tr>
  71. <th>Member</th>
  72. <th>Description</th>
  73. </tr>
  74. <tr>
  75. <td><code>matrix_row (matrix_type &amp;data, size_type
  76. i)</code></td>
  77. <td>Constructs a sub vector.</td>
  78. </tr>
  79. <tr>
  80. <td><code>size_type size () const</code></td>
  81. <td>Returns the size of the sub vector.</td>
  82. </tr>
  83. <tr>
  84. <td><code>const_reference operator () (size_type i)
  85. const</code></td>
  86. <td>Returns the value of the <code>i</code>-th element.</td>
  87. </tr>
  88. <tr>
  89. <td><code>reference operator () (size_type i)</code></td>
  90. <td>Returns a reference of the <code>i</code>-th element.</td>
  91. </tr>
  92. <tr>
  93. <td><code>matrix_row &amp;operator = (const matrix_row
  94. &amp;mr)</code></td>
  95. <td>The assignment operator.</td>
  96. </tr>
  97. <tr>
  98. <td><code>matrix_row &amp;assign_temporary (matrix_row
  99. &amp;mr)</code></td>
  100. <td>Assigns a temporary. May change the matrix row <code>mr</code>
  101. .</td>
  102. </tr>
  103. <tr>
  104. <td><code>template&lt;class AE&gt;<br />
  105. matrix_row &amp;operator = (const vector_expression&lt;AE&gt;
  106. &amp;ae)</code></td>
  107. <td>The extended assignment operator.</td>
  108. </tr>
  109. <tr>
  110. <td><code>template&lt;class AE&gt;<br />
  111. matrix_row &amp;assign (const vector_expression&lt;AE&gt;
  112. &amp;ae)</code></td>
  113. <td>Assigns a vector expression to the sub vector. Left and right
  114. hand side of the assignment should be independent.</td>
  115. </tr>
  116. <tr>
  117. <td><code>template&lt;class AE&gt;<br />
  118. matrix_row &amp;operator += (const vector_expression&lt;AE&gt;
  119. &amp;ae)</code></td>
  120. <td>A computed assignment operator. Adds the vector expression to
  121. the sub vector.</td>
  122. </tr>
  123. <tr>
  124. <td><code>template&lt;class AE&gt;<br />
  125. matrix_row &amp;plus_assign (const vector_expression&lt;AE&gt;
  126. &amp;ae)</code></td>
  127. <td>Adds a vector expression to the sub vector. Left and right hand
  128. side of the assignment should be independent.</td>
  129. </tr>
  130. <tr>
  131. <td><code>template&lt;class AE&gt;<br />
  132. matrix_row &amp;operator -= (const vector_expression&lt;AE&gt;
  133. &amp;ae)</code></td>
  134. <td>A computed assignment operator. Subtracts the vector expression
  135. from the sub vector.</td>
  136. </tr>
  137. <tr>
  138. <td><code>template&lt;class AE&gt;<br />
  139. matrix_row &amp;minus_assign (const vector_expression&lt;AE&gt;
  140. &amp;ae)</code></td>
  141. <td>Subtracts a vector expression from the sub vector. Left and
  142. right hand side of the assignment should be independent.</td>
  143. </tr>
  144. <tr>
  145. <td><code>template&lt;class AT&gt;<br />
  146. matrix_row &amp;operator *= (const AT &amp;at)</code></td>
  147. <td>A computed assignment operator. Multiplies the sub vector with
  148. a scalar.</td>
  149. </tr>
  150. <tr>
  151. <td><code>template&lt;class AT&gt;<br />
  152. matrix_row &amp;operator /= (const AT &amp;at)</code></td>
  153. <td>A computed assignment operator. Divides the sub vector through
  154. a scalar.</td>
  155. </tr>
  156. <tr>
  157. <td><code>void swap (matrix_row &amp;mr)</code></td>
  158. <td>Swaps the contents of the sub vectors.</td>
  159. </tr>
  160. <tr>
  161. <td><code>const_iterator begin () const</code></td>
  162. <td>Returns a <code>const_iterator</code> pointing to the beginning
  163. of the <code>matrix_row</code>.</td>
  164. </tr>
  165. <tr>
  166. <td><code>const_iterator end () const</code></td>
  167. <td>Returns a <code>const_iterator</code> pointing to the end of
  168. the <code>matrix_row</code>.</td>
  169. </tr>
  170. <tr>
  171. <td><code>iterator begin ()</code></td>
  172. <td>Returns a <code>iterator</code> pointing to the beginning of
  173. the <code>matrix_row</code>.</td>
  174. </tr>
  175. <tr>
  176. <td><code>iterator end ()</code></td>
  177. <td>Returns a <code>iterator</code> pointing to the end of the
  178. <code>matrix_row</code>.</td>
  179. </tr>
  180. <tr>
  181. <td><code>const_reverse_iterator rbegin () const</code></td>
  182. <td>Returns a <code>const_reverse_iterator</code> pointing to the
  183. beginning of the reversed <code>matrix_row</code>.</td>
  184. </tr>
  185. <tr>
  186. <td><code>const_reverse_iterator rend () const</code></td>
  187. <td>Returns a <code>const_reverse_iterator</code> pointing to the
  188. end of the reversed <code>matrix_row</code>.</td>
  189. </tr>
  190. <tr>
  191. <td><code>reverse_iterator rbegin ()</code></td>
  192. <td>Returns a <code>reverse_iterator</code> pointing to the
  193. beginning of the reversed <code>matrix_row</code>.</td>
  194. </tr>
  195. <tr>
  196. <td><code>reverse_iterator rend ()</code></td>
  197. <td>Returns a <code>reverse_iterator</code> pointing to the end of
  198. the reversed <code>matrix_row</code>.</td>
  199. </tr>
  200. </tbody>
  201. </table>
  202. <h3>Projections</h3>
  203. <h4>Description</h4>
  204. <p>The free <code>row</code> functions support the construction of
  205. matrix rows.</p>
  206. <h4>Prototypes</h4>
  207. <pre><code>
  208. template&lt;class M&gt;
  209. matrix_row&lt;M&gt; row (M &amp;data, std::size_t i);
  210. template&lt;class M&gt;
  211. const matrix_row&lt;const M&gt; row (const M &amp;data, std::size_t i);
  212. </code></pre>
  213. <h4>Definition</h4>
  214. <p>Defined in the header matrix_proxy.hpp.</p>
  215. <h4>Type requirements</h4>
  216. <ul>
  217. <li><code>M</code> is a model of <a href=
  218. "expression_concept.html#matrix_expression">Matrix Expression</a> .</li>
  219. </ul>
  220. <h4>Complexity</h4>
  221. <p>Linear depending from the size of the row.</p>
  222. <h4>Examples</h4>
  223. <pre>
  224. #include &lt;boost/numeric/ublas/matrix.hpp&gt;
  225. #include &lt;boost/numeric/ublas/matrix_proxy.hpp&gt;
  226. #include &lt;boost/numeric/ublas/io.hpp&gt;
  227. int main () {
  228. using namespace boost::numeric::ublas;
  229. matrix&lt;double&gt; m (3, 3);
  230. for (unsigned i = 0; i &lt; m.size1 (); ++ i) {
  231. for (unsigned j = 0; j &lt; m.size2 (); ++ j)
  232. row (m, i) (j) = 3 * i + j;
  233. std::cout &lt;&lt; row (m, i) &lt;&lt; std::endl;
  234. }
  235. }
  236. </pre>
  237. <h2><a name="matrix_column"></a>Matrix Column</h2>
  238. <h4>Description</h4>
  239. <p>The templated class <code>matrix_column&lt;M&gt;</code> allows
  240. addressing a column of a matrix.</p>
  241. <h4>Example</h4>
  242. <pre>
  243. #include &lt;boost/numeric/ublas/matrix.hpp&gt;
  244. #include &lt;boost/numeric/ublas/matrix_proxy.hpp&gt;
  245. #include &lt;boost/numeric/ublas/io.hpp&gt;
  246. int main () {
  247. using namespace boost::numeric::ublas;
  248. matrix&lt;double&gt; m (3, 3);
  249. for (unsigned j = 0; j &lt; m.size2 (); ++ j) {
  250. matrix_column&lt;matrix&lt;double&gt; &gt; mc (m, j);
  251. for (unsigned i = 0; i &lt; mc.size (); ++ i)
  252. mc (i) = 3 * i + j;
  253. std::cout &lt;&lt; mc &lt;&lt; std::endl;
  254. }
  255. }
  256. </pre>
  257. <h4>Definition</h4>
  258. <p>Defined in the header matrix_proxy.hpp.</p>
  259. <h4>Template parameters</h4>
  260. <table border="1" summary="parameters">
  261. <tbody>
  262. <tr>
  263. <th>Parameter</th>
  264. <th>Description</th>
  265. <th>Default</th>
  266. </tr>
  267. <tr>
  268. <td><code>M</code></td>
  269. <td>The type of matrix referenced.</td>
  270. <td></td>
  271. </tr>
  272. </tbody>
  273. </table>
  274. <h4>Model of</h4>
  275. <p><a href="expression_concept.html#vector_expression">Vector Expression</a>
  276. .</p>
  277. <p>If the specified column falls outside that of the column index
  278. range of the matrix, then the <code>matrix_column</code> is not a
  279. well formed Vector Expression. That is, access to an element which
  280. is outside of the matrix is <i>undefined</i>.</p>
  281. <h4>Type requirements</h4>
  282. <p>None, except for those imposed by the requirements of <a href=
  283. "expression_concept.html#vector_expression">Vector Expression</a> .</p>
  284. <h4>Public base classes</h4>
  285. <p><code>vector_expression&lt;matrix_column&lt;M&gt;
  286. &gt;</code></p>
  287. <h4>Members</h4>
  288. <table border="1" summary="members">
  289. <tbody>
  290. <tr>
  291. <th>Member</th>
  292. <th>Description</th>
  293. </tr>
  294. <tr>
  295. <td><code>matrix_column (matrix_type &amp;data, size_type
  296. j)</code></td>
  297. <td>Constructs a sub vector.</td>
  298. </tr>
  299. <tr>
  300. <td><code>size_type size () const</code></td>
  301. <td>Returns the size of the sub vector.</td>
  302. </tr>
  303. <tr>
  304. <td><code>const_reference operator () (size_type i)
  305. const</code></td>
  306. <td>Returns the value of the <code>i</code>-th element.</td>
  307. </tr>
  308. <tr>
  309. <td><code>reference operator () (size_type i)</code></td>
  310. <td>Returns a reference of the <code>i</code>-th element.</td>
  311. </tr>
  312. <tr>
  313. <td><code>matrix_column &amp;operator = (const matrix_column
  314. &amp;mc)</code></td>
  315. <td>The assignment operator.</td>
  316. </tr>
  317. <tr>
  318. <td><code>matrix_column &amp;assign_temporary (matrix_column
  319. &amp;mc)</code></td>
  320. <td>Assigns a temporary. May change the matrix column
  321. <code>mc</code> .</td>
  322. </tr>
  323. <tr>
  324. <td><code>template&lt;class AE&gt;<br />
  325. matrix_column &amp;operator = (const vector_expression&lt;AE&gt;
  326. &amp;ae)</code></td>
  327. <td>The extended assignment operator.</td>
  328. </tr>
  329. <tr>
  330. <td><code>template&lt;class AE&gt;<br />
  331. matrix_column &amp;assign (const vector_expression&lt;AE&gt;
  332. &amp;ae)</code></td>
  333. <td>Assigns a vector expression to the sub vector. Left and right
  334. hand side of the assignment should be independent.</td>
  335. </tr>
  336. <tr>
  337. <td><code>template&lt;class AE&gt;<br />
  338. matrix_column &amp;operator += (const vector_expression&lt;AE&gt;
  339. &amp;ae)</code></td>
  340. <td>A computed assignment operator. Adds the vector expression to
  341. the sub vector.</td>
  342. </tr>
  343. <tr>
  344. <td><code>template&lt;class AE&gt;<br />
  345. matrix_column &amp;plus_assign (const vector_expression&lt;AE&gt;
  346. &amp;ae)</code></td>
  347. <td>Adds a vector expression to the sub vector. Left and right hand
  348. side of the assignment should be independent.</td>
  349. </tr>
  350. <tr>
  351. <td><code>template&lt;class AE&gt;<br />
  352. matrix_column &amp;operator -= (const vector_expression&lt;AE&gt;
  353. &amp;ae)</code></td>
  354. <td>A computed assignment operator. Subtracts the vector expression
  355. from the sub vector.</td>
  356. </tr>
  357. <tr>
  358. <td><code>template&lt;class AE&gt;<br />
  359. matrix_column &amp;minus_assign (const vector_expression&lt;AE&gt;
  360. &amp;ae)</code></td>
  361. <td>Subtracts a vector expression from the sub vector. Left and
  362. right hand side of the assignment should be independent.</td>
  363. </tr>
  364. <tr>
  365. <td><code>template&lt;class AT&gt;<br />
  366. matrix_column &amp;operator *= (const AT &amp;at)</code></td>
  367. <td>A computed assignment operator. Multiplies the sub vector with
  368. a scalar.</td>
  369. </tr>
  370. <tr>
  371. <td><code>template&lt;class AT&gt;<br />
  372. matrix_column &amp;operator /= (const AT &amp;at)</code></td>
  373. <td>A computed assignment operator. Divides the sub vector through
  374. a scalar.</td>
  375. </tr>
  376. <tr>
  377. <td><code>void swap (matrix_column &amp;mc)</code></td>
  378. <td>Swaps the contents of the sub vectors.</td>
  379. </tr>
  380. <tr>
  381. <td><code>const_iterator begin () const</code></td>
  382. <td>Returns a <code>const_iterator</code> pointing to the beginning
  383. of the <code>matrix_column</code>.</td>
  384. </tr>
  385. <tr>
  386. <td><code>const_iterator end () const</code></td>
  387. <td>Returns a <code>const_iterator</code> pointing to the end of
  388. the <code>matrix_column</code>.</td>
  389. </tr>
  390. <tr>
  391. <td><code>iterator begin ()</code></td>
  392. <td>Returns a <code>iterator</code> pointing to the beginning of
  393. the <code>matrix_column</code>.</td>
  394. </tr>
  395. <tr>
  396. <td><code>iterator end ()</code></td>
  397. <td>Returns a <code>iterator</code> pointing to the end of the
  398. <code>matrix_column</code>.</td>
  399. </tr>
  400. <tr>
  401. <td><code>const_reverse_iterator rbegin () const</code></td>
  402. <td>Returns a <code>const_reverse_iterator</code> pointing to the
  403. beginning of the reversed <code>matrix_column</code>.</td>
  404. </tr>
  405. <tr>
  406. <td><code>const_reverse_iterator rend () const</code></td>
  407. <td>Returns a <code>const_reverse_iterator</code> pointing to the
  408. end of the reversed <code>matrix_column</code>.</td>
  409. </tr>
  410. <tr>
  411. <td><code>reverse_iterator rbegin ()</code></td>
  412. <td>Returns a <code>reverse_iterator</code> pointing to the
  413. beginning of the reversed <code>matrix_column</code>.</td>
  414. </tr>
  415. <tr>
  416. <td><code>reverse_iterator rend ()</code></td>
  417. <td>Returns a <code>reverse_iterator</code> pointing to the end of
  418. the reversed <code>matrix_column</code>.</td>
  419. </tr>
  420. </tbody>
  421. </table>
  422. <h3>Projections</h3>
  423. <h4>Description</h4>
  424. <p>The free <code>column</code> functions support the construction
  425. of matrix columns.</p>
  426. <h4>Prototypes</h4>
  427. <pre><code>
  428. template&lt;class M&gt;
  429. matrix_column&lt;M&gt; column (M &amp;data, std::size_t j);
  430. template&lt;class M&gt;
  431. const matrix_column&lt;const M&gt; column (const M &amp;data, std::size_t j);
  432. </code></pre>
  433. <h4>Definition</h4>
  434. <p>Defined in the header matrix_proxy.hpp.</p>
  435. <h4>Type requirements</h4>
  436. <ul>
  437. <li><code>M</code> is a model of <a href=
  438. "expression_concept.html#matrix_expression">Matrix Expression</a> .</li>
  439. </ul>
  440. <h4>Complexity</h4>
  441. <p>Linear depending from the size of the column.</p>
  442. <h4>Examples</h4>
  443. <pre>
  444. #include &lt;boost/numeric/ublas/matrix.hpp&gt;
  445. #include &lt;boost/numeric/ublas/matrix_proxy.hpp&gt;
  446. #include &lt;boost/numeric/ublas/io.hpp&gt;
  447. int main () {
  448. using namespace boost::numeric::ublas;
  449. matrix&lt;double&gt; m (3, 3);
  450. for (unsigned j = 0; j &lt; m.size2 (); ++ j) {
  451. for (unsigned i = 0; i &lt; m.size1 (); ++ i)
  452. column (m, j) (i) = 3 * i + j;
  453. std::cout &lt;&lt; column (m, j) &lt;&lt; std::endl;
  454. }
  455. }
  456. </pre>
  457. <h2><a name="vector_range"></a>Vector Range</h2>
  458. <h4>Description</h4>
  459. <p>The templated class <code>matrix_vector_range&lt;M&gt;</code>
  460. allows addressing a sub vector of a matrix.</p>
  461. <h4>Example</h4>
  462. <pre>
  463. #include &lt;boost/numeric/ublas/matrix.hpp&gt;
  464. #include &lt;boost/numeric/ublas/matrix_proxy.hpp&gt;
  465. #include &lt;boost/numeric/ublas/io.hpp&gt;
  466. int main () {
  467. using namespace boost::numeric::ublas;
  468. matrix&lt;double&gt; m (3, 3);
  469. for (unsigned i = 0; i &lt; m.size1 (); ++ i)
  470. for (unsigned j = 0; j &lt; m.size2 (); ++ j)
  471. m (i, j) = 3 * i + j;
  472. matrix_vector_range&lt;matrix&lt;double&gt; &gt; mvr (m, range (0, 3), range (0, 3));
  473. std::cout &lt;&lt; mvr &lt;&lt; std::endl;
  474. }
  475. </pre>
  476. <h4>Definition</h4>
  477. <p>Defined in the header matrix_proxy.hpp.</p>
  478. <h4>Template parameters</h4>
  479. <table border="1" summary="parameters">
  480. <tbody>
  481. <tr>
  482. <th>Parameter</th>
  483. <th>Description</th>
  484. <th>Default</th>
  485. </tr>
  486. <tr>
  487. <td><code>M</code></td>
  488. <td>The type of matrix referenced.</td>
  489. <td></td>
  490. </tr>
  491. </tbody>
  492. </table>
  493. <h4>Model of</h4>
  494. <p><a href="expression_concept.html#vector_expression">Vector Expression</a>
  495. .</p>
  496. <p>If the specified ranges fall outside that of the index range of
  497. the matrix, then the <code>matrix_vector_range</code> is not a well
  498. formed Vector Expression. That is, access to an element which is
  499. outside of the matrix is <i>undefined</i>.</p>
  500. <h4>Type requirements</h4>
  501. <p>None, except for those imposed by the requirements of <a href=
  502. "expression_concept.html#vector_expression">Vector Expression</a> .</p>
  503. <h4>Public base classes</h4>
  504. <p><code>vector_expression&lt;matrix_vector_range&lt;M&gt;
  505. &gt;</code></p>
  506. <h4>Members</h4>
  507. <table border="1" summary="members">
  508. <tbody>
  509. <tr>
  510. <th>Member</th>
  511. <th>Description</th>
  512. </tr>
  513. <tr>
  514. <td><code>matrix_vector_range (matrix_type &amp;data,<br />
  515. const range &amp;r1, const range &amp;r2)</code></td>
  516. <td>Constructs a sub vector.</td>
  517. </tr>
  518. <tr>
  519. <td><code>size_type size () const</code></td>
  520. <td>Returns the size of the sub vector.</td>
  521. </tr>
  522. <tr>
  523. <td><code>const_reference operator () (size_type i)
  524. const</code></td>
  525. <td>Returns the value of the <code>i</code>-th element.</td>
  526. </tr>
  527. <tr>
  528. <td><code>reference operator () (size_type i)</code></td>
  529. <td>Returns a reference of the <code>i</code>-th element.</td>
  530. </tr>
  531. <tr>
  532. <td><code>matrix_vector_range &amp;operator = (const
  533. matrix_vector_range &amp;mvr)</code></td>
  534. <td>The assignment operator.</td>
  535. </tr>
  536. <tr>
  537. <td><code>matrix_vector_range &amp;assign_temporary
  538. (matrix_vector_range &amp;mvr)</code></td>
  539. <td>Assigns a temporary. May change the matrix vector range
  540. <code>mvr</code>.</td>
  541. </tr>
  542. <tr>
  543. <td><code>template&lt;class AE&gt;<br />
  544. matrix_vector_range &amp;operator = (const
  545. vector_expression&lt;AE&gt; &amp;ae)</code></td>
  546. <td>The extended assignment operator.</td>
  547. </tr>
  548. <tr>
  549. <td><code>template&lt;class AE&gt;<br />
  550. matrix_vector_range &amp;assign (const vector_expression&lt;AE&gt;
  551. &amp;ae)</code></td>
  552. <td>Assigns a vector expression to the sub vector. Left and right
  553. hand side of the assignment should be independent.</td>
  554. </tr>
  555. <tr>
  556. <td><code>template&lt;class AE&gt;<br />
  557. matrix_vector_range &amp;operator += (const
  558. vector_expression&lt;AE&gt; &amp;ae)</code></td>
  559. <td>A computed assignment operator. Adds the vector expression to
  560. the sub vector.</td>
  561. </tr>
  562. <tr>
  563. <td><code>template&lt;class AE&gt;<br />
  564. matrix_vector_range &amp;plus_assign (const
  565. vector_expression&lt;AE&gt; &amp;ae)</code></td>
  566. <td>Adds a vector expression to the sub vector. Left and right hand
  567. side of the assignment should be independent.</td>
  568. </tr>
  569. <tr>
  570. <td><code>template&lt;class AE&gt;<br />
  571. matrix_vector_range &amp;operator -= (const
  572. vector_expression&lt;AE&gt; &amp;ae)</code></td>
  573. <td>A computed assignment operator. Subtracts the vector expression
  574. from the sub vector.</td>
  575. </tr>
  576. <tr>
  577. <td><code>template&lt;class AE&gt;<br />
  578. matrix_vector_range &amp;minus_assign (const
  579. vector_expression&lt;AE&gt; &amp;ae)</code></td>
  580. <td>Subtracts a vector expression from the sub vector. Left and
  581. right hand side of the assignment should be independent.</td>
  582. </tr>
  583. <tr>
  584. <td><code>template&lt;class AT&gt;<br />
  585. matrix_vector_range &amp;operator *= (const AT &amp;at)</code></td>
  586. <td>A computed assignment operator. Multiplies the sub vector with
  587. a scalar.</td>
  588. </tr>
  589. <tr>
  590. <td><code>template&lt;class AT&gt;<br />
  591. matrix_vector_range &amp;operator /= (const AT &amp;at)</code></td>
  592. <td>A computed assignment operator. Divides the sub vector through
  593. a scalar.</td>
  594. </tr>
  595. <tr>
  596. <td><code>void swap (matrix_vector_range &amp;mvr)</code></td>
  597. <td>Swaps the contents of the sub vectors.</td>
  598. </tr>
  599. <tr>
  600. <td><code>const_iterator begin () const</code></td>
  601. <td>Returns a <code>const_iterator</code> pointing to the beginning
  602. of the <code>matrix_vector_range</code>.</td>
  603. </tr>
  604. <tr>
  605. <td><code>const_iterator end () const</code></td>
  606. <td>Returns a <code>const_iterator</code> pointing to the end of
  607. the <code>matrix_vector_range</code>.</td>
  608. </tr>
  609. <tr>
  610. <td><code>iterator begin ()</code></td>
  611. <td>Returns a <code>iterator</code> pointing to the beginning of
  612. the <code>matrix_vector_range</code>.</td>
  613. </tr>
  614. <tr>
  615. <td><code>iterator end ()</code></td>
  616. <td>Returns a <code>iterator</code> pointing to the end of the
  617. <code>matrix_vector_range</code>.</td>
  618. </tr>
  619. <tr>
  620. <td><code>const_reverse_iterator rbegin () const</code></td>
  621. <td>Returns a <code>const_reverse_iterator</code> pointing to the
  622. beginning of the <code>matrix_vector_range</code>.</td>
  623. </tr>
  624. <tr>
  625. <td><code>const_reverse_iterator rend () const</code></td>
  626. <td>Returns a <code>const_reverse_iterator</code> pointing to the
  627. end of the reversed <code>matrix_vector_range</code>.</td>
  628. </tr>
  629. <tr>
  630. <td><code>reverse_iterator rbegin ()</code></td>
  631. <td>Returns a <code>reverse_iterator</code> pointing to the
  632. beginning of the reversed <code>matrix_vector_range</code>.</td>
  633. </tr>
  634. <tr>
  635. <td><code>reverse_iterator rend ()</code></td>
  636. <td>Returns a <code>reverse_iterator</code> pointing to the end of
  637. the reversed <code>matrix_vector_range</code>.</td>
  638. </tr>
  639. </tbody>
  640. </table>
  641. <h2><a name="vector_slice"></a>Vector Slice</h2>
  642. <h4>Description</h4>
  643. <p>The templated class <code>matrix_vector_slice&lt;M&gt;</code>
  644. allows addressing a sliced sub vector of a matrix.</p>
  645. <h4>Example</h4>
  646. <pre>
  647. #include &lt;boost/numeric/ublas/matrix.hpp&gt;
  648. #include &lt;boost/numeric/ublas/matrix_proxy.hpp&gt;
  649. #include &lt;boost/numeric/ublas/io.hpp&gt;
  650. int main () {
  651. using namespace boost::numeric::ublas;
  652. matrix&lt;double&gt; m (3, 3);
  653. for (unsigned i = 0; i &lt; m.size1 (); ++ i)
  654. for (unsigned j = 0; j &lt; m.size2 (); ++ j)
  655. m (i, j) = 3 * i + j;
  656. matrix_vector_slice&lt;matrix&lt;double&gt; &gt; mvs (m, slice (0, 1, 3), slice (0, 1, 3));
  657. std::cout &lt;&lt; mvs &lt;&lt; std::endl;
  658. }
  659. </pre>
  660. <h4>Definition</h4>
  661. <p>Defined in the header matrix_proxy.hpp.</p>
  662. <h4>Template parameters</h4>
  663. <table border="1" summary="parameters">
  664. <tbody>
  665. <tr>
  666. <th>Parameter</th>
  667. <th>Description</th>
  668. <th>Default</th>
  669. </tr>
  670. <tr>
  671. <td><code>M</code></td>
  672. <td>The type of matrix referenced.</td>
  673. <td></td>
  674. </tr>
  675. </tbody>
  676. </table>
  677. <h4>Model of</h4>
  678. <p><a href="expression_concept.html#vector_expression">Vector Expression</a>
  679. .</p>
  680. <p>If the specified slices fall outside that of the index range of
  681. the matrix, then the <code>matrix_vector_slice</code> is not a well
  682. formed Vector Expression. That is, access to an element which is
  683. outside of the matrix is <i>undefined</i>.</p>
  684. <h4>Type requirements</h4>
  685. <p>None, except for those imposed by the requirements of <a href=
  686. "expression_concept.html#vector_expression">Vector Expression</a> .</p>
  687. <h4>Public base classes</h4>
  688. <p><code>vector_expression&lt;matrix_vector_slice&lt;M&gt;
  689. &gt;</code></p>
  690. <h4>Members</h4>
  691. <table border="1" summary="members">
  692. <tbody>
  693. <tr>
  694. <th>Member</th>
  695. <th>Description</th>
  696. </tr>
  697. <tr>
  698. <td><code>matrix_vector_slice (matrix_type &amp;data,<br />
  699. const slice &amp;s1, const slice &amp;s2)</code></td>
  700. <td>Constructs a sub vector.</td>
  701. </tr>
  702. <tr>
  703. <td><code>size_type size () const</code></td>
  704. <td>Returns the size of the sub vector.</td>
  705. </tr>
  706. <tr>
  707. <td><code>const_reference operator () (size_type i)
  708. const</code></td>
  709. <td>Returns the value of the <code>i</code>-th element.</td>
  710. </tr>
  711. <tr>
  712. <td><code>reference operator () (size_type i)</code></td>
  713. <td>Returns a reference of the <code>i</code>-th element.</td>
  714. </tr>
  715. <tr>
  716. <td><code>matrix_vector_slice &amp;operator = (const
  717. matrix_vector_slice &amp;mvs)</code></td>
  718. <td>The assignment operator.</td>
  719. </tr>
  720. <tr>
  721. <td><code>matrix_vector_slice &amp;assign_temporary
  722. (matrix_vector_slice &amp;mvs)</code></td>
  723. <td>Assigns a temporary. May change the matrix vector slice
  724. <code>vs</code>.</td>
  725. </tr>
  726. <tr>
  727. <td><code>template&lt;class AE&gt;<br />
  728. matrix_vector_slice &amp;operator = (const
  729. vector_expression&lt;AE&gt; &amp;ae)</code></td>
  730. <td>The extended assignment operator.</td>
  731. </tr>
  732. <tr>
  733. <td><code>template&lt;class AE&gt;<br />
  734. matrix_vector_slice &amp;assign (const vector_expression&lt;AE&gt;
  735. &amp;ae)</code></td>
  736. <td>Assigns a vector expression to the sub vector. Left and right
  737. hand side of the assignment should be independent.</td>
  738. </tr>
  739. <tr>
  740. <td><code>template&lt;class AE&gt;<br />
  741. matrix_vector_slice &amp;operator += (const
  742. vector_expression&lt;AE&gt; &amp;ae)</code></td>
  743. <td>A computed assignment operator. Adds the vector expression to
  744. the sub vector.</td>
  745. </tr>
  746. <tr>
  747. <td><code>template&lt;class AE&gt;<br />
  748. matrix_vector_slice &amp;plus_assign (const
  749. vector_expression&lt;AE&gt; &amp;ae)</code></td>
  750. <td>Adds a vector expression to the sub vector. Left and right hand
  751. side of the assignment should be independent.</td>
  752. </tr>
  753. <tr>
  754. <td><code>template&lt;class AE&gt;<br />
  755. matrix_vector_slice &amp;operator -= (const
  756. vector_expression&lt;AE&gt; &amp;ae)</code></td>
  757. <td>A computed assignment operator. Subtracts the vector expression
  758. from the sub vector.</td>
  759. </tr>
  760. <tr>
  761. <td><code>template&lt;class AE&gt;<br />
  762. matrix_vector_slice &amp;minus_assign (const
  763. vector_expression&lt;AE&gt; &amp;ae)</code></td>
  764. <td>Subtracts a vector expression from the sub vector. Left and
  765. right hand side of the assignment should be independent.</td>
  766. </tr>
  767. <tr>
  768. <td><code>template&lt;class AT&gt;<br />
  769. matrix_vector_slice &amp;operator *= (const AT &amp;at)</code></td>
  770. <td>A computed assignment operator. Multiplies the sub vector with
  771. a scalar.</td>
  772. </tr>
  773. <tr>
  774. <td><code>template&lt;class AT&gt;<br />
  775. matrix_vector_slice &amp;operator /= (const AT &amp;at)</code></td>
  776. <td>A computed assignment operator. Divides the sub vector through
  777. a scalar.</td>
  778. </tr>
  779. <tr>
  780. <td><code>void swap (matrix_vector_slice &amp;mvs)</code></td>
  781. <td>Swaps the contents of the sub vectors.</td>
  782. </tr>
  783. <tr>
  784. <td><code>const_iterator begin () const</code></td>
  785. <td>Returns a <code>const_iterator</code> pointing to the beginning
  786. of the <code>matrix_vector_slice</code>.</td>
  787. </tr>
  788. <tr>
  789. <td><code>const_iterator end () const</code></td>
  790. <td>Returns a <code>const_iterator</code> pointing to the end of
  791. the <code>matrix_vector_slice</code>.</td>
  792. </tr>
  793. <tr>
  794. <td><code>iterator begin ()</code></td>
  795. <td>Returns a <code>iterator</code> pointing to the beginning of
  796. the <code>matrix_vector_slice</code>.</td>
  797. </tr>
  798. <tr>
  799. <td><code>iterator end ()</code></td>
  800. <td>Returns a <code>iterator</code> pointing to the end of the
  801. <code>matrix_vector_slice</code>.</td>
  802. </tr>
  803. <tr>
  804. <td><code>const_reverse_iterator rbegin () const</code></td>
  805. <td>Returns a <code>const_reverse_iterator</code> pointing to the
  806. beginning of the reversed <code>matrix_vector_slice</code>.</td>
  807. </tr>
  808. <tr>
  809. <td><code>const_reverse_iterator rend () const</code></td>
  810. <td>Returns a <code>const_reverse_iterator</code> pointing to the
  811. end of the reversed <code>matrix_vector_slice</code>.</td>
  812. </tr>
  813. <tr>
  814. <td><code>reverse_iterator rbegin ()</code></td>
  815. <td>Returns a <code>reverse_iterator</code> pointing to the
  816. beginning of the reversed <code>matrix_vector_slice</code>.</td>
  817. </tr>
  818. <tr>
  819. <td><code>reverse_iterator rend ()</code></td>
  820. <td>Returns a <code>reverse_iterator</code> pointing to the end of
  821. the reversed <code>matrix_vector_slice</code>.</td>
  822. </tr>
  823. </tbody>
  824. </table>
  825. <h2><a name="matrix_range"></a>Matrix Range</h2>
  826. <h4>Description</h4>
  827. <p>The templated class <code>matrix_range&lt;M&gt;</code> allows
  828. addressing a sub matrix of a matrix.</p>
  829. <h4>Example</h4>
  830. <pre>
  831. #include &lt;boost/numeric/ublas/matrix.hpp&gt;
  832. #include &lt;boost/numeric/ublas/matrix_proxy.hpp&gt;
  833. #include &lt;boost/numeric/ublas/io.hpp&gt;
  834. int main () {
  835. using namespace boost::numeric::ublas;
  836. matrix&lt;double&gt; m (3, 3);
  837. matrix_range&lt;matrix&lt;double&gt; &gt; mr (m, range (0, 3), range (0, 3));
  838. for (unsigned i = 0; i &lt; mr.size1 (); ++ i)
  839. for (unsigned j = 0; j &lt; mr.size2 (); ++ j)
  840. mr (i, j) = 3 * i + j;
  841. std::cout &lt;&lt; mr &lt;&lt; std::endl;
  842. }
  843. </pre>
  844. <h4>Definition</h4>
  845. <p>Defined in the header matrix_proxy.hpp.</p>
  846. <h4>Template parameters</h4>
  847. <table border="1" summary="parameters">
  848. <tbody>
  849. <tr>
  850. <th>Parameter</th>
  851. <th>Description</th>
  852. <th>Default</th>
  853. </tr>
  854. <tr>
  855. <td><code>M</code></td>
  856. <td>The type of matrix referenced.</td>
  857. <td></td>
  858. </tr>
  859. </tbody>
  860. </table>
  861. <h4>Model of</h4>
  862. <p><a href="expression_concept.html#matrix_expression">Matrix Expression</a>
  863. .</p>
  864. <p>If the specified ranges fall outside that of the index range of
  865. the matrix, then the <code>matrix_range</code> is not a well formed
  866. Matrix Expression. That is, access to an element which is outside
  867. of the matrix is <i>undefined</i>.</p>
  868. <h4>Type requirements</h4>
  869. <p>None, except for those imposed by the requirements of <a href=
  870. "expression_concept.html#matrix_expression">Matrix Expression</a> .</p>
  871. <h4>Public base classes</h4>
  872. <p><code>matrix_expression&lt;matrix_range&lt;M&gt; &gt;</code></p>
  873. <h4>Members</h4>
  874. <table border="1" summary="members">
  875. <tbody>
  876. <tr>
  877. <th>Member</th>
  878. <th>Description</th>
  879. </tr>
  880. <tr>
  881. <td><code>matrix_range (matrix_type &amp;data,<br />
  882. const range &amp;r1, const range &amp;r2)</code></td>
  883. <td>Constructs a sub matrix.</td>
  884. </tr>
  885. <tr>
  886. <td><code>size_type start1 () const</code></td>
  887. <td>Returns the index of the first row.</td>
  888. </tr>
  889. <tr>
  890. <td><code>size_type size1 () const</code></td>
  891. <td>Returns the number of rows.</td>
  892. </tr>
  893. <tr>
  894. <td><code>size_type start2 () const</code></td>
  895. <td>Returns the index of the first column.</td>
  896. </tr>
  897. <tr>
  898. <td><code>size_type size2 () const</code></td>
  899. <td>Returns the number of columns.</td>
  900. </tr>
  901. <tr>
  902. <td><code>const_reference operator () (size_type i, size_type j)
  903. const</code></td>
  904. <td>Returns the value of the <code>j</code>-th element in the
  905. <code>i</code>-th row.</td>
  906. </tr>
  907. <tr>
  908. <td><code>reference operator () (size_type i, size_type
  909. j)</code></td>
  910. <td>Returns a reference of the <code>j</code>-th element in the
  911. <code>i</code>-th row.</td>
  912. </tr>
  913. <tr>
  914. <td><code>matrix_range &amp;operator = (const matrix_range
  915. &amp;mr)</code></td>
  916. <td>The assignment operator.</td>
  917. </tr>
  918. <tr>
  919. <td><code>matrix_range &amp;assign_temporary (matrix_range
  920. &amp;mr)</code></td>
  921. <td>Assigns a temporary. May change the matrix range
  922. <code>mr</code> .</td>
  923. </tr>
  924. <tr>
  925. <td><code>template&lt;class AE&gt;<br />
  926. matrix_range &amp;operator = (const matrix_expression&lt;AE&gt;
  927. &amp;ae)</code></td>
  928. <td>The extended assignment operator.</td>
  929. </tr>
  930. <tr>
  931. <td><code>template&lt;class AE&gt;<br />
  932. matrix_range &amp;assign (const matrix_expression&lt;AE&gt;
  933. &amp;ae)</code></td>
  934. <td>Assigns a matrix expression to the sub matrix. Left and right
  935. hand side of the assignment should be independent.</td>
  936. </tr>
  937. <tr>
  938. <td><code>template&lt;class AE&gt;<br />
  939. matrix_range &amp;operator += (const matrix_expression&lt;AE&gt;
  940. &amp;ae)</code></td>
  941. <td>A computed assignment operator. Adds the matrix expression to
  942. the sub matrix.</td>
  943. </tr>
  944. <tr>
  945. <td><code>template&lt;class AE&gt;<br />
  946. matrix_range &amp;plus_assign (const matrix_expression&lt;AE&gt;
  947. &amp;ae)</code></td>
  948. <td>Adds a matrix expression to the sub matrix. Left and right hand
  949. side of the assignment should be independent.</td>
  950. </tr>
  951. <tr>
  952. <td><code>template&lt;class AE&gt;<br />
  953. matrix_range &amp;operator -= (const matrix_expression&lt;AE&gt;
  954. &amp;ae)</code></td>
  955. <td>A computed assignment operator. Subtracts the matrix expression
  956. from the sub matrix.</td>
  957. </tr>
  958. <tr>
  959. <td><code>template&lt;class AE&gt;<br />
  960. matrix_range &amp;minus_assign (const matrix_expression&lt;AE&gt;
  961. &amp;ae)</code></td>
  962. <td>Subtracts a matrix expression from the sub matrix. Left and
  963. right hand side of the assignment should be independent.</td>
  964. </tr>
  965. <tr>
  966. <td><code>template&lt;class AT&gt;<br />
  967. matrix_range &amp;operator *= (const AT &amp;at)</code></td>
  968. <td>A computed assignment operator. Multiplies the sub matrix with
  969. a scalar.</td>
  970. </tr>
  971. <tr>
  972. <td><code>template&lt;class AT&gt;<br />
  973. matrix_range &amp;operator /= (const AT &amp;at)</code></td>
  974. <td>A computed assignment operator. Divides the sub matrix through
  975. a scalar.</td>
  976. </tr>
  977. <tr>
  978. <td><code>void swap (matrix_range &amp;mr)</code></td>
  979. <td>Swaps the contents of the sub matrices.</td>
  980. </tr>
  981. <tr>
  982. <td><code>const_iterator1 begin1 () const</code></td>
  983. <td>Returns a <code>const_iterator1</code> pointing to the
  984. beginning of the <code>matrix_range</code>.</td>
  985. </tr>
  986. <tr>
  987. <td><code>const_iterator1 end1 () const</code></td>
  988. <td>Returns a <code>const_iterator1</code> pointing to the end of
  989. the <code>matrix_range</code>.</td>
  990. </tr>
  991. <tr>
  992. <td><code>iterator1 begin1 ()</code></td>
  993. <td>Returns a <code>iterator1</code> pointing to the beginning of
  994. the <code>matrix_range</code>.</td>
  995. </tr>
  996. <tr>
  997. <td><code>iterator1 end1 ()</code></td>
  998. <td>Returns a <code>iterator1</code> pointing to the end of the
  999. <code>matrix_range</code>.</td>
  1000. </tr>
  1001. <tr>
  1002. <td><code>const_iterator2 begin2 () const</code></td>
  1003. <td>Returns a <code>const_iterator2</code> pointing to the
  1004. beginning of the <code>matrix_range</code>.</td>
  1005. </tr>
  1006. <tr>
  1007. <td><code>const_iterator2 end2 () const</code></td>
  1008. <td>Returns a <code>const_iterator2</code> pointing to the end of
  1009. the <code>matrix_range</code>.</td>
  1010. </tr>
  1011. <tr>
  1012. <td><code>iterator2 begin2 ()</code></td>
  1013. <td>Returns a <code>iterator2</code> pointing to the beginning of
  1014. the <code>matrix_range</code>.</td>
  1015. </tr>
  1016. <tr>
  1017. <td><code>iterator2 end2 ()</code></td>
  1018. <td>Returns a <code>iterator2</code> pointing to the end of the
  1019. <code>matrix_range</code>.</td>
  1020. </tr>
  1021. <tr>
  1022. <td><code>const_reverse_iterator1 rbegin1 () const</code></td>
  1023. <td>Returns a <code>const_reverse_iterator1</code> pointing to the
  1024. beginning of the reversed <code>matrix_range</code>.</td>
  1025. </tr>
  1026. <tr>
  1027. <td><code>const_reverse_iterator1 rend1 () const</code></td>
  1028. <td>Returns a <code>const_reverse_iterator1</code> pointing to the
  1029. end of the reversed <code>matrix_range</code>.</td>
  1030. </tr>
  1031. <tr>
  1032. <td><code>reverse_iterator1 rbegin1 ()</code></td>
  1033. <td>Returns a <code>reverse_iterator1</code> pointing to the
  1034. beginning of the reversed <code>matrix_range</code>.</td>
  1035. </tr>
  1036. <tr>
  1037. <td><code>reverse_iterator1 rend1 ()</code></td>
  1038. <td>Returns a <code>reverse_iterator1</code> pointing to the end of
  1039. the reversed <code>matrix_range</code>.</td>
  1040. </tr>
  1041. <tr>
  1042. <td><code>const_reverse_iterator2 rbegin2 () const</code></td>
  1043. <td>Returns a <code>const_reverse_iterator2</code> pointing to the
  1044. beginning of the reversed <code>matrix_range</code>.</td>
  1045. </tr>
  1046. <tr>
  1047. <td><code>const_reverse_iterator2 rend2 () const</code></td>
  1048. <td>Returns a <code>const_reverse_iterator2</code> pointing to the
  1049. end of the reversed <code>matrix_range</code>.</td>
  1050. </tr>
  1051. <tr>
  1052. <td><code>reverse_iterator2 rbegin2 ()</code></td>
  1053. <td>Returns a <code>reverse_iterator2</code> pointing to the
  1054. beginning of the reversed <code>matrix_range</code>.</td>
  1055. </tr>
  1056. <tr>
  1057. <td><code>reverse_iterator2 rend2 ()</code></td>
  1058. <td>Returns a <code>reverse_iterator2</code> pointing to the end of
  1059. reversed the <code>matrix_range</code>.</td>
  1060. </tr>
  1061. </tbody>
  1062. </table>
  1063. <h3>Simple Projections</h3>
  1064. <h4>Description</h4>
  1065. <p>The free <code>subrange</code> functions support the construction
  1066. of matrix ranges.</p>
  1067. <h4>Prototypes</h4>
  1068. <pre><code>
  1069. template&lt;class M&gt;
  1070. matrix_range&lt;M&gt; subrange (M &amp;data,
  1071. M::size_type start1, M::size_type stop1, M::size_type start2, M::size_type, stop2);
  1072. template&lt;class M&gt;
  1073. const matrix_range&lt;const M&gt; subrange (const M &amp;data,
  1074. M::size_type start1, M::size_type stop1, M::size_type start2, M::size_type, stop2);
  1075. </code></pre>
  1076. <h3>Generic Projections</h3>
  1077. <h4>Description</h4>
  1078. <p>The free <code>project</code> functions support the construction
  1079. of matrix ranges. Existing <code>matrix_range</code>'s can be composed with further ranges. The resulting ranges are computed using this existing ranges' <code>compose</code> function.</p>
  1080. <h4>Prototypes</h4>
  1081. <pre><code>
  1082. template&lt;class M&gt;
  1083. matrix_range&lt;M&gt; project (M &amp;data, const range &amp;r1, const range &amp;r2);
  1084. template&lt;class M&gt;
  1085. const matrix_range&lt;const M&gt; project (const M &amp;data, const range &amp;r1, const range &amp;r2);
  1086. template&lt;class M&gt;
  1087. matrix_range&lt;M&gt; project (matrix_range&lt;M&gt; &amp;data, const range &amp;r1, const range &amp;r2);
  1088. template&lt;class M&gt;
  1089. const matrix_range&lt;M&gt; project (const matrix_range&lt;M&gt; &amp;data, const range &amp;r1, const range &amp;r2);
  1090. </code></pre>
  1091. <h4>Definition</h4>
  1092. <p>Defined in the header matrix_proxy.hpp.</p>
  1093. <h4>Type requirements</h4>
  1094. <ul>
  1095. <li><code>M</code> is a model of <a href=
  1096. "expression_concept.html#matrix_expression">Matrix Expression</a> .</li>
  1097. </ul>
  1098. <h4>Complexity</h4>
  1099. <p>Quadratic depending from the size of the ranges.</p>
  1100. <h4>Examples</h4>
  1101. <pre>
  1102. #include &lt;boost/numeric/ublas/matrix.hpp&gt;
  1103. #include &lt;boost/numeric/ublas/matrix_proxy.hpp&gt;
  1104. #include &lt;boost/numeric/ublas/io.hpp&gt;
  1105. int main () {
  1106. using namespace boost::numeric::ublas;
  1107. matrix&lt;double&gt; m (3, 3);
  1108. for (unsigned i = 0; i &lt; m.size1 (); ++ i)
  1109. for (unsigned j = 0; j &lt; m.size2 (); ++ j)
  1110. project (m, range (0, 3), range (0, 3)) (i, j) = 3 * i + j;
  1111. std::cout &lt;&lt; project (m, range (0, 3), range (0, 3)) &lt;&lt; std::endl;
  1112. }
  1113. </pre>
  1114. <h2><a name="matrix_slice"></a>Matrix Slice</h2>
  1115. <h4>Description</h4>
  1116. <p>The templated class <code>matrix_slice&lt;M&gt;</code> allows
  1117. addressing a sliced sub matrix of a matrix.</p>
  1118. <h4>Example</h4>
  1119. <pre>
  1120. #include &lt;boost/numeric/ublas/matrix.hpp&gt;
  1121. #include &lt;boost/numeric/ublas/matrix_proxy.hpp&gt;
  1122. #include &lt;boost/numeric/ublas/io.hpp&gt;
  1123. int main () {
  1124. using namespace boost::numeric::ublas;
  1125. matrix&lt;double&gt; m (3, 3);
  1126. matrix_slice&lt;matrix&lt;double&gt; &gt; ms (m, slice (0, 1, 3), slice (0, 1, 3));
  1127. for (unsigned i = 0; i &lt; ms.size1 (); ++ i)
  1128. for (unsigned j = 0; j &lt; ms.size2 (); ++ j)
  1129. ms (i, j) = 3 * i + j;
  1130. std::cout &lt;&lt; ms &lt;&lt; std::endl;
  1131. }
  1132. </pre>
  1133. <h4>Definition</h4>
  1134. <p>Defined in the header matrix_proxy.hpp.</p>
  1135. <h4>Template parameters</h4>
  1136. <table border="1" summary="parameters">
  1137. <tbody>
  1138. <tr>
  1139. <th>Parameter</th>
  1140. <th>Description</th>
  1141. <th>Default</th>
  1142. </tr>
  1143. <tr>
  1144. <td><code>M</code></td>
  1145. <td>The type of matrix referenced.</td>
  1146. <td></td>
  1147. </tr>
  1148. </tbody>
  1149. </table>
  1150. <h4>Model of</h4>
  1151. <p><a href="expression_concept.html#matrix_expression">Matrix Expression</a>
  1152. .</p>
  1153. <p>If the specified slices fall outside that of the index range of
  1154. the matrix, then the <code>matrix_slice</code> is not a well formed
  1155. Matrix Expression. That is, access to an element which is outside
  1156. of the matrix is <i>undefined</i>.</p>
  1157. <h4>Type requirements</h4>
  1158. <p>None, except for those imposed by the requirements of <a href=
  1159. "expression_concept.html#matrix_expression">Matrix Expression</a> .</p>
  1160. <h4>Public base classes</h4>
  1161. <p><code>matrix_expression&lt;matrix_slice&lt;M&gt; &gt;</code></p>
  1162. <h4>Members</h4>
  1163. <table border="1" summary="members">
  1164. <tbody>
  1165. <tr>
  1166. <th>Member</th>
  1167. <th>Description</th>
  1168. </tr>
  1169. <tr>
  1170. <td><code>matrix_slice (matrix_type &amp;data,<br />
  1171. const slice &amp;s1, const slice &amp;s2)</code></td>
  1172. <td>Constructs a sub matrix.</td>
  1173. </tr>
  1174. <tr>
  1175. <td><code>size_type size1 () const</code></td>
  1176. <td>Returns the number of rows.</td>
  1177. </tr>
  1178. <tr>
  1179. <td><code>size_type size2 () const</code></td>
  1180. <td>Returns the number of columns.</td>
  1181. </tr>
  1182. <tr>
  1183. <td><code>const_reference operator () (size_type i, size_type j)
  1184. const</code></td>
  1185. <td>Returns the value of the <code>j</code>-th element in the
  1186. <code>i</code>-th row.</td>
  1187. </tr>
  1188. <tr>
  1189. <td><code>reference operator () (size_type i, size_type
  1190. j)</code></td>
  1191. <td>Returns a reference of the <code>j</code>-th element in the
  1192. <code>i</code>-th row.</td>
  1193. </tr>
  1194. <tr>
  1195. <td><code>matrix_slice &amp;operator = (const matrix_slice
  1196. &amp;ms)</code></td>
  1197. <td>The assignment operator.</td>
  1198. </tr>
  1199. <tr>
  1200. <td><code>matrix_slice &amp;assign_temporary (matrix_slice
  1201. &amp;ms)</code></td>
  1202. <td>Assigns a temporary. May change the matrix slice
  1203. <code>ms</code> .</td>
  1204. </tr>
  1205. <tr>
  1206. <td><code>template&lt;class AE&gt;<br />
  1207. matrix_slice &amp;operator = (const matrix_expression&lt;AE&gt;
  1208. &amp;ae)</code></td>
  1209. <td>The extended assignment operator.</td>
  1210. </tr>
  1211. <tr>
  1212. <td><code>template&lt;class AE&gt;<br />
  1213. matrix_slice &amp;assign (const matrix_expression&lt;AE&gt;
  1214. &amp;ae)</code></td>
  1215. <td>Assigns a matrix expression to the sub matrix. Left and right
  1216. hand side of the assignment should be independent.</td>
  1217. </tr>
  1218. <tr>
  1219. <td><code>template&lt;class AE&gt;<br />
  1220. matrix_slice &amp;operator += (const matrix_expression&lt;AE&gt;
  1221. &amp;ae)</code></td>
  1222. <td>A computed assignment operator. Adds the matrix expression to
  1223. the sub matrix.</td>
  1224. </tr>
  1225. <tr>
  1226. <td><code>template&lt;class AE&gt;<br />
  1227. matrix_slice &amp;plus_assign (const matrix_expression&lt;AE&gt;
  1228. &amp;ae)</code></td>
  1229. <td>Adds a matrix expression to the sub matrix. Left and right hand
  1230. side of the assignment should be independent.</td>
  1231. </tr>
  1232. <tr>
  1233. <td><code>template&lt;class AE&gt;<br />
  1234. matrix_slice &amp;operator -= (const matrix_expression&lt;AE&gt;
  1235. &amp;ae)</code></td>
  1236. <td>A computed assignment operator. Subtracts the matrix expression
  1237. from the sub matrix.</td>
  1238. </tr>
  1239. <tr>
  1240. <td><code>template&lt;class AE&gt;<br />
  1241. matrix_slice &amp;minus_assign (const matrix_expression&lt;AE&gt;
  1242. &amp;ae)</code></td>
  1243. <td>Subtracts a matrix expression from the sub matrix. Left and
  1244. right hand side of the assignment should be independent.</td>
  1245. </tr>
  1246. <tr>
  1247. <td><code>template&lt;class AT&gt;<br />
  1248. matrix_slice &amp;operator *= (const AT &amp;at)</code></td>
  1249. <td>A computed assignment operator. Multiplies the sub matrix with
  1250. a scalar.</td>
  1251. </tr>
  1252. <tr>
  1253. <td><code>template&lt;class AT&gt;<br />
  1254. matrix_slice &amp;operator /= (const AT &amp;at)</code></td>
  1255. <td>A computed assignment operator. Multiplies the sub matrix
  1256. through a scalar.</td>
  1257. </tr>
  1258. <tr>
  1259. <td><code>void swap (matrix_slice &amp;ms)</code></td>
  1260. <td>Swaps the contents of the sub matrices.</td>
  1261. </tr>
  1262. <tr>
  1263. <td><code>const_iterator1 begin1 () const</code></td>
  1264. <td>Returns a <code>const_iterator1</code> pointing to the
  1265. beginning of the <code>matrix_slice</code>.</td>
  1266. </tr>
  1267. <tr>
  1268. <td><code>const_iterator1 end1 () const</code></td>
  1269. <td>Returns a <code>const_iterator1</code> pointing to the end of
  1270. the <code>matrix_slice</code>.</td>
  1271. </tr>
  1272. <tr>
  1273. <td><code>iterator1 begin1 ()</code></td>
  1274. <td>Returns a <code>iterator1</code> pointing to the beginning of
  1275. the <code>matrix_slice</code>.</td>
  1276. </tr>
  1277. <tr>
  1278. <td><code>iterator1 end1 ()</code></td>
  1279. <td>Returns a <code>iterator1</code> pointing to the end of the
  1280. <code>matrix_slice</code>.</td>
  1281. </tr>
  1282. <tr>
  1283. <td><code>const_iterator2 begin2 () const</code></td>
  1284. <td>Returns a <code>const_iterator2</code> pointing to the
  1285. beginning of the <code>matrix_slice</code>.</td>
  1286. </tr>
  1287. <tr>
  1288. <td><code>const_iterator2 end2 () const</code></td>
  1289. <td>Returns a <code>const_iterator2</code> pointing to the end of
  1290. the <code>matrix_slice</code>.</td>
  1291. </tr>
  1292. <tr>
  1293. <td><code>iterator2 begin2 ()</code></td>
  1294. <td>Returns a <code>iterator2</code> pointing to the beginning of
  1295. the <code>matrix_slice</code>.</td>
  1296. </tr>
  1297. <tr>
  1298. <td><code>iterator2 end2 ()</code></td>
  1299. <td>Returns a <code>iterator2</code> pointing to the end of the
  1300. <code>matrix_slice</code>.</td>
  1301. </tr>
  1302. <tr>
  1303. <td><code>const_reverse_iterator1 rbegin1 () const</code></td>
  1304. <td>Returns a <code>const_reverse_iterator1</code> pointing to the
  1305. beginning of the reversed <code>matrix_slice</code>.</td>
  1306. </tr>
  1307. <tr>
  1308. <td><code>const_reverse_iterator1 rend1 () const</code></td>
  1309. <td>Returns a <code>const_reverse_iterator1</code> pointing to the
  1310. end of the reversed <code>matrix_slice</code>.</td>
  1311. </tr>
  1312. <tr>
  1313. <td><code>reverse_iterator1 rbegin1 ()</code></td>
  1314. <td>Returns a <code>reverse_iterator1</code> pointing to the
  1315. beginning of the reversed <code>matrix_slice</code>.</td>
  1316. </tr>
  1317. <tr>
  1318. <td><code>reverse_iterator1 rend1 ()</code></td>
  1319. <td>Returns a <code>reverse_iterator1</code> pointing to the end of
  1320. the reversed <code>matrix_slice</code>.</td>
  1321. </tr>
  1322. <tr>
  1323. <td><code>const_reverse_iterator2 rbegin2 () const</code></td>
  1324. <td>Returns a <code>const_reverse_iterator2</code> pointing to the
  1325. beginning of the reversed <code>matrix_slice</code>.</td>
  1326. </tr>
  1327. <tr>
  1328. <td><code>const_reverse_iterator2 rend2 () const</code></td>
  1329. <td>Returns a <code>const_reverse_iterator2</code> pointing to the
  1330. end of the reversed <code>matrix_slice</code>.</td>
  1331. </tr>
  1332. <tr>
  1333. <td><code>reverse_iterator2 rbegin2 ()</code></td>
  1334. <td>Returns a <code>reverse_iterator2</code> pointing to the
  1335. beginning of the reversed <code>matrix_slice</code>.</td>
  1336. </tr>
  1337. <tr>
  1338. <td><code>reverse_iterator2 rend2 ()</code></td>
  1339. <td>Returns a <code>reverse_iterator2</code> pointing to the end of
  1340. the reversed <code>matrix_slice</code>.</td>
  1341. </tr>
  1342. </tbody>
  1343. </table>
  1344. <h3>Simple Projections</h3>
  1345. <h4>Description</h4>
  1346. <p>The free <code>subslice</code> functions support the construction
  1347. of matrix slices.</p>
  1348. <h4>Prototypes</h4>
  1349. <pre><code>
  1350. template&lt;class M&gt;
  1351. matrix_slice&lt;M&gt; subslice (M &amp;data,
  1352. M::size_type start1, M::difference_type stride1, M::size_type size1,
  1353. M::size_type start2, M::difference_type stride2, M::size_type size2);
  1354. template&lt;class M&gt;
  1355. const matrix_slice&lt;const M&gt; subslice (const M &amp;data,
  1356. M::size_type start1, M::difference_type stride1, M::size_type size1,
  1357. M::size_type start2, M::difference_type stride2, M::size_type size2);
  1358. </code></pre>
  1359. <h3>Generic Projections</h3>
  1360. <h4>Description</h4>
  1361. <p>The free <code>project</code> functions support the construction
  1362. of matrix slices. Existing <code>matrix_slice</code>'s can be composed with further ranges or slices. The resulting slices are computed using this existing slices' <code>compose</code> function.</p>
  1363. <h4>Prototypes</h4>
  1364. <pre><code>
  1365. template&lt;class M&gt;
  1366. matrix_slice&lt;M&gt; project (M &amp;data, const slice &amp;s1, const slice &amp;s2);
  1367. template&lt;class M&gt;
  1368. const matrix_slice&lt;const M&gt; project (const M &amp;data, const slice &amp;s1, const slice &amp;s2);
  1369. template&lt;class M&gt;
  1370. matrix_slice&lt;M&gt; project (matrix_slice&lt;M&gt; &amp;data, const range &amp;r1, const range &amp;r2);
  1371. template&lt;class M&gt;
  1372. const matrix_slice&lt;M&gt; project (const matrix_slice&lt;M&gt; &amp;data, const range &amp;r1, const range &amp;r2);
  1373. template&lt;class M&gt;
  1374. matrix_slice&lt;M&gt; project (matrix_slice&lt;M&gt; &amp;data, const slice &amp;s1, const slice &amp;s2);
  1375. template&lt;class M&gt;
  1376. const matrix_slice&lt;M&gt; project (const matrix_slice&lt;M&gt; &amp;data, const slice &amp;s1, const slice &amp;s2);
  1377. </code></pre>
  1378. <h4>Definition</h4>
  1379. <p>Defined in the header matrix_proxy.hpp.</p>
  1380. <h4>Type requirements</h4>
  1381. <ul>
  1382. <li><code>M</code> is a model of <a href=
  1383. "expression_concept.html#matrix_expression">Matrix Expression</a> .</li>
  1384. </ul>
  1385. <h4>Complexity</h4>
  1386. <p>Quadratic depending from the size of the slices.</p>
  1387. <h4>Examples</h4>
  1388. <pre>
  1389. #include &lt;boost/numeric/ublas/matrix.hpp&gt;
  1390. #include &lt;boost/numeric/ublas/matrix_proxy.hpp&gt;
  1391. #include &lt;boost/numeric/ublas/io.hpp&gt;
  1392. int main () {
  1393. using namespace boost::numeric::ublas;
  1394. matrix&lt;double&gt; m (3, 3);
  1395. for (unsigned i = 0; i &lt; m.size1 (); ++ i)
  1396. for (unsigned j = 0; j &lt; m.size2 (); ++ j)
  1397. project (m, slice (0, 1, 3), slice (0, 1, 3)) (i, j) = 3 * i + j;
  1398. std::cout &lt;&lt; project (m, slice (0, 1, 3), slice (0, 1, 3)) &lt;&lt; std::endl;
  1399. }
  1400. </pre>
  1401. <hr />
  1402. <p>Copyright (&copy;) 2000-2002 Joerg Walter, Mathias Koch<br />
  1403. Use, modification and distribution are subject to the
  1404. Boost Software License, Version 1.0.
  1405. (See accompanying file LICENSE_1_0.txt
  1406. or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
  1407. http://www.boost.org/LICENSE_1_0.txt
  1408. </a>).
  1409. </p>
  1410. <script type="text/javascript">
  1411. (function($) {
  1412. $('#toc').toc();
  1413. })(jQuery);
  1414. </script>
  1415. </body>
  1416. </html>