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">
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>
15 <h1><img src="../../../../boost.png" align="middle" />Overview of Matrix- and Vector-Types </h1>
16 <div class="toc" id="toc"></div>
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="#storage_layout">Special Storage Layouts</a></dd>
30 <table style="border: none;" summary="notation">
31 <tr><td><code>T</code></td>
32 <td>is the data type. For general linear algebra operations this will be a real type e.g. <code>double</code>, ...</td></tr>
33 <tr><td><code>F</code></td>
34 <td>is the orientation type (functor), either
35 <code>row_major</code> or <code>column_major</code></td></tr>
36 <tr><td><code>A, IA, TA</code></td> <td>is an array storage type, e.g. <code>std::vector,
37 bounded_array, unbounded_array, ...</code></td></tr>
38 <tr><td><code>TRI</code></td>
39 <td>is a triangular functor: <code>lower,
40 unit_lower, strict_lower, upper, unit_upper,
41 strict_upper</code></td></tr>
42 <tr><td><code>M, N</code></td>
43 <td>are unsigned integer sizes
44 (<code>std::size_t</code>)</td></tr>
45 <tr><td><code>IB</code></td>
47 (<code>std::size_t</code>)</td></tr>
48 <tr><td><code>VEC</code></td>
49 <td>is any vector type</td></tr>
50 <tr><td><code>MAT</code> </td>
51 <td>is any matrix type</td></tr>
52 <tr><td><code>[...]</code></td>
53 <td>denote optional arguments - for more details
54 look at the section "storage layout".</td></tr>
57 <h2><a id="vectors">Vectors</a></h2>
58 <table border="1" summary="vector types">
61 <th width="30%">Definition</th>
67 <td><code>vector<T [, A]><br /> v(size);</code></td>
68 <td>a dense vector of values of type <code>T</code> of variable
69 size. A storage type <code>A</code> can be specified
70 which defaults to <code>unbounded_array</code>.
71 Elements are constructed by <code>A</code>, which need not initialise their value.</td>
75 <td><code>bounded_vector<T, N><br /> v;</code></td>
76 <td>a dense vector of values of type <code>T</code> of variable size but with maximum
77 <code>N</code>. The default constructor creates <code>v</code>
78 with size <code>N</code>.
79 Elements are constructed by the storage type <code>bounded_array</code>, which need not initialise their value.</td>
82 <td><code>c_vector<T, M><br /> v(size);</code></td>
83 <td>a dense vector of values of type <code>T</code> with the given size.
84 The data is stored as an ordinary C++ array <code>T
88 <td><code>zero_vector<T><br /> v(size);</code></td>
89 <td>the zero vector of type <code>T</code> with the given
93 <td><code>unit_vector<T><br /> v(size, index);</code></td>
94 <td>the unit vector of type <code>T</code> with the given size. The
95 vector is zero other then a single specified element.
96 <br/><code>index</code> should be less than <code>size</code>.</td>
99 <td><code>mapped_vector<T [, S]><br /> v(size);</code></td>
100 <td>a sparse vector of values of type <code>T</code> of variable
101 size. The sparse storage type <code>S</code> can be <code>std::map<size_t,
102 T></code> or <code>map_array<size_t, T></code>.</td>
105 <td><code>compressed_vector<T [,IB, IA, TA]><br /> v(size);</code></td>
106 <td>a sparse vector of values of type <code>T</code> of variable
107 size. The non zero values are stored as two seperate arrays - an
108 index array and a value array. The index array is always sorted and
109 there is at most one entry for each index.</td>
112 <td><code>coordinate_vector<T [,IB, IA, TA]><br /> v(size);</code></td>
113 <td>a sparse vector of values of type <code>T</code> of variable
114 size. The non zero values are stored as two seperate arrays - an
115 index array and a value array. The arrays may be out of order with
116 multiple entries for each vector element. If there are multiple
117 values for the same index the sum of these values is the real
122 <p><em>Note:</em> the default types are defined in
123 <code>boost/numeric/ublas/fwd.hpp</code>.</p>
125 <h2><a id="vector_proxies">Vector Proxies</a></h2>
127 <table border="1" summary="vector proxies">
130 <th width="30%">Definition</th>
136 <td><code>vector_range<VEC><br /> vr(v, range);</code></td>
137 <td>a vector referencing a continuous subvector of elements of
138 vector <code>v</code> containing all elements specified by
139 <code>range</code>.</td>
142 <td><code>vector_slice<VEC><br /> vs(v, slice);</code></td>
143 <td>a vector referencing a non continuous subvector of elements of
144 vector <code>v</code> containing all elements specified by
145 <code>slice</code>.</td>
148 <td><code>matrix_row<MAT><br /> vr(m, index);</code></td>
149 <td>a vector referencing the <code>index</code>-th row of matrix
153 <td><code>matrix_column<MAT><br /> vc(m, index);</code></td>
154 <td>a vector referencing the <code>index</code>-th column of matrix
160 <h2><a id="matrices">Matrices</a></h2>
162 <table border="1" summary="matrix types">
165 <th width="30%">Definition</th>
171 <td><code>matrix<T [, F, A]><br /> m(size1, size2);</code></td>
172 <td>a dense matrix of values of type <code>T</code> of variable
173 size. A storage type <code>A</code> can be specified
174 which defaults to <code>unbounded_array</code>.
175 The orientation functor <code>F</code> defaults to
176 <code>row_major</code>.
177 Elements are constructed by <code>A</code>, which need not initialise their value.</td>
180 <td><code>bounded_matrix<T, M, N [, F]><br /> m;</code></td>
181 <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>
182 defaults to <code>row_major</code>. The default constructor creates
183 <code>m</code> with size <code>M</code>-by-<code>N</code>.
184 Elements are constructed by the storage type <code>bounded_array</code>, which need not initialise their value.</td>
187 <td><code>c_matrix<T, M, N><br /> m(size1, size2);</code></td>
188 <td>a dense matrix of values of type <code>T</code> with the given size.
189 The data is stored as an ordinary C++ array <code>T
190 data_[N][M]</code></td>
193 <td><code>vector_of_vector<T [, F, A]><br /> m(size1,
195 <td>a dense matrix of values of type <code>T</code> with the given size.
196 The data is stored as a vector of vectors. The orientation
197 <code>F</code> defaults to <code>row_major</code>. The storage
198 type <code>S</code> defaults to
199 <code>unbounded_array<unbounded_array<T> ></code></td>
202 <td><code>zero_matrix<T><br /> m(size1, size2);</code></td>
203 <td>a zero matrix of type <code>T</code> with the given size.</td>
206 <td><code>identity_matrix<T><br /> m(size1, size2);</code></td>
207 <td>an identity matrix of type <code>T</code> with the given size.
208 The values are <code>v(i,j) = (i==j)?T(1):T()</code>.</td>
211 <td><code>scalar_matrix<T><br /> m(size1, size2,
213 <td>a matrix of type <code>T</code> with the given size that has the
214 value <code>value</code> everywhere.</td>
217 <td><code>triangular_matrix<T [, TRI, F, A]><br />
219 <td>a triangular matrix of values of type <code>T</code> of
220 variable size. Only the nonzero elements are stored in the given
221 order <code>F</code>. ("triangular packed storage") The triangular
222 type <code>F</code> defaults to <code>lower</code>, the orientation
223 type <code>F</code> defaults to <code>row_major</code>.</td>
226 <td><code>banded_matrix<T [, F, A]><br /> m(size1, size2, n_lower,
227 n_upper);</code></td>
228 <td>a banded matrix of values of type <code>T</code> of variable
229 size with <code>n_lower</code> sub diagonals and
230 <code>n_upper</code> super diagonals. Only the nonzero elements are
231 stored in the given order <code>F</code>. ("packed storage")</td>
234 <td><code>symmetric_matrix<T [, TRI, F, A]><br />
236 <td>a symmetric matrix of values of type <code>T</code> of
237 variable size. Only the given triangular matrix is stored in the
238 given order <code>F</code>.</td>
241 <td><code>hermitian_matrix<T [, TRI, F, A]><br />
243 <td>a hermitian matrix of values of type <code>T</code> of
244 variable size. Only the given triangular matrix is stored using
245 the order <code>F</code>.</td>
248 <td><code>mapped_matrix<T, [F, S]><br /> m(size1, size2 [,
249 non_zeros]);</code></td>
250 <td>a sparse matrix of values of type <code>T</code> of variable
251 size. The sparse storage type <code>S</code> can be either <code>std::map<size_t,
252 std::map<size_t, T> ></code> or
253 <code>map_array<size_t, map_array<size_t,
254 T> ></code>.</td>
257 <td><code>sparse_vector_of_sparse_vector<T, [F, C]><br /> m(size1,
258 size2 [, non_zeros]);</code></td>
259 <td>a sparse matrix of values of type <code>T</code> of variable
263 <td><code>compressed_matrix<T, [F, IB, IA, TA]><br /> m(size1,
264 size2 [, non_zeros]);</code></td>
265 <td>a sparse matrix of values of type <code>T</code> of variable
266 size. The values are stored in compressed row/column storage.</td>
269 <td><code>coordinate_matrix<T, [F, IB, IA, TA]><br /> m(size1,
270 size2 [, non_zeros]);</code></td>
271 <td>a sparse matrix of values of type <code>T</code> of variable
272 size. The values are stored in 3 parallel array as triples (i, j,
273 value). More than one value for each pair of indices is possible,
274 the real value is the sum of all.</td>
277 <td><code>generalized_vector_of_vector<T, F, A><br /> m(size1,
278 size2 [, non_zeros]);</code></td>
279 <td>a sparse matrix of values of type <code>T</code> of variable
280 size. The values are stored as a vector of sparse vectors, e.g.
281 <code>generalized_vector_of_vector<double, row_major,
282 unbounded_array<coordinate_vector<double> > ></code></td>
286 <p><em>Note:</em> the default types are defined in
287 <code>boost/numeric/ublas/fwd.hpp</code>.</p>
289 <h2><a id="matrix_proxies">Matrix Proxies</a></h2>
291 <table border="1" summary="matrix proxies">
294 <th width="30%">Definition</th>
300 <td><code>triangular_adaptor<MAT, TRI><br /> ta(m);</code></td>
301 <td>a triangular matrix referencing a selection of elements of the
302 matrix <code>m</code>.</td>
305 <td><code>symmetric_adaptor<MAT, TRI><br /> sa(m);</code></td>
306 <td>a symmetric matrix referencing a selection of elements of the
307 matrix <code>m</code>.</td>
310 <td><code>hermitian_adaptor<MAT, TRI><br /> ha(m);</code></td>
311 <td>a hermitian matrix referencing a selection of elements of the
312 matrix <code>m</code>.</td>
315 <td><code>banded_adaptor<MAT><br /> ba(m, n_lower,
316 n_upper);</code></td>
317 <td>a banded matrix referencing a selection of elements of the
318 matrix <code>m</code>.</td>
321 <td><code>matrix_range<MAT, TRI><br /> mr(m, range1,
323 <td>a matrix referencing a submatrix of elements in the matrix
327 <td><code>matrix_slice<MAT, TRI><br /> ms(m, slice1,
329 <td>a matrix referencing a non continues submatrix of elements in
330 the matrix <code>m</code>.</td>
337 <h2><a id="storage_layout">Special Storage Layouts</a></h2>
340 <p>The library supports conventional dense, packed and basic sparse
341 vector and matrix storage layouts. The description of the most
342 common constructions of vectors and matrices comes next.</p>
344 <table border="1" summary="storage layouts">
347 <th width="30%">Construction</th>
351 <td><code>vector<T,<br />
352 std::vector<T> ><br />
353 v (size)</code></td>
354 <td>a dense vector, storage is provided by a standard
356 The storage layout usually is BLAS compliant.</td>
359 <td><code>vector<T,<br />
360 unbounded_array<T> ><br />
361 v (size)</code></td>
362 <td>a dense vector, storage is provided by a heap-based
364 The storage layout usually is BLAS compliant.</td>
367 <td><code>vector<T,<br />
368 bounded_array<T, N> ><br />
369 v (size)</code></td>
370 <td>a dense vector, storage is provided by a stack-based
372 The storage layout usually is BLAS compliant.</td>
375 <td><code>mapped_vector<T,<br />
376 std::map<std::size_t, T> ><br />
377 v (size, non_zeros)</code></td>
378 <td>a sparse vector, storage is provided by a standard
382 <td><code>mapped_vector<T,<br />
383 map_array<std::size_t, T> ><br />
384 v (size, non_zeros)</code></td>
385 <td>a sparse vector, storage is provided by a map
389 <td><code>matrix<T,<br />
390 row_major,<br />
391 std::vector<T> ><br />
392 m (size1, size2)</code></td>
393 <td>a dense matrix, orientation is row major, storage is
394 provided by a standard vector.</td>
397 <td><code>matrix<T,<br />
398 column_major,<br />
399 std::vector<T> ><br />
400 m (size1, size2)</code></td>
401 <td>a dense matrix, orientation is column major, storage
402 is provided by a standard vector.<br />
403 The storage layout usually is BLAS compliant.</td>
406 <td><code>matrix<T,<br />
407 row_major,<br />
408 unbounded_array<T> ><br />
409 m (size1, size2)</code></td>
410 <td>a dense matrix, orientation is row major, storage is
411 provided by a heap-based array.</td>
414 <td><code>matrix<T,<br />
415 column_major,<br />
416 unbounded_array<T> ><br />
417 m (size1, size2)</code></td>
418 <td>a dense matrix, orientation is column major, storage
419 is provided by a heap-based array.<br />
420 The storage layout usually is BLAS compliant.</td>
423 <td><code>matrix<T,<br />
424 row_major,<br />
425 bounded_array<T, N1 * N2> ><br />
426 m (size1, size2)</code></td>
427 <td>a dense matrix, orientation is row major, storage is
428 provided by a stack-based array.</td>
431 <td><code>matrix<T,<br />
432 column_major,<br />
433 bounded_array<T, N1 * N2> ><br />
434 m (size1, size2)</code></td>
435 <td>a dense matrix, orientation is column major, storage
436 is provided by a stack-based array.<br />
437 The storage layout usually is BLAS compliant.</td>
440 <td><code>triangular_matrix<T,<br />
441 row_major, F, A><br />
442 m (size)</code></td>
443 <td>a packed triangular matrix, orientation is row
447 <td><code>triangular_matrix<T,<br />
448 column_major, F, A><br />
449 m (size)</code></td>
450 <td>a packed triangular matrix, orientation is column
452 The storage layout usually is BLAS compliant.</td>
455 <td><code>banded_matrix<T,<br />
456 row_major, A><br />
457 m (size1, size2, lower, upper)</code></td>
458 <td>a packed banded matrix, orientation is row
462 <td><code>banded_matrix<T,<br />
463 column_major, A><br />
464 m (size1, size2, lower, upper)</code></td>
465 <td>a packed banded matrix, orientation is column
467 The storage layout usually is BLAS compliant.</td>
470 <td><code>symmetric_matrix<T,<br />
471 row_major, F, A><br />
472 m (size)</code></td>
473 <td>a packed symmetric matrix, orientation is row
477 <td><code>symmetric_matrix<T,<br />
478 column_major, F, A><br />
479 m (size)</code></td>
480 <td>a packed symmetric matrix, orientation is column
482 The storage layout usually is BLAS compliant.</td>
485 <td><code>hermitian_matrix<T,<br />
486 row_major, F, A><br />
487 m (size)</code></td>
488 <td>a packed hermitian matrix, orientation is row
492 <td><code>hermitian_matrix<T,<br />
493 column_major, F, A><br />
494 m (size)</code></td>
495 <td>a packed hermitian matrix, orientation is column
497 The storage layout usually is BLAS compliant.</td>
500 <td><code>mapped_matrix<T,<br />
501 row_major,<br />
502 std::map<std::size_t, T> ><br />
503 m (size1, size2, non_zeros)</code></td>
504 <td>a sparse matrix, orientation is row major, storage
505 is provided by a standard map.</td>
508 <td><code>mapped_matrix<T,<br />
509 column_major,<br />
510 std::map<std::size_t, T> ><br />
511 m (size1, size2, non_zeros)</code></td>
512 <td>a sparse matrix, orientation is column major,
513 storage is provided by a standard map.</td>
516 <td><code>mapped_matrix<T,<br />
517 row_major,<br />
518 map_array<std::size_t, T> ><br />
519 m (size1, size2, non_zeros)</code></td>
520 <td>a sparse matrix, orientation is row major, storage
521 is provided by a map array.</td>
524 <td><code>mapped_matrix<T,<br />
525 column_major,<br />
526 map_array<std::size_t, T> ><br />
527 m (size1, size2, non_zeros)</code></td>
528 <td>a sparse matrix, orientation is column major,
529 storage is provided by a map array.</td>
532 <td><code>compressed_matrix<T,<br />
533 row_major><br />
534 m (size1, size2, non_zeros)</code></td>
535 <td>a compressed matrix, orientation is row major.<br />
536 The storage layout usually is BLAS compliant.</td>
539 <td><code>compressed_matrix<T,<br />
540 column_major><br />
541 m (size1, size2, non_zeros)</code></td>
542 <td>a compressed matrix, orientation is column
544 The storage layout usually is BLAS compliant.</td>
547 <td><code>coordinate_matrix<T,<br />
548 row_major><br />
549 m (size1, size2, non_zeros)</code></td>
550 <td>a coordinate matrix, orientation is row major.<br />
551 The storage layout usually is BLAS compliant.</td>
554 <td><code>coordinate_matrix<T,<br />
555 column_major><br />
556 m (size1, size2, non_zeros)</code></td>
557 <td>a coordinate matrix, orientation is column
559 The storage layout usually is BLAS compliant.</td>
565 <p>Copyright (©) 2000-2004 Joerg Walter, Mathias Koch, Gunter
566 Winkler, Michael Stevens<br />
567 Use, modification and distribution are subject to the
568 Boost Software License, Version 1.0.
569 (See accompanying file LICENSE_1_0.txt
570 or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
571 http://www.boost.org/LICENSE_1_0.txt
574 <script type="text/javascript">