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 name="GENERATOR" content="Quanta Plus" /> 8<link rel="stylesheet" href="../../../../boost.css" type="text/css"/> 9<link rel="stylesheet" href="ublas.css" type="text/css" /> 10<script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script> 11<script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script> 12<title>Types Overview</title> 13</head> 14<body> 15<h1><img src="../../../../boost.png" align="middle" />Overview of Tensor, Matrix- and Vector Types </h1> 16<div class="toc" id="toc"></div> 17 18<dl> 19<dt>Contents:</dt> 20<dd><a href="#vectors">Vectors</a></dd> 21<dd><a href="#vector_proxies">Vector Proxies</a></dd> 22<dd><a href="#matrices">Matrices</a></dd> 23<dd><a href="#matrix_proxies">Matrix Proxies</a></dd> 24<dd><a href="#tensors">Tensors</a></dd> 25<dd><a href="#storage_layout">Special Storage Layouts</a></dd> 26</dl> 27 28 29<h2>Notation</h2> 30 31<table style="border: none;" summary="notation"> 32<tr><td><code>T</code></td> 33<td>is the data type. For general linear algebra operations this will be a real type e.g. <code>double</code>, ...</td></tr> 34<tr><td><code>F</code></td> 35<td>is the orientation type, either 36<code>row_major</code> or <code>column_major</code> for matrices and <code>first_order</code> or <code>last_order</code> for tensors</td></tr> 37<tr><td><code>A, IA, TA</code></td> <td>is an array storage type, e.g. <code>std::vector, 38bounded_array, unbounded_array, ...</code></td></tr> 39<tr><td><code>TRI</code></td> 40<td>is a triangular functor: <code>lower, 41unit_lower, strict_lower, upper, unit_upper, 42strict_upper</code></td></tr> 43<tr><td><code>M, N, K</code></td> 44<td>are unsigned integer sizes 45(<code>std::size_t</code>)</td></tr> 46<tr><td><code>IB</code></td> 47<td>is an index base 48(<code>std::size_t</code>)</td></tr> 49<tr><td><code>VEC</code></td> 50<td>is any vector type</td></tr> 51<tr><td><code>MAT</code> </td> 52<td>is any matrix type</td></tr> 53<tr><td><code>TEN</code> </td> 54<td>is any tensor type</td></tr> 55<tr><td><code>[...]</code></td> 56<td>denote optional arguments - for more details 57look at the section "storage layout".</td></tr> 58</table> 59 60<h2><a id="vectors">Vectors</a></h2> 61<table border="1" summary="vector types"> 62<thead> 63<tr> 64<th width="30%">Definition</th> 65<th>Description</th> 66</tr> 67</thead> 68<tbody> 69<tr> 70<td><code>vector<T [, A]><br /> v(size);</code></td> 71<td>a dense vector of values of type <code>T</code> of variable 72size. A storage type <code>A</code> can be specified 73which defaults to <code>unbounded_array</code>. 74Elements are constructed by <code>A</code>, which need not initialise their value.</td> 75 76</tr> 77<tr> 78<td><code>bounded_vector<T, N><br /> v;</code></td> 79<td>a dense vector of values of type <code>T</code> of variable size but with maximum 80<code>N</code>. The default constructor creates <code>v</code> 81with size <code>N</code>. 82Elements are constructed by the storage type <code>bounded_array</code>, which need not initialise their value.</td> 83</tr> 84<tr> 85<td><code>c_vector<T, M><br /> v(size);</code></td> 86<td>a dense vector of values of type <code>T</code> with the given size. 87The data is stored as an ordinary C++ array <code>T 88data_[M]</code></td> 89</tr> 90<tr> 91<td><code>zero_vector<T><br /> v(size);</code></td> 92<td>the zero vector of type <code>T</code> with the given 93size.</td> 94</tr> 95<tr> 96<td><code>unit_vector<T><br /> v(size, index);</code></td> 97<td>the unit vector of type <code>T</code> with the given size. The 98vector is zero other then a single specified element. 99<br/><code>index</code> should be less than <code>size</code>.</td> 100</tr> 101<tr> 102<td><code>mapped_vector<T [, S]><br /> v(size);</code></td> 103<td>a sparse vector of values of type <code>T</code> of variable 104size. The sparse storage type <code>S</code> can be <code>std::map<size_t, 105T></code> or <code>map_array<size_t, T></code>.</td> 106</tr> 107<tr> 108<td><code>compressed_vector<T [,IB, IA, TA]><br /> v(size);</code></td> 109<td>a sparse vector of values of type <code>T</code> of variable 110size. The non zero values are stored as two seperate arrays - an 111index array and a value array. The index array is always sorted and 112there is at most one entry for each index.</td> 113</tr> 114<tr> 115<td><code>coordinate_vector<T [,IB, IA, TA]><br /> v(size);</code></td> 116<td>a sparse vector of values of type <code>T</code> of variable 117size. The non zero values are stored as two seperate arrays - an 118index array and a value array. The arrays may be out of order with 119multiple entries for each vector element. If there are multiple 120values for the same index the sum of these values is the real 121value.</td> 122</tr> 123</tbody> 124</table> 125<p><em>Note:</em> the default types are defined in 126<code>boost/numeric/ublas/fwd.hpp</code>.</p> 127 128<h2><a id="vector_proxies">Vector Proxies</a></h2> 129 130<table border="1" summary="vector proxies"> 131<thead> 132<tr> 133<th width="30%">Definition</th> 134<th>Description</th> 135</tr> 136</thead> 137<tbody> 138<tr> 139<td><code>vector_range<VEC><br /> vr(v, range);</code></td> 140<td>a vector referencing a continuous subvector of elements of 141vector <code>v</code> containing all elements specified by 142<code>range</code>.</td> 143</tr> 144<tr> 145<td><code>vector_slice<VEC><br /> vs(v, slice);</code></td> 146<td>a vector referencing a non continuous subvector of elements of 147vector <code>v</code> containing all elements specified by 148<code>slice</code>.</td> 149</tr> 150<tr> 151<td><code>matrix_row<MAT><br /> vr(m, index);</code></td> 152<td>a vector referencing the <code>index</code>-th row of matrix 153<code>m</code></td> 154</tr> 155<tr> 156<td><code>matrix_column<MAT><br /> vc(m, index);</code></td> 157<td>a vector referencing the <code>index</code>-th column of matrix 158<code>m</code></td> 159</tr> 160</tbody> 161</table> 162 163<h2><a id="matrices">Matrices</a></h2> 164 165<table border="1" summary="matrix types"> 166<thead> 167<tr> 168<th width="30%">Definition</th> 169<th>Description</th> 170</tr> 171</thead> 172<tbody> 173<tr> 174<td><code>matrix<T [, F, A]><br /> m(size1, size2);</code></td> 175<td>a dense matrix of values of type <code>T</code> of variable 176size. A storage type <code>A</code> can be specified 177which defaults to <code>unbounded_array</code>. 178The orientation functor <code>F</code> defaults to 179<code>row_major</code>. 180Elements are constructed by <code>A</code>, which need not initialise their value.</td> 181</tr> 182<tr> 183<td><code>bounded_matrix<T, M, N [, F]><br /> m;</code></td> 184<td>a dense matrix of type <code>T</code> with variable size with maximum <code>M</code>-by-<code>N</code>. The orientation functor <code>F</code> 185defaults to <code>row_major</code>. The default constructor creates 186<code>m</code> with size <code>M</code>-by-<code>N</code>. 187Elements are constructed by the storage type <code>bounded_array</code>, which need not initialise their value.</td> 188</tr> 189<tr> 190<td><code>c_matrix<T, M, N><br /> m(size1, size2);</code></td> 191<td>a dense matrix of values of type <code>T</code> with the given size. 192The data is stored as an ordinary C++ array <code>T 193data_[N][M]</code></td> 194</tr> 195<tr> 196<td><code>vector_of_vector<T [, F, A]><br /> m(size1, 197size2);</code></td> 198<td>a dense matrix of values of type <code>T</code> with the given size. 199The data is stored as a vector of vectors. The orientation 200<code>F</code> defaults to <code>row_major</code>. The storage 201type <code>S</code> defaults to 202<code>unbounded_array<unbounded_array<T> ></code></td> 203</tr> 204<tr> 205<td><code>zero_matrix<T><br /> m(size1, size2);</code></td> 206<td>a zero matrix of type <code>T</code> with the given size.</td> 207</tr> 208<tr> 209<td><code>identity_matrix<T><br /> m(size1, size2);</code></td> 210<td>an identity matrix of type <code>T</code> with the given size. 211The values are <code>v(i,j) = (i==j)?T(1):T()</code>.</td> 212</tr> 213<tr> 214<td><code>scalar_matrix<T><br /> m(size1, size2, 215value);</code></td> 216<td>a matrix of type <code>T</code> with the given size that has the 217value <code>value</code> everywhere.</td> 218</tr> 219<tr> 220<td><code>triangular_matrix<T [, TRI, F, A]><br /> 221m(size);</code></td> 222<td>a triangular matrix of values of type <code>T</code> of 223variable size. Only the nonzero elements are stored in the given 224order <code>F</code>. ("triangular packed storage") The triangular 225type <code>F</code> defaults to <code>lower</code>, the orientation 226type <code>F</code> defaults to <code>row_major</code>.</td> 227</tr> 228<tr> 229<td><code>banded_matrix<T [, F, A]><br /> m(size1, size2, n_lower, 230n_upper);</code></td> 231<td>a banded matrix of values of type <code>T</code> of variable 232size with <code>n_lower</code> sub diagonals and 233<code>n_upper</code> super diagonals. Only the nonzero elements are 234stored in the given order <code>F</code>. ("packed storage")</td> 235</tr> 236<tr> 237<td><code>symmetric_matrix<T [, TRI, F, A]><br /> 238m(size);</code></td> 239<td>a symmetric matrix of values of type <code>T</code> of 240variable size. Only the given triangular matrix is stored in the 241given order <code>F</code>.</td> 242</tr> 243<tr> 244<td><code>hermitian_matrix<T [, TRI, F, A]><br /> 245m(size);</code></td> 246<td>a hermitian matrix of values of type <code>T</code> of 247variable size. Only the given triangular matrix is stored using 248the order <code>F</code>.</td> 249</tr> 250<tr> 251<td><code>mapped_matrix<T, [F, S]><br /> m(size1, size2 [, 252non_zeros]);</code></td> 253<td>a sparse matrix of values of type <code>T</code> of variable 254size. The sparse storage type <code>S</code> can be either <code>std::map<size_t, 255std::map<size_t, T> ></code> or 256<code>map_array<size_t, map_array<size_t, 257T> ></code>.</td> 258</tr> 259<tr> 260<td><code>sparse_vector_of_sparse_vector<T, [F, C]><br /> m(size1, 261size2 [, non_zeros]);</code></td> 262<td>a sparse matrix of values of type <code>T</code> of variable 263size.</td> 264</tr> 265<tr> 266<td><code>compressed_matrix<T, [F, IB, IA, TA]><br /> m(size1, 267size2 [, non_zeros]);</code></td> 268<td>a sparse matrix of values of type <code>T</code> of variable 269size. The values are stored in compressed row/column storage.</td> 270</tr> 271<tr> 272<td><code>coordinate_matrix<T, [F, IB, IA, TA]><br /> m(size1, 273size2 [, non_zeros]);</code></td> 274<td>a sparse matrix of values of type <code>T</code> of variable 275size. The values are stored in 3 parallel array as triples (i, j, 276value). More than one value for each pair of indices is possible, 277the real value is the sum of all.</td> 278</tr> 279<tr> 280<td><code>generalized_vector_of_vector<T, F, A><br /> m(size1, 281size2 [, non_zeros]);</code></td> 282<td>a sparse matrix of values of type <code>T</code> of variable 283size. The values are stored as a vector of sparse vectors, e.g. 284<code>generalized_vector_of_vector<double, row_major, 285unbounded_array<coordinate_vector<double> > ></code></td> 286</tr> 287</tbody> 288</table> 289<p><em>Note:</em> the default types are defined in 290<code>boost/numeric/ublas/fwd.hpp</code>.</p> 291 292<h2><a id="matrix_proxies">Matrix Proxies</a></h2> 293 294<table border="1" summary="matrix proxies"> 295<thead> 296<tr> 297<th width="30%">Definition</th> 298<th>Description</th> 299</tr> 300</thead> 301<tbody> 302<tr> 303<td><code>triangular_adaptor<MAT, TRI><br /> ta(m);</code></td> 304<td>a triangular matrix referencing a selection of elements of the 305matrix <code>m</code>.</td> 306</tr> 307<tr> 308<td><code>symmetric_adaptor<MAT, TRI><br /> sa(m);</code></td> 309<td>a symmetric matrix referencing a selection of elements of the 310matrix <code>m</code>.</td> 311</tr> 312<tr> 313<td><code>hermitian_adaptor<MAT, TRI><br /> ha(m);</code></td> 314<td>a hermitian matrix referencing a selection of elements of the 315matrix <code>m</code>.</td> 316</tr> 317<tr> 318<td><code>banded_adaptor<MAT><br /> ba(m, n_lower, 319n_upper);</code></td> 320<td>a banded matrix referencing a selection of elements of the 321matrix <code>m</code>.</td> 322</tr> 323<tr> 324<td><code>matrix_range<MAT, TRI><br /> mr(m, range1, 325range2);</code></td> 326<td>a matrix referencing a submatrix of elements in the matrix 327<code>m</code>.</td> 328</tr> 329<tr> 330<td><code>matrix_slice<MAT, TRI><br /> ms(m, slice1, 331slice2);</code></td> 332<td>a matrix referencing a non continues submatrix of elements in 333the matrix <code>m</code>.</td> 334</tr> 335</tbody> 336</table> 337 338 339 340<h2><a id="tensors">Tensors</a></h2> 341 342<table border="1" summary="tensor types"> 343<thead> 344<tr> 345<th width="10%">Definition</th> 346<th>Description</th> 347</tr> 348</thead> 349<tbody> 350<tr> 351<td><code>tensor<T [, F, A]><br /> t(size1, size2, ... );</code></td> 352<td>a dense matrix of values of type <code>T</code> of variable 353size. A storage type <code>A</code> can be specified 354which defaults to <code>std::vector<T></code>. 355The orientation type <code>F</code> defaults to 356<code>first_order</code>. 357Elements are constructed by <code>A</code>, which need not initialise their value.</td> 358</tr> 359</tbody> 360</table> 361 362 363 364 365<h2><a id="storage_layout">Special Storage Layouts</a></h2> 366 367 368<p>The library supports conventional dense, packed and basic sparse 369vector and matrix storage layouts. The description of the most 370common constructions of vectors and matrices comes next.</p> 371 372<table border="1" summary="storage layouts"> 373<tbody> 374<tr> 375<th width="30%">Construction</th> 376<th>Comment</th> 377</tr> 378<tr> 379<td><code>vector<T,<br /> 380 std::vector<T> ><br /> 381 v (size)</code></td> 382<td>a dense vector, storage is provided by a standard 383vector.<br /> 384The storage layout usually is BLAS compliant.</td> 385</tr> 386<tr> 387<td><code>vector<T,<br /> 388 unbounded_array<T> ><br /> 389 v (size)</code></td> 390<td>a dense vector, storage is provided by a heap-based 391array.<br /> 392The storage layout usually is BLAS compliant.</td> 393</tr> 394<tr> 395<td><code>vector<T,<br /> 396 bounded_array<T, N> ><br /> 397 v (size)</code></td> 398<td>a dense vector, storage is provided by a stack-based 399array.<br /> 400The storage layout usually is BLAS compliant.</td> 401</tr> 402<tr> 403<td><code>mapped_vector<T,<br /> 404 std::map<std::size_t, T> ><br /> 405 v (size, non_zeros)</code></td> 406<td>a sparse vector, storage is provided by a standard 407map.</td> 408</tr> 409<tr> 410<td><code>mapped_vector<T,<br /> 411 map_array<std::size_t, T> ><br /> 412 v (size, non_zeros)</code></td> 413<td>a sparse vector, storage is provided by a map 414array.</td> 415</tr> 416<tr> 417<td><code>matrix<T,<br /> 418 row_major,<br /> 419 std::vector<T> ><br /> 420 m (size1, size2)</code></td> 421<td>a dense matrix, orientation is row major, storage is 422provided by a standard vector.</td> 423</tr> 424<tr> 425<td><code>matrix<T,<br /> 426 column_major,<br /> 427 std::vector<T> ><br /> 428 m (size1, size2)</code></td> 429<td>a dense matrix, orientation is column major, storage 430is provided by a standard vector.<br /> 431The storage layout usually is BLAS compliant.</td> 432</tr> 433<tr> 434<td><code>matrix<T,<br /> 435 row_major,<br /> 436 unbounded_array<T> ><br /> 437 m (size1, size2)</code></td> 438<td>a dense matrix, orientation is row major, storage is 439provided by a heap-based array.</td> 440</tr> 441<tr> 442<td><code>matrix<T,<br /> 443 column_major,<br /> 444 unbounded_array<T> ><br /> 445 m (size1, size2)</code></td> 446<td>a dense matrix, orientation is column major, storage 447is provided by a heap-based array.<br /> 448The storage layout usually is BLAS compliant.</td> 449</tr> 450<tr> 451<td><code>matrix<T,<br /> 452 row_major,<br /> 453 bounded_array<T, N1 * N2> ><br /> 454 m (size1, size2)</code></td> 455<td>a dense matrix, orientation is row major, storage is 456provided by a stack-based array.</td> 457</tr> 458<tr> 459<td><code>matrix<T,<br /> 460 column_major,<br /> 461 bounded_array<T, N1 * N2> ><br /> 462 m (size1, size2)</code></td> 463<td>a dense matrix, orientation is column major, storage 464is provided by a stack-based array.<br /> 465The storage layout usually is BLAS compliant.</td> 466</tr> 467<tr> 468<td><code>triangular_matrix<T,<br /> 469 row_major, F, A><br /> 470 m (size)</code></td> 471<td>a packed triangular matrix, orientation is row 472major.</td> 473</tr> 474<tr> 475<td><code>triangular_matrix<T,<br /> 476 column_major, F, A><br /> 477 m (size)</code></td> 478<td>a packed triangular matrix, orientation is column 479major.<br /> 480The storage layout usually is BLAS compliant.</td> 481</tr> 482<tr> 483<td><code>banded_matrix<T,<br /> 484 row_major, A><br /> 485 m (size1, size2, lower, upper)</code></td> 486<td>a packed banded matrix, orientation is row 487major.</td> 488</tr> 489<tr> 490<td><code>banded_matrix<T,<br /> 491 column_major, A><br /> 492 m (size1, size2, lower, upper)</code></td> 493<td>a packed banded matrix, orientation is column 494major.<br /> 495The storage layout usually is BLAS compliant.</td> 496</tr> 497<tr> 498<td><code>symmetric_matrix<T,<br /> 499 row_major, F, A><br /> 500 m (size)</code></td> 501<td>a packed symmetric matrix, orientation is row 502major.</td> 503</tr> 504<tr> 505<td><code>symmetric_matrix<T,<br /> 506 column_major, F, A><br /> 507 m (size)</code></td> 508<td>a packed symmetric matrix, orientation is column 509major.<br /> 510The storage layout usually is BLAS compliant.</td> 511</tr> 512<tr> 513<td><code>hermitian_matrix<T,<br /> 514 row_major, F, A><br /> 515 m (size)</code></td> 516<td>a packed hermitian matrix, orientation is row 517major.</td> 518</tr> 519<tr> 520<td><code>hermitian_matrix<T,<br /> 521 column_major, F, A><br /> 522 m (size)</code></td> 523<td>a packed hermitian matrix, orientation is column 524major.<br /> 525The storage layout usually is BLAS compliant.</td> 526</tr> 527<tr> 528<td><code>mapped_matrix<T,<br /> 529 row_major,<br /> 530 std::map<std::size_t, T> ><br /> 531 m (size1, size2, non_zeros)</code></td> 532<td>a sparse matrix, orientation is row major, storage 533is provided by a standard map.</td> 534</tr> 535<tr> 536<td><code>mapped_matrix<T,<br /> 537 column_major,<br /> 538 std::map<std::size_t, T> ><br /> 539 m (size1, size2, non_zeros)</code></td> 540<td>a sparse matrix, orientation is column major, 541storage is provided by a standard map.</td> 542</tr> 543<tr> 544<td><code>mapped_matrix<T,<br /> 545 row_major,<br /> 546 map_array<std::size_t, T> ><br /> 547 m (size1, size2, non_zeros)</code></td> 548<td>a sparse matrix, orientation is row major, storage 549is provided by a map array.</td> 550</tr> 551<tr> 552<td><code>mapped_matrix<T,<br /> 553 column_major,<br /> 554 map_array<std::size_t, T> ><br /> 555 m (size1, size2, non_zeros)</code></td> 556<td>a sparse matrix, orientation is column major, 557storage is provided by a map array.</td> 558</tr> 559<tr> 560<td><code>compressed_matrix<T,<br /> 561 row_major><br /> 562 m (size1, size2, non_zeros)</code></td> 563<td>a compressed matrix, orientation is row major.<br /> 564The storage layout usually is BLAS compliant.</td> 565</tr> 566<tr> 567<td><code>compressed_matrix<T,<br /> 568 column_major><br /> 569 m (size1, size2, non_zeros)</code></td> 570<td>a compressed matrix, orientation is column 571major.<br /> 572The storage layout usually is BLAS compliant.</td> 573</tr> 574<tr> 575<td><code>coordinate_matrix<T,<br /> 576 row_major><br /> 577 m (size1, size2, non_zeros)</code></td> 578<td>a coordinate matrix, orientation is row major.<br /> 579The storage layout usually is BLAS compliant.</td> 580</tr> 581<tr> 582<td><code>coordinate_matrix<T,<br /> 583 column_major><br /> 584 m (size1, size2, non_zeros)</code></td> 585<td>a coordinate matrix, orientation is column 586major.<br /> 587The storage layout usually is BLAS compliant.</td> 588</tr> 589</tbody> 590</table> 591 592<hr /> 593<p>Copyright (©) 2000-2004 Joerg Walter, Mathias Koch, Gunter 594Winkler, Michael Stevens<br /> 595 Use, modification and distribution are subject to the 596 Boost Software License, Version 1.0. 597 (See accompanying file LICENSE_1_0.txt 598 or copy at <a href="http://www.boost.org/LICENSE_1_0.txt"> 599 http://www.boost.org/LICENSE_1_0.txt 600 </a>). 601</p> 602<script type="text/javascript"> 603(function($) { 604 $('#toc').toc(); 605})(jQuery); 606</script> 607</body> 608</html> 609