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>Sparse Matrix</title> 14</head> 15<body> 16<h1><img src="../../../../boost.png" align="middle" />Sparse Matricies</h1> 17<div class="toc" id="toc"></div> 18<h2><a name="mapped_matrix"></a>Mapped Matrix</h2> 19<h4>Description</h4> 20<p>The templated class <code>mapped_matrix<T, F, A></code> is 21the base container adaptor for sparse matricies using element maps. 22For a <em>(m xn</em>)-dimensional sparse matrix and <em>0 <= i < m</em>, 23<em>0 <= j < n</em> the non-zero elements 24<em>m</em><sub><em>i, j</em></sub> are mapped via <em>(i x n + 25j)</em> for row major orientation or via <em>(i + j x m)</em> for 26column major orientation to consecutive elements of the associative 27container, i.e. for elements <em>k</em> = 28<em>m</em><sub><em>i</em></sub><sub><sub><em>1</em></sub></sub><sub> 29<em>,j</em></sub><sub><sub><em>1</em></sub></sub>and <em>k + 1 = 30m</em><sub><em>i</em></sub><sub><sub><em>2</em></sub></sub><sub><em> 31,j</em></sub><sub><sub><em>2</em></sub></sub>of the container holds 32<em>i</em><sub><em>1</em></sub> <em>< 33i</em><sub><em>2</em></sub> or <em>(i</em><sub><em>1</em></sub> 34<em>= i</em><sub><em>2</em></sub> and 35<em>j</em><sub><em>1</em></sub> <em>< 36j</em><sub><em>2</em></sub><em>)</em> with row major orientation or 37<em>j</em><sub><em>1</em></sub> <em>< 38j</em><sub><em>2</em></sub> or <em>(j</em><sub><em>1</em></sub> 39<em>= j</em><sub><em>2</em></sub> and 40<em>i</em><sub><em>1</em></sub> <em>< 41i</em><sub><em>2</em></sub><em>)</em> with column major 42orientation.</p> 43<h4>Example</h4> 44<pre> 45#include <boost/numeric/ublas/matrix_sparse.hpp> 46#include <boost/numeric/ublas/io.hpp> 47 48int main () { 49 using namespace boost::numeric::ublas; 50 mapped_matrix<double> m (3, 3, 3 * 3); 51 for (unsigned i = 0; i < m.size1 (); ++ i) 52 for (unsigned j = 0; j < m.size2 (); ++ j) 53 m (i, j) = 3 * i + j; 54 std::cout << m << std::endl; 55} 56</pre> 57<h4>Definition</h4> 58<p>Defined in the header matrix_sparse.hpp.</p> 59<h4>Template parameters</h4> 60<table border="1" summary="parameters"> 61<tbody> 62<tr> 63<th>Parameter</th> 64<th>Description</th> 65<th>Default</th> 66</tr> 67<tr> 68<td><code>T</code></td> 69<td>The type of object stored in the mapped matrix.</td> 70<td></td> 71</tr> 72<tr> 73<td><code>F</code></td> 74<td>Functor describing the storage organization. <a href= 75"#mapped_matrix_1">[1]</a></td> 76<td><code>row_major</code></td> 77</tr> 78<tr> 79<td><code>A</code></td> 80<td>The type of the adapted array. <a href= 81"#mapped_matrix_2">[2]</a></td> 82<td><code>map_std<std::size_t, T></code></td> 83</tr> 84</tbody> 85</table> 86<h4>Model of</h4> 87<p><a href="container_concept.html#matrix">Matrix</a> .</p> 88<h4>Type requirements</h4> 89<p>None, except for those imposed by the requirements of <a href= 90"container_concept.html#matrix">Matrix</a> .</p> 91<h4>Public base classes</h4> 92<p><code>matrix_container<mapped_matrix<T, F, A> 93></code></p> 94<h4>Members</h4> 95<table border="1" summary="members"> 96<tbody> 97<tr> 98<th>Member</th> 99<th>Description</th> 100</tr> 101<tr> 102<td><code>mapped_matrix ()</code></td> 103<td>Allocates a <code>mapped_matrix</code> that holds at most zero 104rows of zero elements.</td> 105</tr> 106<tr> 107<td><code>mapped_matrix (size_type size1, size_type2, size_type non_zeros = 0)</code></td> 108<td>Allocates a <code>mapped_matrix</code> that holds at most 109<code>size1</code> rows of <code>size2</code> elements.</td> 110</tr> 111<tr> 112<td><code>mapped_matrix (const mapped_matrix &m)</code></td> 113<td>The copy constructor.</td> 114</tr> 115<tr> 116<td><code>template<class AE><br /> 117mapped_matrix (size_type non_zeros, const 118matrix_expression<AE> &ae)</code></td> 119<td>The extended copy constructor.</td> 120</tr> 121<tr> 122<td><code>void resize (size_type size1, size_type size2, bool preserve = true)</code></td> 123<td>Reallocates a <code>mapped_matrix</code> to hold at most 124<code>size1</code> rows of <code>size2</code> elements. The 125existing elements of the <code>mapped_matrix</code> are preseved 126when specified.</td> 127</tr> 128<tr> 129<td><code>size_type size1 () const</code></td> 130<td>Returns the number of rows.</td> 131</tr> 132<tr> 133<td><code>size_type size2 () const</code></td> 134<td>Returns the number of columns.</td> 135</tr> 136<tr> 137<td><code>const_reference operator () (size_type i, size_type j) 138const</code></td> 139<td>Returns the value of the <code>j</code>-th element in the 140<code>i</code>-th row.</td> 141</tr> 142<tr> 143<td><code>reference operator () (size_type i, size_type 144j)</code></td> 145<td>Returns a reference of the <code>j</code>-th element in the 146<code>i</code>-th row.</td> 147</tr> 148<tr> 149<td><code>mapped_matrix &operator = (const mapped_matrix 150&m)</code></td> 151<td>The assignment operator.</td> 152</tr> 153<tr> 154<td><code>mapped_matrix &assign_temporary (mapped_matrix 155&m)</code></td> 156<td>Assigns a temporary. May change the mapped matrix 157<code>m</code> .</td> 158</tr> 159<tr> 160<td><code>template<class AE><br /> 161mapped_matrix &operator = (const matrix_expression<AE> 162&ae)</code></td> 163<td>The extended assignment operator.</td> 164</tr> 165<tr> 166<td><code>template<class AE><br /> 167mapped_matrix &assign (const matrix_expression<AE> 168&ae)</code></td> 169<td>Assigns a matrix expression to the mapped matrix. Left and 170right hand side of the assignment should be independent.</td> 171</tr> 172<tr> 173<td><code>template<class AE><br /> 174mapped_matrix &operator += (const matrix_expression<AE> 175&ae)</code></td> 176<td>A computed assignment operator. Adds the matrix expression to 177the mapped matrix.</td> 178</tr> 179<tr> 180<td><code>template<class AE><br /> 181mapped_matrix &plus_assign (const matrix_expression<AE> 182&ae)</code></td> 183<td>Adds a matrix expression to the mapped matrix. Left and right 184hand side of the assignment should be independent.</td> 185</tr> 186<tr> 187<td><code>template<class AE><br /> 188mapped_matrix &operator -= (const matrix_expression<AE> 189&ae)</code></td> 190<td>A computed assignment operator. Subtracts the matrix expression 191from the mapped matrix.</td> 192</tr> 193<tr> 194<td><code>template<class AE><br /> 195mapped_matrix &minus_assign (const matrix_expression<AE> 196&ae)</code></td> 197<td>Subtracts a matrix expression from the mapped matrix. Left and 198right hand side of the assignment should be independent.</td> 199</tr> 200<tr> 201<td><code>template<class AT><br /> 202mapped_matrix &operator *= (const AT &at)</code></td> 203<td>A computed assignment operator. Multiplies the mapped matrix 204with a scalar.</td> 205</tr> 206<tr> 207<td><code>template<class AT><br /> 208mapped_matrix &operator /= (const AT &at)</code></td> 209<td>A computed assignment operator. Divides the mapped matrix 210through a scalar.</td> 211</tr> 212<tr> 213<td><code>void swap (mapped_matrix &m)</code></td> 214<td>Swaps the contents of the mapped matrices.</td> 215</tr> 216<tr> 217<td><code>true_refrence insert_element (size_type i, size_type j, const_reference 218t)</code></td> 219<td>Inserts the value <code>t</code> at the <code>j</code>-th 220element of the <code>i</code>-th row. Duplicates elements are not allowed.</td> 221</tr> 222<tr> 223<td><code>void erase_element (size_type i, size_type j)</code></td> 224<td>Erases the value at the <code>j</code>-th element of the 225<code>i</code>-th row.</td> 226</tr> 227<tr> 228<td><code>void clear ()</code></td> 229<td>Clears the mapped matrix.</td> 230</tr> 231<tr> 232<td><code>const_iterator1 begin1 () const</code></td> 233<td>Returns a <code>const_iterator1</code> pointing to the 234beginning of the <code>mapped_matrix</code>.</td> 235</tr> 236<tr> 237<td><code>const_iterator1 end1 () const</code></td> 238<td>Returns a <code>const_iterator1</code> pointing to the end of 239the <code>mapped_matrix</code>.</td> 240</tr> 241<tr> 242<td><code>iterator1 begin1 ()</code></td> 243<td>Returns a <code>iterator1</code> pointing to the beginning of 244the <code>mapped_matrix</code>.</td> 245</tr> 246<tr> 247<td><code>iterator1 end1 ()</code></td> 248<td>Returns a <code>iterator1</code> pointing to the end of the 249<code>mapped_matrix</code>.</td> 250</tr> 251<tr> 252<td><code>const_iterator2 begin2 () const</code></td> 253<td>Returns a <code>const_iterator2</code> pointing to the 254beginning of the <code>mapped_matrix</code>.</td> 255</tr> 256<tr> 257<td><code>const_iterator2 end2 () const</code></td> 258<td>Returns a <code>const_iterator2</code> pointing to the end of 259the <code>mapped_matrix</code>.</td> 260</tr> 261<tr> 262<td><code>iterator2 begin2 ()</code></td> 263<td>Returns a <code>iterator2</code> pointing to the beginning of 264the <code>mapped_matrix</code>.</td> 265</tr> 266<tr> 267<td><code>iterator2 end2 ()</code></td> 268<td>Returns a <code>iterator2</code> pointing to the end of the 269<code>mapped_matrix</code>.</td> 270</tr> 271<tr> 272<td><code>const_reverse_iterator1 rbegin1 () const</code></td> 273<td>Returns a <code>const_reverse_iterator1</code> pointing to the 274beginning of the reversed <code>mapped_matrix</code>.</td> 275</tr> 276<tr> 277<td><code>const_reverse_iterator1 rend1 () const</code></td> 278<td>Returns a <code>const_reverse_iterator1</code> pointing to the 279end of the reversed <code>mapped_matrix</code>.</td> 280</tr> 281<tr> 282<td><code>reverse_iterator1 rbegin1 ()</code></td> 283<td>Returns a <code>reverse_iterator1</code> pointing to the 284beginning of the reversed <code>mapped_matrix</code>.</td> 285</tr> 286<tr> 287<td><code>reverse_iterator1 rend1 ()</code></td> 288<td>Returns a <code>reverse_iterator1</code> pointing to the end of 289the reversed <code>mapped_matrix</code>.</td> 290</tr> 291<tr> 292<td><code>const_reverse_iterator2 rbegin2 () const</code></td> 293<td>Returns a <code>const_reverse_iterator2</code> pointing to the 294beginning of the reversed <code>mapped_matrix</code>.</td> 295</tr> 296<tr> 297<td><code>const_reverse_iterator2 rend2 () const</code></td> 298<td>Returns a <code>const_reverse_iterator2</code> pointing to the 299end of the reversed <code>mapped_matrix</code>.</td> 300</tr> 301<tr> 302<td><code>reverse_iterator2 rbegin2 ()</code></td> 303<td>Returns a <code>reverse_iterator2</code> pointing to the 304beginning of the reversed <code>mapped_matrix</code>.</td> 305</tr> 306<tr> 307<td><code>reverse_iterator2 rend2 ()</code></td> 308<td>Returns a <code>reverse_iterator2</code> pointing to the end of 309the reversed <code>mapped_matrix</code>.</td> 310</tr> 311</tbody> 312</table> 313<h4>Notes</h4> 314<p><a name="mapped_matrix_1">[1]</a> Supported 315parameters for the storage organization are <code>row_major</code> 316and <code>column_major</code>.</p> 317<p><a name="mapped_matrix_2">[2]</a> Supported 318parameters for the adapted array are 319<code>map_array<std::size_t, T></code> and 320<code>map_std<std::size_t, T></code>. The latter is 321equivalent to <code>std::map<std::size_t, T></code>.</p> 322<h2><a name="compressed_matrix"></a>Compressed Matrix</h2> 323<h4>Description</h4> 324<p>The templated class <code>compressed_matrix<T, F, IB, IA, 325TA></code> is the base container adaptor for compressed 326matrices. For a <em>(m x n</em> )-dimensional compressed matrix and 327<em>0 <= i < m</em>, <em>0 <= j < n</em> the non-zero 328elements <em>m</em><sub><em>i, j</em></sub> are mapped via <em>(i x 329n + j)</em> for row major orientation or via <em>(i + j x m)</em> 330for column major orientation to consecutive elements of the index 331and value containers, i.e. for elements <em>k</em> = 332<em>m</em><sub><em>i</em></sub><sub><sub><em>1</em></sub></sub><sub> 333<em>,j</em></sub><sub><sub><em>1</em></sub></sub>and <em>k + 1 = 334m</em><sub><em>i</em></sub><sub><sub><em>2</em></sub></sub><sub><em> 335,j</em></sub><sub><sub><em>2</em></sub></sub>of the container holds 336<em>i</em><sub><em>1</em></sub> <em>< 337i</em><sub><em>2</em></sub> or <em>(i</em><sub><em>1</em></sub> 338<em>= i</em><sub><em>2</em></sub> and 339<em>j</em><sub><em>1</em></sub> <em>< 340j</em><sub><em>2</em></sub><em>)</em> with row major orientation or 341<em>j</em><sub><em>1</em></sub> <em>< 342j</em><sub><em>2</em></sub> or <em>(j</em><sub><em>1</em></sub> 343<em>= j</em><sub><em>2</em></sub> and 344<em>i</em><sub><em>1</em></sub> <em>< 345i</em><sub><em>2</em></sub><em>)</em> with column major 346orientation.</p> 347<h4>Example</h4> 348<pre> 349#include <boost/numeric/ublas/matrix_sparse.hpp> 350#include <boost/numeric/ublas/io.hpp> 351 352int main () { 353 using namespace boost::numeric::ublas; 354 compressed_matrix<double> m (3, 3, 3 * 3); 355 for (unsigned i = 0; i < m.size1 (); ++ i) 356 for (unsigned j = 0; j < m.size2 (); ++ j) 357 m (i, j) = 3 * i + j; 358 std::cout << m << std::endl; 359} 360</pre> 361<h4>Definition</h4> 362<p>Defined in the header matrix_sparse.hpp.</p> 363<h4>Template parameters</h4> 364<table border="1" summary="parameters"> 365<tbody> 366<tr> 367<th>Parameter</th> 368<th>Description</th> 369<th>Default</th> 370</tr> 371<tr> 372<td><code>T</code></td> 373<td>The type of object stored in the compressed matrix.</td> 374<td></td> 375</tr> 376<tr> 377<td><code>F</code></td> 378<td>Functor describing the storage organization. <a href= 379"#compressed_matrix_1">[1]</a></td> 380<td><code>row_major</code></td> 381</tr> 382<tr> 383<td><code>IB</code></td> 384<td>The index base of the compressed vector. <a href= 385"#compressed_matrix_2">[2]</a></td> 386<td><code>0</code></td> 387</tr> 388<tr> 389<td><code>IA</code></td> 390<td>The type of the adapted array for indices. <a href= 391"#compressed_matrix_3">[3]</a></td> 392<td><code>unbounded_array<std::size_t></code></td> 393</tr> 394<tr> 395<td><code>TA</code></td> 396<td>The type of the adapted array for values. <a href= 397"#compressed_matrix_3">[3]</a></td> 398<td><code>unbounded_array<T></code></td> 399</tr> 400</tbody> 401</table> 402<h4>Model of</h4> 403<p><a href="container_concept.html#matrix">Matrix</a> .</p> 404<h4>Type requirements</h4> 405<p>None, except for those imposed by the requirements of <a href= 406"container_concept.html#matrix">Matrix</a> .</p> 407<h4>Public base classes</h4> 408<p><code>matrix_container<compressed_matrix<T, F, IB, IA, 409TA> ></code></p> 410<h4>Members</h4> 411<table border="1" summary="members"> 412<tbody> 413<tr> 414<th>Member</th> 415<th>Description</th> 416</tr> 417<tr> 418<td><code>compressed_matrix ()</code></td> 419<td>Allocates a <code>compressed_matrix</code> that holds at most 420zero rows of zero elements.</td> 421</tr> 422<tr> 423<td><code>compressed_matrix (size_type size1, size_type2, size_type non_zeros = 0)</code></td> 424<td>Allocates a <code>compressed_matrix</code> that holds at most 425<code>size1</code> rows of <code>size2</code> elements.</td> 426</tr> 427<tr> 428<td><code>compressed_matrix (const compressed_matrix 429&m)</code></td> 430<td>The copy constructor.</td> 431</tr> 432<tr> 433<td><code>template<class AE><br /> 434compressed_matrix (size_type non_zeros, const 435matrix_expression<AE> &ae)</code></td> 436<td>The extended copy constructor.</td> 437</tr> 438<tr> 439<td><code>void resize (size_type size1, size_type size2, bool preserve = true)</code></td> 440<td>Reallocates a <code>compressed_matrix</code> to hold at most 441<code>size1</code> rows of <code>size2</code> elements. The 442existing elements of the <code>compressed_matrix</code> are 443preseved when specified.</td> 444</tr> 445<tr> 446<td><code>size_type size1 () const</code></td> 447<td>Returns the number of rows.</td> 448</tr> 449<tr> 450<td><code>size_type size2 () const</code></td> 451<td>Returns the number of columns.</td> 452</tr> 453<tr> 454<td><code>const_reference operator () (size_type i, size_type j) 455const</code></td> 456<td>Returns the value of the <code>j</code>-th element in the 457<code>i</code>-th row.</td> 458</tr> 459<tr> 460<td><code>reference operator () (size_type i, size_type 461j)</code></td> 462<td>Returns a reference of the <code>j</code>-th element in the 463<code>i</code>-th row.</td> 464</tr> 465<tr> 466<td><code>compressed_matrix &operator = (const 467compressed_matrix &m)</code></td> 468<td>The assignment operator.</td> 469</tr> 470<tr> 471<td><code>compressed_matrix &assign_temporary 472(compressed_matrix &m)</code></td> 473<td>Assigns a temporary. May change the compressed matrix 474<code>m</code>.</td> 475</tr> 476<tr> 477<td><code>template<class AE><br /> 478compressed_matrix &operator = (const 479matrix_expression<AE> &ae)</code></td> 480<td>The extended assignment operator.</td> 481</tr> 482<tr> 483<td><code>template<class AE><br /> 484compressed_matrix &assign (const matrix_expression<AE> 485&ae)</code></td> 486<td>Assigns a matrix expression to the compressed matrix. Left and 487right hand side of the assignment should be independent.</td> 488</tr> 489<tr> 490<td><code>template<class AE><br /> 491compressed_matrix &operator += (const 492matrix_expression<AE> &ae)</code></td> 493<td>A computed assignment operator. Adds the matrix expression to 494the compressed matrix.</td> 495</tr> 496<tr> 497<td><code>template<class AE><br /> 498compressed_matrix &plus_assign (const 499matrix_expression<AE> &ae)</code></td> 500<td>Adds a matrix expression to the compressed matrix. Left and 501right hand side of the assignment should be independent.</td> 502</tr> 503<tr> 504<td><code>template<class AE><br /> 505compressed_matrix &operator -= (const 506matrix_expression<AE> &ae)</code></td> 507<td>A computed assignment operator. Subtracts the matrix expression 508from the compressed matrix.</td> 509</tr> 510<tr> 511<td><code>template<class AE><br /> 512compressed_matrix &minus_assign (const 513matrix_expression<AE> &ae)</code></td> 514<td>Subtracts a matrix expression from the compressed matrix. Left 515and right hand side of the assignment should be independent.</td> 516</tr> 517<tr> 518<td><code>template<class AT><br /> 519compressed_matrix &operator *= (const AT &at)</code></td> 520<td>A computed assignment operator. Multiplies the compressed 521matrix with a scalar.</td> 522</tr> 523<tr> 524<td><code>template<class AT><br /> 525compressed_matrix &operator /= (const AT &at)</code></td> 526<td>A computed assignment operator. Divides the compressed matrix 527through a scalar.</td> 528</tr> 529<tr> 530<td><code>void swap (compressed_matrix &m)</code></td> 531<td>Swaps the contents of the compressed matrices.</td> 532</tr> 533<tr> 534<td><code>true_reference insert_element (size_type i, size_type j, const_reference 535t)</code></td> 536<td>Inserts the value <code>t</code> at the <code>j</code>-th 537element of the <code>i</code>-th row. Duplicates elements are not allowed.</td> 538</tr> 539<tr> 540<td><code>void erase_element (size_type i, size_type j)</code></td> 541<td>Erases the value at the <code>j</code>-th element of the 542<code>i</code>-th row.</td> 543</tr> 544<tr> 545<td><code>void clear ()</code></td> 546<td>Clears the compressed matrix.</td> 547</tr> 548<tr> 549<td><code>const_iterator1 begin1 () const</code></td> 550<td>Returns a <code>const_iterator1</code> pointing to the 551beginning of the <code>compressed_matrix</code>.</td> 552</tr> 553<tr> 554<td><code>const_iterator1 end1 () const</code></td> 555<td>Returns a <code>const_iterator1</code> pointing to the end of 556the <code>compressed_matrix</code>.</td> 557</tr> 558<tr> 559<td><code>iterator1 begin1 ()</code></td> 560<td>Returns a <code>iterator1</code> pointing to the beginning of 561the <code>compressed_matrix</code>.</td> 562</tr> 563<tr> 564<td><code>iterator1 end1 ()</code></td> 565<td>Returns a <code>iterator1</code> pointing to the end of the 566<code>compressed_matrix</code>.</td> 567</tr> 568<tr> 569<td><code>const_iterator2 begin2 () const</code></td> 570<td>Returns a <code>const_iterator2</code> pointing to the 571beginning of the <code>compressed_matrix</code>.</td> 572</tr> 573<tr> 574<td><code>const_iterator2 end2 () const</code></td> 575<td>Returns a <code>const_iterator2</code> pointing to the end of 576the <code>compressed_matrix</code>.</td> 577</tr> 578<tr> 579<td><code>iterator2 begin2 ()</code></td> 580<td>Returns a <code>iterator2</code> pointing to the beginning of 581the <code>compressed_matrix</code>.</td> 582</tr> 583<tr> 584<td><code>iterator2 end2 ()</code></td> 585<td>Returns a <code>iterator2</code> pointing to the end of the 586<code>compressed_matrix</code>.</td> 587</tr> 588<tr> 589<td><code>const_reverse_iterator1 rbegin1 () const</code></td> 590<td>Returns a <code>const_reverse_iterator1</code> pointing to the 591beginning of the reversed <code>compressed_matrix</code>.</td> 592</tr> 593<tr> 594<td><code>const_reverse_iterator1 rend1 () const</code></td> 595<td>Returns a <code>const_reverse_iterator1</code> pointing to the 596end of the reversed <code>compressed_matrix</code>.</td> 597</tr> 598<tr> 599<td><code>reverse_iterator1 rbegin1 ()</code></td> 600<td>Returns a <code>reverse_iterator1</code> pointing to the 601beginning of the reversed <code>compressed_matrix</code>.</td> 602</tr> 603<tr> 604<td><code>reverse_iterator1 rend1 ()</code></td> 605<td>Returns a <code>reverse_iterator1</code> pointing to the end of 606the reversed <code>compressed_matrix</code>.</td> 607</tr> 608<tr> 609<td><code>const_reverse_iterator2 rbegin2 () const</code></td> 610<td>Returns a <code>const_reverse_iterator2</code> pointing to the 611beginning of the reversed <code>compressed_matrix</code>.</td> 612</tr> 613<tr> 614<td><code>const_reverse_iterator2 rend2 () const</code></td> 615<td>Returns a <code>const_reverse_iterator2</code> pointing to the 616end of the reversed <code>compressed_matrix</code>.</td> 617</tr> 618<tr> 619<td><code>reverse_iterator2 rbegin2 ()</code></td> 620<td>Returns a <code>reverse_iterator2</code> pointing to the 621beginning of the reversed <code>compressed_matrix</code>.</td> 622</tr> 623<tr> 624<td><code>reverse_iterator2 rend2 ()</code></td> 625<td>Returns a <code>reverse_iterator2</code> pointing to the end of 626the reversed <code>compressed_matrix</code>.</td> 627</tr> 628</tbody> 629</table> 630<h4>Notes</h4> 631<p><a name="compressed_matrix_1">[1]</a> 632Supported parameters for the storage organization are 633<code>row_major</code> and <code>column_major</code>.</p> 634<p><a name="compressed_matrix_2">[2]</a> 635Supported parameters for the index base are <code>0</code> and 636<code>1</code> at least.</p> 637<p><a name="compressed_matrix_3">[3]</a> 638Supported parameters for the adapted array are 639<code>unbounded_array<></code> , 640<code>bounded_array<></code> and 641<code>std::vector<></code> .</p> 642<h2><a name="coordinate_matrix"></a>Coordinate Matrix</h2> 643<h4>Description</h4> 644<p>The templated class <code>coordinate_matrix<T, F, IB, IA, 645TA></code> is the base container adaptor for compressed 646matrices. For a <em>(m x n</em> )-dimensional sorted coordinate 647matrix and <em>0 <= i < m</em>, <em>0 <= j < n</em> the 648non-zero elements <em>m</em><sub><em>i, j</em></sub> are mapped via 649<em>(i x n + j)</em> for row major orientation or via <em>(i + j x 650m)</em> for column major orientation to consecutive elements of the 651index and value containers, i.e. for elements <em>k</em> = 652<em>m</em><sub><em>i</em></sub><sub><sub><em>1</em></sub></sub><sub> 653<em>,j</em></sub><sub><sub><em>1</em></sub></sub>and <em>k + 1 = 654m</em><sub><em>i</em></sub><sub><sub><em>2</em></sub></sub><sub><em> 655,j</em></sub><sub><sub><em>2</em></sub></sub>of the container holds 656<em>i</em><sub><em>1</em></sub> <em>< 657i</em><sub><em>2</em></sub> or <em>(i</em><sub><em>1</em></sub> 658<em>= i</em><sub><em>2</em></sub> and 659<em>j</em><sub><em>1</em></sub> <em>< 660j</em><sub><em>2</em></sub><em>)</em> with row major orientation or 661<em>j</em><sub><em>1</em></sub> <em>< 662j</em><sub><em>2</em></sub> or <em>(j</em><sub><em>1</em></sub> 663<em>= j</em><sub><em>2</em></sub> and 664<em>i</em><sub><em>1</em></sub> <em>< 665i</em><sub><em>2</em></sub><em>)</em> with column major 666orientation.</p> 667<h4>Example</h4> 668<pre> 669#include <boost/numeric/ublas/matrix_sparse.hpp> 670#include <boost/numeric/ublas/io.hpp> 671 672int main () { 673 using namespace boost::numeric::ublas; 674 coordinate_matrix<double> m (3, 3, 3 * 3); 675 for (unsigned i = 0; i < m.size1 (); ++ i) 676 for (unsigned j = 0; j < m.size2 (); ++ j) 677 m (i, j) = 3 * i + j; 678 std::cout << m << std::endl; 679} 680</pre> 681<h4>Definition</h4> 682<p>Defined in the header matrix_sparse.hpp.</p> 683<h4>Template parameters</h4> 684<table border="1" summary="parameters"> 685<tbody> 686<tr> 687<th>Parameter</th> 688<th>Description</th> 689<th>Default</th> 690</tr> 691<tr> 692<td><code>T</code></td> 693<td>The type of object stored in the coordinate matrix.</td> 694<td></td> 695</tr> 696<tr> 697<td><code>F</code></td> 698<td>Functor describing the storage organization. <a href= 699"#coordinate_matrix_1">[1]</a></td> 700<td><code>row_major</code></td> 701</tr> 702<tr> 703<td><code>IB</code></td> 704<td>The index base of the coordinate vector. <a href= 705"#coordinate_matrix_2">[2]</a></td> 706<td><code>0</code></td> 707</tr> 708<tr> 709<td><code>IA</code></td> 710<td>The type of the adapted array for indices. <a href= 711"#coordinate_matrix_3">[3]</a></td> 712<td><code>unbounded_array<std::size_t></code></td> 713</tr> 714<tr> 715<td><code>TA</code></td> 716<td>The type of the adapted array for values. <a href= 717"#coordinate_matrix_3">[3]</a></td> 718<td><code>unbounded_array<T></code></td> 719</tr> 720</tbody> 721</table> 722<h4>Model of</h4> 723<p><a href="container_concept.html#matrix">Matrix</a> .</p> 724<h4>Type requirements</h4> 725<p>None, except for those imposed by the requirements of <a href= 726"container_concept.html#matrix">Matrix</a> .</p> 727<h4>Public base classes</h4> 728<p><code>matrix_container<coordinate_matrix<T, F, IB, IA, 729TA> ></code></p> 730<h4>Members</h4> 731<table border="1" summary="members"> 732<tbody> 733<tr> 734<th>Member</th> 735<th>Description</th> 736</tr> 737<tr> 738<td><code>coordinate_matrix ()</code></td> 739<td>Allocates a <code>coordinate_matrix</code> that holds at most 740zero rows of zero elements.</td> 741</tr> 742<tr> 743<td><code>coordinate_matrix (size_type size1, size_type2, size_type non_zeros = 0)</code></td> 744<td>Allocates a <code>coordinate_matrix</code> that holds at most 745<code>size1</code> rows of <code>size2</code> elements.</td> 746</tr> 747<tr> 748<td><code>coordinate_matrix (const coordinate_matrix 749&m)</code></td> 750<td>The copy constructor.</td> 751</tr> 752<tr> 753<td><code>template<class AE><br /> 754coordinate_matrix (size_type non_zeros, const 755matrix_expression<AE> &ae)</code></td> 756<td>The extended copy constructor.</td> 757</tr> 758<tr> 759<td><code>void resize (size_type size1, size_type size2, bool preserve = true)</code></td> 760<td>Reallocates a <code>coordinate_matrix</code> to hold at most 761<code>size1</code> rows of <code>size2</code> elements. The 762existing elements of the <code>coordinate_matrix</code> are 763preseved when specified.</td> 764</tr> 765<tr> 766<td><code>size_type size1 () const</code></td> 767<td>Returns the number of rows.</td> 768</tr> 769<tr> 770<td><code>size_type size2 () const</code></td> 771<td>Returns the number of columns.</td> 772</tr> 773<tr> 774<td><code>const_reference operator () (size_type i, size_type j) 775const</code></td> 776<td>Returns the value of the <code>j</code>-th element in the 777<code>i</code>-th row.</td> 778</tr> 779<tr> 780<td><code>reference operator () (size_type i, size_type 781j)</code></td> 782<td>Returns a reference of the <code>j</code>-th element in the 783<code>i</code>-th row.</td> 784</tr> 785<tr> 786<td><code>coordinate_matrix &operator = (const 787coordinate_matrix &m)</code></td> 788<td>The assignment operator.</td> 789</tr> 790<tr> 791<td><code>coordinate_matrix &assign_temporary 792(coordinate_matrix &m)</code></td> 793<td>Assigns a temporary. May change the coordinate matrix 794<code>m</code>.</td> 795</tr> 796<tr> 797<td><code>template<class AE><br /> 798coordinate_matrix &operator = (const 799matrix_expression<AE> &ae)</code></td> 800<td>The extended assignment operator.</td> 801</tr> 802<tr> 803<td><code>template<class AE><br /> 804coordinate_matrix &assign (const matrix_expression<AE> 805&ae)</code></td> 806<td>Assigns a matrix expression to the coordinate matrix. Left and 807right hand side of the assignment should be independent.</td> 808</tr> 809<tr> 810<td><code>template<class AE><br /> 811coordinate_matrix &operator += (const 812matrix_expression<AE> &ae)</code></td> 813<td>A computed assignment operator. Adds the matrix expression to 814the coordinate matrix.</td> 815</tr> 816<tr> 817<td><code>template<class AE><br /> 818coordinate_matrix &plus_assign (const 819matrix_expression<AE> &ae)</code></td> 820<td>Adds a matrix expression to the coordinate matrix. Left and 821right hand side of the assignment should be independent.</td> 822</tr> 823<tr> 824<td><code>template<class AE><br /> 825coordinate_matrix &operator -= (const 826matrix_expression<AE> &ae)</code></td> 827<td>A computed assignment operator. Subtracts the matrix expression 828from the coordinate matrix.</td> 829</tr> 830<tr> 831<td><code>template<class AE><br /> 832coordinate_matrix &minus_assign (const 833matrix_expression<AE> &ae)</code></td> 834<td>Subtracts a matrix expression from the coordinate matrix. Left 835and right hand side of the assignment should be independent.</td> 836</tr> 837<tr> 838<td><code>template<class AT><br /> 839coordinate_matrix &operator *= (const AT &at)</code></td> 840<td>A computed assignment operator. Multiplies the coordinate 841matrix with a scalar.</td> 842</tr> 843<tr> 844<td><code>template<class AT><br /> 845coordinate_matrix &operator /= (const AT &at)</code></td> 846<td>A computed assignment operator. Divides the coordinate matrix 847through a scalar.</td> 848</tr> 849<tr> 850<td><code>void swap (coordinate_matrix &m)</code></td> 851<td>Swaps the contents of the coordinate matrices.</td> 852</tr> 853<tr> 854<td><code>true_reference insert_element (size_type i, size_type j, const_reference 855t)</code></td> 856<td>Inserts the value <code>t</code> at the <code>j</code>-th 857element of the <code>i</code>-th row. Duplicates elements are not allowed.</td> 858</tr> 859<tr> 860<td><code>void append_element (size_type i, size_type j, const_reference t)</code></td> 861<td>Appends the value <code>t</code> at the <code>j</code>-th element of the <code>i</code>-th row. 862Duplicate elements can be appended to a <code>coordinate_matrix</code>. They are merged into a single 863arithmetically summed element by the <code>sort</code> function.</td> 864</tr> 865<tr> 866<td><code>void erase_element (size_type i, size_type j)</code></td> 867<td>Erases the value at the <code>j</code>-th element of the 868<code>i</code>-th row.</td> 869</tr> 870<tr> 871<td><code>void clear ()</code></td> 872<td>Clears the coordinate matrix.</td> 873</tr> 874<tr> 875<td><code>const_iterator1 begin1 () const</code></td> 876<td>Returns a <code>const_iterator1</code> pointing to the 877beginning of the <code>coordinate_matrix</code>.</td> 878</tr> 879<tr> 880<td><code>const_iterator1 end1 () const</code></td> 881<td>Returns a <code>const_iterator1</code> pointing to the end of 882the <code>coordinate_matrix</code>.</td> 883</tr> 884<tr> 885<td><code>iterator1 begin1 ()</code></td> 886<td>Returns a <code>iterator1</code> pointing to the beginning of 887the <code>coordinate_matrix</code>.</td> 888</tr> 889<tr> 890<td><code>iterator1 end1 ()</code></td> 891<td>Returns a <code>iterator1</code> pointing to the end of the 892<code>coordinate_matrix</code>.</td> 893</tr> 894<tr> 895<td><code>const_iterator2 begin2 () const</code></td> 896<td>Returns a <code>const_iterator2</code> pointing to the 897beginning of the <code>coordinate_matrix</code>.</td> 898</tr> 899<tr> 900<td><code>const_iterator2 end2 () const</code></td> 901<td>Returns a <code>const_iterator2</code> pointing to the end of 902the <code>coordinate_matrix</code>.</td> 903</tr> 904<tr> 905<td><code>iterator2 begin2 ()</code></td> 906<td>Returns a <code>iterator2</code> pointing to the beginning of 907the <code>coordinate_matrix</code>.</td> 908</tr> 909<tr> 910<td><code>iterator2 end2 ()</code></td> 911<td>Returns a <code>iterator2</code> pointing to the end of the 912<code>coordinate_matrix</code>.</td> 913</tr> 914<tr> 915<td><code>const_reverse_iterator1 rbegin1 () const</code></td> 916<td>Returns a <code>const_reverse_iterator1</code> pointing to the 917beginning of the reversed <code>coordinate_matrix</code>.</td> 918</tr> 919<tr> 920<td><code>const_reverse_iterator1 rend1 () const</code></td> 921<td>Returns a <code>const_reverse_iterator1</code> pointing to the 922end of the reversed <code>coordinate_matrix</code>.</td> 923</tr> 924<tr> 925<td><code>reverse_iterator1 rbegin1 ()</code></td> 926<td>Returns a <code>reverse_iterator1</code> pointing to the 927beginning of the reversed <code>coordinate_matrix</code>.</td> 928</tr> 929<tr> 930<td><code>reverse_iterator1 rend1 ()</code></td> 931<td>Returns a <code>reverse_iterator1</code> pointing to the end of 932the reversed <code>coordinate_matrix</code>.</td> 933</tr> 934<tr> 935<td><code>const_reverse_iterator2 rbegin2 () const</code></td> 936<td>Returns a <code>const_reverse_iterator2</code> pointing to the 937beginning of the reversed <code>coordinate_matrix</code>.</td> 938</tr> 939<tr> 940<td><code>const_reverse_iterator2 rend2 () const</code></td> 941<td>Returns a <code>const_reverse_iterator2</code> pointing to the 942end of the reversed <code>coordinate_matrix</code>.</td> 943</tr> 944<tr> 945<td><code>reverse_iterator2 rbegin2 ()</code></td> 946<td>Returns a <code>reverse_iterator2</code> pointing to the 947beginning of the reversed <code>coordinate_matrix</code>.</td> 948</tr> 949<tr> 950<td><code>reverse_iterator2 rend2 ()</code></td> 951<td>Returns a <code>reverse_iterator2</code> pointing to the end of 952the reversed <code>coordinate_matrix</code>.</td> 953</tr> 954</tbody> 955</table> 956<h4>Notes</h4> 957<p><a name="coordinate_matrix_1">[1]</a> 958Supported parameters for the storage organization are 959<code>row_major</code> and <code>column_major</code>.</p> 960<p><a name="coordinate_matrix_2">[2]</a> 961Supported parameters for the index base are <code>0</code> and 962<code>1</code> at least.</p> 963<p><a name="coordinate_matrix_3">[3]</a> 964Supported parameters for the adapted array are 965<code>unbounded_array<></code> , 966<code>bounded_array<></code> and 967<code>std::vector<></code> .</p> 968<hr /> 969<p>Copyright (©) 2000-2002 Joerg Walter, Mathias Koch<br /> 970 Use, modification and distribution are subject to the 971 Boost Software License, Version 1.0. 972 (See accompanying file LICENSE_1_0.txt 973 or copy at <a href="http://www.boost.org/LICENSE_1_0.txt"> 974 http://www.boost.org/LICENSE_1_0.txt 975 </a>). 976</p> 977<script type="text/javascript"> 978(function($) { 979 $('#toc').toc(); 980})(jQuery); 981</script> 982</body> 983</html> 984