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