container_concept.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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. <script type="text/x-mathjax-config">
  14. MathJax.Hub.Config({
  15. jax: ["input/TeX", "output/HTML-CSS"],
  16. extensions: ["tex2jax.js"],
  17. "HTML-CSS": { preferredFont: "TeX", availableFonts: ["STIX","TeX"], scale: "70" },
  18. tex2jax: {
  19. inlineMath: [ ["$", "$"], ["\\(","\\)"] ],
  20. displayMath: [ ["$$","$$"], ["\\[", "\\]"] ],
  21. processEscapes: true,
  22. ignoreClass: "tex2jax_ignore|dno" },
  23. TeX: { noUndefined: { attributes: { mathcolor: "red", mathbackground: "#FFEEEE", mathsize: "90%" } } },
  24. messageStyle: "none"
  25. });
  26. </script>
  27. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js"></script>
  28. <title>Container Concepts</title>
  29. </head>
  30. <body>
  31. <h1><img src="../../../../boost.png" align="middle" />Container Concepts</h1>
  32. <div class="toc" id="toc"></div>
  33. <h2><a name="vector"></a>Vector</h2>
  34. <h4>Description</h4>
  35. <p>A Vector describes common aspects of dense, packed and sparse
  36. vectors.</p>
  37. <h4>Refinement of</h4>
  38. <p><a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a>,
  39. <a href="expression_concept.html#vector_expression">Vector Expression</a>
  40. <a href="#vector_expression_note">[1]</a>.</p>
  41. <h4>Associated types</h4>
  42. <p>In addition to the types defined by <a href="expression_concept.html#vector_expression">Vector Expression</a></p>
  43. <table border="1" summary="types">
  44. <tbody>
  45. <tr>
  46. <td>Public base</td>
  47. <td>vector_container&lt;V&gt;</td>
  48. <td>V must be derived from this public base type.</td>
  49. </tr>
  50. <tr>
  51. <td>Storage array</td>
  52. <td>V::array_type</td>
  53. <td>
  54. Dense Vector ONLY. The type of underlying storage array used to store the elements. The array_type must model the
  55. <a href="storage_concept.html"><b>Storage</b></a> concept.</td>
  56. </tr>
  57. </tbody>
  58. </table>
  59. <h4>Notation</h4>
  60. <table border="0" summary="notation">
  61. <tbody>
  62. <tr>
  63. <td><code>V</code></td>
  64. <td>A type that is a model of Vector</td>
  65. </tr>
  66. <tr>
  67. <td><code>v</code></td>
  68. <td>Objects of type <code>V</code></td>
  69. </tr>
  70. <tr>
  71. <td><code>n, i</code></td>
  72. <td>Objects of a type convertible to <code>size_type</code></td>
  73. </tr>
  74. <tr>
  75. <td><code>t</code></td>
  76. <td>Object of a type convertible to <code>value_type</code></td>
  77. </tr>
  78. <tr>
  79. <td><code>p</code></td>
  80. <td>Object of a type convertible to <code>bool</code></td>
  81. </tr>
  82. </tbody>
  83. </table>
  84. <h4>Definitions</h4>
  85. <h4>Valid expressions</h4>
  86. <p>In addition to the expressions defined in <a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a>,
  87. <a href="expression_concept.html#vector_expression">Vector Expression</a> the following expressions must be valid.</p>
  88. <table border="1" summary="expressions">
  89. <tbody>
  90. <tr>
  91. <th>Name</th>
  92. <th>Expression</th>
  93. <th>Type requirements</th>
  94. <th>Return type</th>
  95. </tr>
  96. <tr>
  97. <td>Sizing constructor</td>
  98. <td><code>V v (n)</code></td>
  99. <td>&nbsp;</td>
  100. <td><code>V</code></td>
  101. </tr>
  102. <tr>
  103. <td>Insert</td>
  104. <td><code>v.insert_element (i, t)</code></td>
  105. <td><code>v</code> is mutable.</td>
  106. <td><code>void</code></td>
  107. </tr>
  108. <tr>
  109. <td>Erase</td>
  110. <td><code>v.erase_element (i)</code></td>
  111. <td><code>v</code> is mutable.</td>
  112. <td><code>void</code></td>
  113. </tr>
  114. <tr>
  115. <td>Clear</td>
  116. <td><code>v.clear ()</code></td>
  117. <td><code>v</code> is mutable.</td>
  118. <td><code>void</code></td>
  119. </tr>
  120. <tr>
  121. <td>Resize</td>
  122. <td><code>v.resize (n)</code><br />
  123. <code>v.resize (n, p)</code></td>
  124. <td><code>v</code> is mutable.</td>
  125. <td><code>void</code></td>
  126. </tr>
  127. <tr>
  128. <td>Storage</td>
  129. <td><code>v.data()</code></td>
  130. <td><code>v</code> is mutable and Dense.</td>
  131. <td><code>array_type&amp;</code> if <code>v</code> is mutable, <code>const array_type&amp;</code> otherwise</td>
  132. </tr>
  133. </tbody>
  134. </table>
  135. <h4>Expression semantics</h4>
  136. <p>Semantics of an expression is defined only where it differs
  137. from, or is not defined in <a href=
  138. "expression_concept.html#vector_expression">Vector Expression</a> .</p>
  139. <table border="1" summary="semantics">
  140. <tr>
  141. <th>Name</th>
  142. <th>Expression</th>
  143. <th>Precondition</th>
  144. <th>Semantics</th>
  145. <th>Postcondition</th>
  146. </tr>
  147. <tr>
  148. <td>Sizing constructor</td>
  149. <td><code>V v (n)</code></td>
  150. <td><code>n &gt;= 0</code></td>
  151. <td>Allocates a vector of<code>n</code> elements.</td>
  152. <td><code>v.size () == n</code>.</td>
  153. </tr>
  154. <tr>
  155. <td>Element access <a href="#element_access_note">[2]</a></td>
  156. <td><code>v[n]</code></td>
  157. <td><code>0&lt;n&gt;v.size()</code></td>
  158. <td>returns the n-th element in v</td>
  159. <td>&nbsp;</td>
  160. </tr>
  161. <tr>
  162. <td>Insert</td>
  163. <td><code>v.insert_element (i, t)</code></td>
  164. <td><code>0 &lt;= i &lt; v.size ()</code>.</td>
  165. <td>Inserts an element at <code>v (i)</code> with value <code>t</code>.
  166. The storage requirement of the Vector may be increased.</td>
  167. <td><code>v (i)</code> is equal to <code>t</code>.</td>
  168. </tr>
  169. <tr>
  170. <td>Erase</td>
  171. <td><code>v.erase_element (i)</code></td>
  172. <td><code>0 &lt;= i &lt; v.size ()</code></td>
  173. <td>Destroys the element as <code>v (i)</code> and replaces it with the default
  174. <code>value_type ()</code>.
  175. The storage requirement of the Vector may be decreased.</td>
  176. <td><code>v (i)</code> is equal to <code>value_type ()</code>.</td>
  177. </tr>
  178. <tr>
  179. <td>Clear</td>
  180. <td><code>v.clear ()</code></td>
  181. <td>&nbsp;</td>
  182. <td>Equivalent to<br />
  183. <code>for (i = 0; i &lt; v.size (); ++ i)</code><br />
  184. &nbsp; <code>v.erase_element (i);</code></td>
  185. <td>&nbsp;</td>
  186. </tr>
  187. <tr>
  188. <td>Resize</td>
  189. <td><code>v.resize (n)
  190. <br />v.resize (n, p)</code></td>
  191. <td>&nbsp;</td>
  192. <td>Reallocates the vector so that it can hold <code>n</code>
  193. elements.<br />
  194. Erases or appends elements in order to bring the vector to the prescribed size. Appended elements copies of <code>value_type()</code>.
  195. <br />
  196. When <code>p == false</code> then existing elements are not preserved and elements will not appended as normal. Instead the vector is in the same state as that after an equivalent sizing constructor.</td>
  197. <td><code>v.size () == n</code>.</td>
  198. </tr>
  199. <tr>
  200. <td>Storage</td>
  201. <td><code>v.data()</code></td>
  202. <td></td>
  203. <td>Returns a reference to the underlying dense storage.</td>
  204. <td>&nbsp;</td>
  205. </tr>
  206. </table>
  207. <h4>Complexity guarantees</h4>
  208. <p>The run-time complexity of the sizing constructor is linear in
  209. the vector's size.</p>
  210. <p>The run-time complexity of insert_element and erase_element is specific for the
  211. Vector model and it depends on increases/decreases in storage requirements.</p>
  212. <p>The run-time complexity of resize is linear in the vector's
  213. size.</p>
  214. <h4>Invariants</h4>
  215. <h4>Models</h4>
  216. <ul>
  217. <li><code>vector</code>, <code>bounded_vector</code>, <code>c_vector</code></li>
  218. <li><code>unit_vector</code>, <code>zero_vector</code>, <code>scalar_vector</code></li>
  219. <li><code>mapped_vector;</code>, <code>compressed_vector</code>, <code>coordinate_vector</code></li>
  220. </ul>
  221. <h4>Notes</h4>
  222. <p><a name="vector_expression_note">[1]</a>
  223. As a user you need not care about <tt>Vector</tt> being a refinement of the VectorExpression. Being a refinement of the VectorExpression is only important for the template-expression engine but not the user.</p>
  224. <p><a name="element_access_note">[2]</a>
  225. The <code>operator[]</code> is added purely for convenience
  226. and compatibility with the <code>std::vector</code>. In uBLAS however,
  227. generally <code>operator()</code> is used for indexing because this can be
  228. used for both vectors and matrices.</p>
  229. <hr>
  230. <!--......................................................................-->
  231. <h2><a name="matrix"></a>Matrix</h2>
  232. <h4>Description</h4>
  233. <p>A Matrix describes common aspects of dense, packed and sparse
  234. matrices.</p>
  235. <h4>Refinement of</h4>
  236. <p><a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a>,
  237. <a href="expression_concept.html#matrix_expression">Matrix Expression</a>
  238. <a href="#matrix_expression_note">[1]</a>
  239. .</p>
  240. <h4>Associated types</h4>
  241. <p>In addition to the types defined by <a href="expression_concept.html#matrix_expression">Matrix Expression</a></p>
  242. <table border="1" summary="types">
  243. <tbody>
  244. <tr>
  245. <td>Public base</td>
  246. <td>matrix_container&lt;M&gt;</td>
  247. <td>M must be derived from this public base type.</td>
  248. </tr>
  249. <tr>
  250. <td>Storage array</td>
  251. <td>M::array_type</td>
  252. <td>Dense Matrix ONLY. The type of underlying storage array used to store the elements. The array_type must model
  253. the <a href="storage_concept.html"><b>Storage</b></a> concept.</td>
  254. </tr>
  255. </tbody>
  256. </table>
  257. <h4>Notation</h4>
  258. <table border="0" summary="notation">
  259. <tbody>
  260. <tr>
  261. <td><code>M</code></td>
  262. <td>A type that is a model of Matrix</td>
  263. </tr>
  264. <tr>
  265. <td><code>m</code></td>
  266. <td>Objects of type <code>M</code></td>
  267. </tr>
  268. <tr>
  269. <td><code>n1, n2, i, j</code></td>
  270. <td>Objects of a type convertible to <code>size_type</code></td>
  271. </tr>
  272. <tr>
  273. <td><code>t</code></td>
  274. <td>Object of a type convertible to <code>value_type</code></td>
  275. </tr>
  276. <tr>
  277. <td><code>p</code></td>
  278. <td>Object of a type convertible to <code>bool</code></td>
  279. </tr>
  280. </tbody>
  281. </table>
  282. <h4>Definitions</h4>
  283. <h4>Valid expressions</h4>
  284. <p>In addition to the expressions defined in <a href=
  285. "expression_concept.html#matrix_expression">Matrix Expression</a> the
  286. following expressions must be valid.</p>
  287. <table border="1" summary="expressions">
  288. <tbody>
  289. <tr>
  290. <th>Name</th>
  291. <th>Expression</th>
  292. <th>Type requirements</th>
  293. <th>Return type</th>
  294. </tr>
  295. <tr>
  296. <td>Sizing constructor</td>
  297. <td><code>M m (n1, n2)</code></td>
  298. <td>&nbsp;</td>
  299. <td><code>M</code></td>
  300. </tr>
  301. <tr>
  302. <td>Insert</td>
  303. <td><code>m.insert_element (i, j, t)</code></td>
  304. <td><code>m</code> is mutable.</td>
  305. <td><code>void</code></td>
  306. </tr>
  307. <tr>
  308. <td>Erase</td>
  309. <td><code>m.erase_element (i, j)</code></td>
  310. <td><code>m</code> is mutable.</td>
  311. <td><code>void</code></td>
  312. </tr>
  313. <tr>
  314. <td>Clear</td>
  315. <td><code>m.clear ()</code></td>
  316. <td><code>m</code> is mutable.</td>
  317. <td><code>void</code></td>
  318. </tr>
  319. <tr>
  320. <td>Resize</td>
  321. <td><code>m.resize (n1, n2)</code><br />
  322. <code>m.resize (n1, n2, p)</code></td>
  323. <td><code>m</code> is mutable.</td>
  324. <td><code>void</code></td>
  325. </tr>
  326. <tr>
  327. <td>Storage</td>
  328. <td><code>m.data()</code></td>
  329. <td><code>m</code> is mutable and Dense.</td>
  330. <td><code>array_type&amp;</code> if <code>m</code> is mutable, <code>const array_type&amp;</code> otherwise</td>
  331. </tr>
  332. </tbody>
  333. </table>
  334. <h4>Expression semantics</h4>
  335. <p>Semantics of an expression is defined only where it differs
  336. from, or is not defined in <a href=
  337. "expression_concept.html#matrix_expression">Matrix Expression</a> .</p>
  338. <table border="1" summary="semantics">
  339. <tbody>
  340. <tr>
  341. <th>Name</th>
  342. <th>Expression</th>
  343. <th>Precondition</th>
  344. <th>Semantics</th>
  345. <th>Postcondition</th>
  346. </tr>
  347. <tr>
  348. <td>Sizing constructor</td>
  349. <td><code>M m (n1, n2)</code></td>
  350. <td><code>n1 &gt;= 0</code> and <code>n2 &gt;= 0</code></td>
  351. <td>Allocates a matrix of <code>n1</code> rows and <code>n2</code>
  352. columns.</td>
  353. <td><code>m.size1 () == n1</code> and <code>m.size2 () ==
  354. n2</code>.</td>
  355. </tr>
  356. <tr>
  357. <td>Insert</td>
  358. <td><code>m.insert_element (i, j, t)</code></td>
  359. <td><code>0 &lt;= i &lt; m.size1 ()</code>,<br />
  360. <code>0 &lt;= j &lt; m.size2 ()</code>.</td>
  361. <td>Inserts an element at <code>m (i, j)</code> with value <code>t</code>.
  362. The storage requirement of the Matrix may be increased.</td>
  363. <td><code>m (i, j)</code> is equal to <code>t</code>.</td>
  364. </tr>
  365. <tr>
  366. <td>Erase</td>
  367. <td><code>m.erase_element (i, j)</code></td>
  368. <td><code>0 &lt;= i &lt; m.size1 ()</code>and <code><br />
  369. 0 &lt;= j &lt; m.size2</code></td>
  370. <td>Destroys the element as <code>m (i, j)</code> and replaces it with the default
  371. <code>value_type ()</code>.
  372. The storage requirement of the Matrix may be decreased.</td>
  373. <td><code>m (i, j)</code> is equal to <code>value_type ()</code>.</td>
  374. </tr>
  375. <tr>
  376. <td>Clear</td>
  377. <td><code>m.clear ()</code></td>
  378. <td>&nbsp;</td>
  379. <td>Equivalent to<br />
  380. <code>for (i = 0; i &lt; m.size1 (); ++ i)</code><br />
  381. &nbsp; <code>for (j = 0; j &lt; m.size2 (); ++ j)</code><br />
  382. &nbsp; &nbsp; <code>m.erase_element (i, j);</code></td>
  383. <td>&nbsp;</td>
  384. </tr>
  385. <tr>
  386. <td>Resize</td>
  387. <td><code>m.resize (n1, n2)
  388. <br />
  389. m.resize (n1, n2, p)
  390. </code></td>
  391. <td>&nbsp;</td>
  392. <td>Reallocate the matrix so that it can hold <code>n1</code> rows
  393. and <code>n2</code> columns.<br />
  394. Erases or appends elements in order to bring the matrix to the
  395. prescribed size. Appended elements are <code>value_type()</code>
  396. copies.<br />
  397. When <code>p == false</code> then existing elements are not preserved and elements will not appended as normal. Instead the matrix is in the same state as that after an equivalent sizing constructor.</td>
  398. <td><code>m.size1 () == n1</code> and <code>m.size2 () == n2</code>.</td>
  399. </tr>
  400. <tr>
  401. <td>Storage</td>
  402. <td><code>m.data()</code></td>
  403. <td></td>
  404. <td>Returns a reference to the underlying dense storage.</td>
  405. <td>&nbsp;</td>
  406. </tbody>
  407. </table>
  408. <h4>Complexity guarantees</h4>
  409. <p>The run-time complexity of the sizing constructor is quadratic
  410. in the matrix's size.</p>
  411. <p>The run-time complexity of insert_element and erase_element is specific for the
  412. Matrix model and it depends on increases/decreases in storage requirements.</p>
  413. <p>The run-time complexity of resize is quadratic in the matrix's
  414. size.</p>
  415. <h4>Invariants</h4>
  416. <h4>Models</h4>
  417. <ul>
  418. <li><code>matrix</code>, <code>bounded_matrix</code>, <code>c_matrix</code></li>
  419. <li><code>identity_matrix</code> , <code>zero_matrix</code> , <code>scalar_matrix</code></li>
  420. <li><code>triangular_matrix</code> , <code>symmetric_matrix</code> , <code>banded_matrix</code></li>
  421. <li><code>mapped_matrix</code> , <code>compressed_matrix</code> , <code>coordinate_matrix</code></li>
  422. </ul>
  423. <h4>Notes</h4>
  424. <p><a name="matrix_expression_note">[1]</a>
  425. As a user you need not care about <tt>Matrix</tt> being a refinement of the MatrixExpression. Being a refinement of the MatrixExpression is only important for the template-expression engine but not the user.</p>
  426. <hr>
  427. <!--......................................................................-->
  428. <h2><a name="tensor"></a>Tensor</h2>
  429. <h4>Description</h4>
  430. <p>A Tensor describes common aspects of dense multidimensional arrays.</p>
  431. <h4>Refinement of</h4>
  432. <p><a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a>,
  433. <a href="expression_concept.html#tensor_expression">Tensor Expression</a>
  434. <a href="#tensor_expression_note">[1]</a>
  435. .</p>
  436. <h4>Associated types</h4>
  437. <p>In addition to the types defined by <a href="expression_concept.html#tensor_expression">Tensor Expression</a></p>
  438. <table border="1" summary="types">
  439. <tbody>
  440. <tr>
  441. <td>Public base</td>
  442. <td><code>tensor_container&lt;tensor_t&gt;</code></td>
  443. <td><code>tensor_t</code> must be derived from this public base type.</td>
  444. </tr>
  445. <tr>
  446. <td>Storage array</td>
  447. <td><code>tensor_t::array_type<code></td>
  448. <td>Dense tensor ONLY. The type of underlying storage array used to store the elements. The array_type must model
  449. the <a href="storage_concept.html"><b>Storage</b></a> concept.</td>
  450. </tr>
  451. </tbody>
  452. </table>
  453. <h4>Notation</h4>
  454. <table border="0" summary="notation">
  455. <tbody>
  456. <tr>
  457. <td><code>tensor_t</code></td>
  458. <td>A type that is a model of Tensor</td>
  459. </tr>
  460. <tr>
  461. <td><code>t</code></td>
  462. <td>Objects of type <code>tensor_t</code></td>
  463. </tr>
  464. <tr>
  465. <td><code>n1, n2, np, m1, m2, mq </code></td>
  466. <td>Dimension objects of a type convertible to <code>size_type</code></td>
  467. </tr>
  468. <tr>
  469. <td><code>i1, i2, ip, j, k </code></td>
  470. <td>Index objects of a type convertible to <code>size_type</code></td>
  471. </tr>
  472. <tr>
  473. <td><code>v</code></td>
  474. <td>Object of a type convertible to <code>value_type</code></td>
  475. </tr>
  476. </tbody>
  477. </table>
  478. <h4>Definitions</h4>
  479. <h4>Valid expressions</h4>
  480. <p>In addition to the expressions defined in <a href=
  481. "expression_concept.html#tensor_expression">Tensor Expression</a> the
  482. following expressions must be valid.</p>
  483. <table border="1" summary="expressions">
  484. <tbody>
  485. <tr>
  486. <th>Name</th>
  487. <th>Expression</th>
  488. <th>Type requirements</th>
  489. <th>Return type</th>
  490. </tr>
  491. <tr>
  492. <td>Sizing constructor</td>
  493. <td><code>T t(n1, n2, ..., np)</code></td>
  494. <td>&nbsp;</td>
  495. <td><code>T</code></td>
  496. </tr>
  497. <tr>
  498. <td>Write</td>
  499. <td><code>t.at(i1, i2, ..., ip)</code></td>
  500. <td><code>t</code> is mutable.</td>
  501. <td><code>void</code></td>
  502. </tr>
  503. <tr>
  504. <td>Read</td>
  505. <td><code>t.at(i1, i2, ..., ip)</code></td>
  506. <td><code>t</code> is mutable.</td>
  507. <td><code>v</code></td>
  508. </tr>
  509. <tr>
  510. <td>Clear</td>
  511. <td><code>t.clear ()</code></td>
  512. <td><code>t</code> is mutable.</td>
  513. <td><code>void</code></td>
  514. </tr>
  515. <tr>
  516. <td>Resize</td>
  517. <td><code>t.resize(m1, m2, ... , mq)</code></td>
  518. <td><code>t</code> is mutable.</td>
  519. <td><code>void</code></td>
  520. </tr>
  521. <tr>
  522. <td>Storage</td>
  523. <td><code>t.data()</code></td>
  524. <td><code>t</code> is mutable and dense.</td>
  525. <td><code>pointer</code> if <code>t</code> is mutable, <code>const_pointer</code> otherwise</td>
  526. </tr>
  527. </tbody>
  528. </table>
  529. <h4>Expression semantics</h4>
  530. <p>Semantics of an expression is defined only where it differs
  531. from, or is not defined in <a href=
  532. "expression_concept.html#tensor_expression">Tensor Expression</a> .</p>
  533. <table border="1" summary="semantics">
  534. <tbody>
  535. <tr>
  536. <th>Name</th>
  537. <th>Expression</th>
  538. <th>Precondition</th>
  539. <th>Semantics</th>
  540. <th>Postcondition</th>
  541. </tr>
  542. <tr>
  543. <td>Sizing constructor</td>
  544. <td><code>T t(n1, n2, ..., np)</code></td>
  545. <td>$n_r \geq 1$ for $1\leq 1 \leq p $</code></td>
  546. <td>Allocates a <code>p</code>-order tensor with dimension extents $n_1,n_2,\dots,n_p$.</td>
  547. <td><code>t.size(r)==nr</code> for $1\leq r \leq p$.</td>
  548. </tr>
  549. <tr>
  550. <td>Write</td>
  551. <td><code>t.at(i1,i2,...,ip)=v</code></td>
  552. <td>$0 \leq i_r < n_r$ for $1 \leq r \leq p$.</td>
  553. <td>Writes an element at multi-index position $i_1,i_2,\dots,i_p$ with value <code>v</code>.</td>
  554. <td><code>t(i1,i2,...,ip)</code> is equal to <code>v</code>.</td>
  555. <tr>
  556. <td>Read</td>
  557. <td><code>v=t.at(i1,i2,...,ip)</code></td>
  558. <td>$0 \leq i_r < n_r$ for $1 \leq r \leq p$.</td>
  559. <td>Reads the element at multi-index position $(i_1,i2_,\dots,i_p)$ and returns a value <code>v</code>.</td>
  560. <td><code>t(i1,i2,...,ip)</code> is equal to <code>v</code>.</td>
  561. </tr>
  562. <tr>
  563. <td>Clear</td>
  564. <td><code>t.clear()</code></td>
  565. <td>&nbsp;</td>
  566. <td>Removes all elements from the container.</td>
  567. <td>&nbsp;</td>
  568. </tr>
  569. <tr>
  570. <td>Resize</td>
  571. <td><code>t.resize(m1, m2, ..., mq)</code></td>
  572. <td>$m_r \geq 1$ for $1\leq 1 \leq q $</code></td>
  573. <td>Reallocate the matrix so that it can hold $m_1\times m_2\times \cdots \times m_q$ elements.<br />
  574. Erases or appends elements in order to bring the matrix to the
  575. prescribed size. Appended elements are <code>value_type()</code>
  576. copies.</td>
  577. <td><code>t.size(r) == mr</code> for $1\leq r \leq q$.</td>
  578. </tr>
  579. <tr>
  580. <td>Storage</td>
  581. <td><code>m.data()</code></td>
  582. <td></td>
  583. <td>Returns a reference to the underlying dense storage.</td>
  584. <td>&nbsp;</td>
  585. </tbody>
  586. </table>
  587. <h4>Complexity guarantees</h4>
  588. <p>The run-time complexity of contructor is linear in the tensor's size $n_1 \times n_2 \times \cdots \times n_p$.</p>
  589. <p>The run-time complexity of <code>write()</code> and <code>read()</code> is linear in the order of the tensor.</p>
  590. <p>The run-time complexity of resize is at most linear in the tensor's size $m_1 \times m_2 \times \cdots \times n_q$.</p>
  591. <h4>Invariants</h4>
  592. <h4>Models</h4>
  593. <ul>
  594. <li><code>tensor</code></li>
  595. </ul>
  596. <h4>Notes</h4>
  597. <p><a name="tensor_expression_note">[1]</a>
  598. As a user you need not care about <tt>Tensor</tt> being a refinement of the TensorExpression. Being a refinement of the TensorExpression is only important for the template-expression engine but not the user.</p>
  599. <hr />
  600. <p>
  601. Copyright (&copy;) 2000-2002 Joerg Walter, Mathias Koch<br />
  602. Copyright (&copy;) 2018 Cem Bassoy<br />
  603. Use, modification and distribution are subject to the
  604. Boost Software License, Version 1.0.
  605. (See accompanying file LICENSE_1_0.txt
  606. or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
  607. http://www.boost.org/LICENSE_1_0.txt
  608. </a>).
  609. </p>
  610. <script type="text/javascript">
  611. (function($) {
  612. $('#toc').toc();
  613. })(jQuery);
  614. </script>
  615. </body>
  616. </html>