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>Symmetric Matrix</title> 14</head> 15<body> 16<h1><img src="../../../../boost.png" align="middle" />Symmetric Matrix</h1> 17<div class="toc" id="toc"></div> 18<h2><a name="symmetric_matrix"></a>Symmetric Matrix</h2> 19<h4>Description</h4> 20<p>The templated class <code>symmetric_matrix<T, F1, F2, 21A></code> is the base container adaptor for symmetric matrices. 22For a <em>(n x n</em> )-dimensional symmetric matrix and <em>0 23<= i < n</em>, <em>0 <= j < n</em> holds 24<em>s</em><sub><em>i, j</em></sub> <em>= s</em><sub><em>j, 25i</em></sub>. The storage of symmetric matrices is packed.</p> 26<h4>Example</h4> 27<pre> 28#include <boost/numeric/ublas/symmetric.hpp> 29#include <boost/numeric/ublas/io.hpp> 30 31int main () { 32 using namespace boost::numeric::ublas; 33 symmetric_matrix<double, lower> ml (3, 3); 34 for (unsigned i = 0; i < ml.size1 (); ++ i) 35 for (unsigned j = 0; j <= i; ++ j) 36 ml (i, j) = 3 * i + j; 37 std::cout << ml << std::endl; 38 symmetric_matrix<double, upper> mu (3, 3); 39 for (unsigned i = 0; i < mu.size1 (); ++ i) 40 for (unsigned j = i; j < mu.size2 (); ++ j) 41 mu (i, j) = 3 * i + j; 42 std::cout << mu << std::endl; 43} 44</pre> 45<h4>Definition</h4> 46<p>Defined in the header symmetric.hpp.</p> 47<h4>Template parameters</h4> 48<table border="1" summary="parameters"> 49<tbody> 50<tr> 51<th>Parameter</th> 52<th>Description</th> 53<th>Default</th> 54</tr> 55<tr> 56<td><code>T</code></td> 57<td>The type of object stored in the matrix.</td> 58<td></td> 59</tr> 60<tr> 61<td><code>F1</code></td> 62<td>Functor describing the type of the symmetric matrix. <a name= 63"#symmetric_matrix_1">[1]</a></td> 64<td><code>lower</code></td> 65</tr> 66<tr> 67<td><code>F2</code></td> 68<td>Functor describing the storage organization. <a name= 69"#symmetric_matrix_2">[2]</a></td> 70<td><code>row_major</code></td> 71</tr> 72<tr> 73<td><code>A</code></td> 74<td>The type of the adapted array. <a name="#symmetric_matrix_3" 75>[3]</a></td> 76<td><code>unbounded_array<T></code></td> 77</tr> 78</tbody> 79</table> 80<h4>Model of</h4> 81<p><a href="container_concept.html#matrix">Matrix</a> .</p> 82<h4>Type requirements</h4> 83<p>None, except for those imposed by the requirements of <a href= 84"container_concept.html#matrix">Matrix</a> .</p> 85<h4>Public base classes</h4> 86<p><code>matrix_container<symmetric_matrix<T, F1, F2, A> 87></code></p> 88<h4>Members</h4> 89<table border="1" summary="members"> 90<tbody> 91<tr> 92<th>Member</th> 93<th>Description</th> 94</tr> 95<tr> 96<td><code>symmetric_matrix (size_type size)</code></td> 97<td>Allocates an uninitialized <code>symmetric_matrix</code> that 98holds <code>size</code> rows of <code>size</code> elements.</td> 99</tr> 100<tr> 101<td><code>symmetric_matrix (const symmetric_matrix 102&m)</code></td> 103<td>The copy constructor.</td> 104</tr> 105<tr> 106<td><code>template<class AE><br /> 107symmetric_matrix (const matrix_expression<AE> 108&ae)</code></td> 109<td>The extended copy constructor.</td> 110</tr> 111<tr> 112<td><code>void resize (size_type size, bool preserve = 113true)</code></td> 114<td>Reallocates a <code>symmetric_matrix</code> to hold 115<code>size</code> rows of <code>size</code> elements. The existing 116elements of the <code>symmetric_matrix</code> are preseved when 117specified.</td> 118</tr> 119<tr> 120<td><code>size_type size1 () const</code></td> 121<td>Returns the number of rows.</td> 122</tr> 123<tr> 124<td><code>size_type size2 () const</code></td> 125<td>Returns the number of columns.</td> 126</tr> 127<tr> 128<td><code>const_reference operator () (size_type i, size_type j) 129const</code></td> 130<td>Returns a <code>const</code> reference of the <code>j</code> 131-th element in the <code>i</code>-th row.</td> 132</tr> 133<tr> 134<td><code>reference operator () (size_type i, size_type 135j)</code></td> 136<td>Returns a reference of the <code>j</code>-th element in the 137<code>i</code>-th row.</td> 138</tr> 139<tr> 140<td><code>symmetric_matrix &operator = (const symmetric_matrix 141&m)</code></td> 142<td>The assignment operator.</td> 143</tr> 144<tr> 145<td><code>symmetric_matrix &assign_temporary (symmetric_matrix 146&m)</code></td> 147<td>Assigns a temporary. May change the symmetric matrix 148<code>m</code> .</td> 149</tr> 150<tr> 151<td><code>template<class AE><br /> 152symmetric_matrix &operator = (const matrix_expression<AE> 153&ae)</code></td> 154<td>The extended assignment operator.</td> 155</tr> 156<tr> 157<td><code>template<class AE><br /> 158symmetric_matrix &assign (const matrix_expression<AE> 159&ae)</code></td> 160<td>Assigns a matrix expression to the symmetric matrix. Left and 161right hand side of the assignment should be independent.</td> 162</tr> 163<tr> 164<td><code>template<class AE><br /> 165symmetric_matrix &operator += (const 166matrix_expression<AE> &ae)</code></td> 167<td>A computed assignment operator. Adds the matrix expression to 168the symmetric matrix.</td> 169</tr> 170<tr> 171<td><code>template<class AE><br /> 172symmetric_matrix &plus_assign (const 173matrix_expression<AE> &ae)</code></td> 174<td>Adds a matrix expression to the symmetric matrix. Left and 175right hand side of the assignment should be independent.</td> 176</tr> 177<tr> 178<td><code>template<class AE><br /> 179symmetric_matrix &operator -= (const 180matrix_expression<AE> &ae)</code></td> 181<td>A computed assignment operator. Subtracts the matrix expression 182from the symmetric matrix.</td> 183</tr> 184<tr> 185<td><code>template<class AE><br /> 186symmetric_matrix &minus_assign (const 187matrix_expression<AE> &ae)</code></td> 188<td>Subtracts a matrix expression from the symmetric matrix. Left 189and right hand side of the assignment should be independent.</td> 190</tr> 191<tr> 192<td><code>template<class AT><br /> 193symmetric_matrix &operator *= (const AT &at)</code></td> 194<td>A computed assignment operator. Multiplies the symmetric matrix 195with a scalar.</td> 196</tr> 197<tr> 198<td><code>template<class AT><br /> 199symmetric_matrix &operator /= (const AT &at)</code></td> 200<td>A computed assignment operator. Divides the symmetric matrix 201through a scalar.</td> 202</tr> 203<tr> 204<td><code>void swap (symmetric_matrix &m)</code></td> 205<td>Swaps the contents of the symmetric matrices.</td> 206</tr> 207<tr> 208<td><code>void insert (size_type i, size_type j, const_reference 209t)</code></td> 210<td>Inserts the value <code>t</code> at the <code>j</code>-th 211element of the <code>i</code>-th row.</td> 212</tr> 213<tr> 214<td><code>void erase (size_type i, size_type j)</code></td> 215<td>Erases the value at the <code>j</code>-th elemenst of the 216<code>i</code>-th row.</td> 217</tr> 218<tr> 219<td><code>void clear ()</code></td> 220<td>Clears the matrix.</td> 221</tr> 222<tr> 223<td><code>const_iterator1 begin1 () const</code></td> 224<td>Returns a <code>const_iterator1</code> pointing to the 225beginning of the <code>symmetric_matrix</code>.</td> 226</tr> 227<tr> 228<td><code>const_iterator1 end1 () const</code></td> 229<td>Returns a <code>const_iterator1</code> pointing to the end of 230the <code>symmetric_matrix</code>.</td> 231</tr> 232<tr> 233<td><code>iterator1 begin1 ()</code></td> 234<td>Returns a <code>iterator1</code> pointing to the beginning of 235the <code>symmetric_matrix</code>.</td> 236</tr> 237<tr> 238<td><code>iterator1 end1 ()</code></td> 239<td>Returns a <code>iterator1</code> pointing to the end of the 240<code>symmetric_matrix</code>.</td> 241</tr> 242<tr> 243<td><code>const_iterator2 begin2 () const</code></td> 244<td>Returns a <code>const_iterator2</code> pointing to the 245beginning of the <code>symmetric_matrix</code>.</td> 246</tr> 247<tr> 248<td><code>const_iterator2 end2 () const</code></td> 249<td>Returns a <code>const_iterator2</code> pointing to the end of 250the <code>symmetric_matrix</code>.</td> 251</tr> 252<tr> 253<td><code>iterator2 begin2 ()</code></td> 254<td>Returns a <code>iterator2</code> pointing to the beginning of 255the <code>symmetric_matrix</code>.</td> 256</tr> 257<tr> 258<td><code>iterator2 end2 ()</code></td> 259<td>Returns a <code>iterator2</code> pointing to the end of the 260<code>symmetric_matrix</code>.</td> 261</tr> 262<tr> 263<td><code>const_reverse_iterator1 rbegin1 () const</code></td> 264<td>Returns a <code>const_reverse_iterator1</code> pointing to the 265beginning of the reversed <code>symmetric_matrix</code>.</td> 266</tr> 267<tr> 268<td><code>const_reverse_iterator1 rend1 () const</code></td> 269<td>Returns a <code>const_reverse_iterator1</code> pointing to the 270end of the reversed <code>symmetric_matrix</code>.</td> 271</tr> 272<tr> 273<td><code>reverse_iterator1 rbegin1 ()</code></td> 274<td>Returns a <code>reverse_iterator1</code> pointing to the 275beginning of the reversed <code>symmetric_matrix</code>.</td> 276</tr> 277<tr> 278<td><code>reverse_iterator1 rend1 ()</code></td> 279<td>Returns a <code>reverse_iterator1</code> pointing to the end of 280the reversed <code>symmetric_matrix</code>.</td> 281</tr> 282<tr> 283<td><code>const_reverse_iterator2 rbegin2 () const</code></td> 284<td>Returns a <code>const_reverse_iterator2</code> pointing to the 285beginning of the reversed <code>symmetric_matrix</code>.</td> 286</tr> 287<tr> 288<td><code>const_reverse_iterator2 rend2 () const</code></td> 289<td>Returns a <code>const_reverse_iterator2</code> pointing to the 290end of the reversed <code>symmetric_matrix</code>.</td> 291</tr> 292<tr> 293<td><code>reverse_iterator2 rbegin2 ()</code></td> 294<td>Returns a <code>reverse_iterator2</code> pointing to the 295beginning of the reversed <code>symmetric_matrix</code>.</td> 296</tr> 297<tr> 298<td><code>reverse_iterator2 rend2 ()</code></td> 299<td>Returns a <code>reverse_iterator2</code> pointing to the end of 300the reversed <code>symmetric_matrix</code>.</td> 301</tr> 302</tbody> 303</table> 304<h4>Notes</h4> 305<p><a name="symmetric_matrix_1">[1]</a> 306Supported parameters for the type of the symmetric matrix are 307<code>lower</code> and <code>upper</code>.</p> 308<p><a name="symmetric_matrix_2">[2]</a> 309Supported parameters for the storage organization are 310<code>row_major</code> and <code>column_major</code>.</p> 311<p><a name="symmetric_matrix_3">[3]</a> 312Supported parameters for the adapted array are 313<code>unbounded_array<T></code> , 314<code>bounded_array<T></code> and 315<code>std::vector<T></code> .</p> 316<h2><a name="symmetric_adaptor"></a>Symmetric Adaptor</h2> 317<h4>Description</h4> 318<p>The templated class <code>symmetric_adaptor<M, F></code> 319is a symmetric matrix adaptor for other matrices.</p> 320<h4>Example</h4> 321<pre> 322#include <boost/numeric/ublas/symmetric.hpp> 323#include <boost/numeric/ublas/io.hpp> 324 325int main () { 326 using namespace boost::numeric::ublas; 327 matrix<double> m (3, 3); 328 symmetric_adaptor<matrix<double>, lower> sal (m); 329 for (unsigned i = 0; i < sal.size1 (); ++ i) 330 for (unsigned j = 0; j <= i; ++ j) 331 sal (i, j) = 3 * i + j; 332 std::cout << sal << std::endl; 333 symmetric_adaptor<matrix<double>, upper> sau (m); 334 for (unsigned i = 0; i < sau.size1 (); ++ i) 335 for (unsigned j = i; j < sau.size2 (); ++ j) 336 sau (i, j) = 3 * i + j; 337 std::cout << sau << std::endl; 338} 339</pre> 340<h4>Definition</h4> 341<p>Defined in the header symmetric.hpp.</p> 342<h4>Template parameters</h4> 343<table border="1" summary="parameters"> 344<tbody> 345<tr> 346<th>Parameter</th> 347<th>Description</th> 348<th>Default</th> 349</tr> 350<tr> 351<td><code>M</code></td> 352<td>The type of the adapted matrix.</td> 353<td></td> 354</tr> 355<tr> 356<td><code>F</code></td> 357<td>Functor describing the type of the symmetric adaptor. <a href= 358"#symmetric_adaptor_1">[1]</a></td> 359<td><code>lower</code></td> 360</tr> 361</tbody> 362</table> 363<h4>Model of</h4> 364<p><a href="expression_concept.html#matrix_expression">Matrix Expression</a> 365.</p> 366<h4>Type requirements</h4> 367<p>None, except for those imposed by the requirements of <a href= 368"expression_concept.html#matrix_expression">Matrix Expression</a> .</p> 369<h4>Public base classes</h4> 370<p><code>matrix_expression<symmetric_adaptor<M, F> 371></code></p> 372<h4>Members</h4> 373<table border="1" summary="members"> 374<tbody> 375<tr> 376<th>Member</th> 377<th>Description</th> 378</tr> 379<tr> 380<td><code>symmetric_adaptor ()</code></td> 381<td>Constructs a <code>symmetric_adaptor</code> that holds zero 382rows of zero elements.</td> 383</tr> 384<tr> 385<td><code>symmetric_adaptor (matrix_type &data)</code></td> 386<td>Constructs a <code>symmetric_adaptor</code> of a matrix.</td> 387</tr> 388<tr> 389<td><code>symmetric_adaptor (const symmetric_adaptor 390&m)</code></td> 391<td>The copy constructor.</td> 392</tr> 393<tr> 394<td><code>template<class AE><br /> 395symmetric_adaptor (const matrix_expression<AE> 396&ae)</code></td> 397<td>The extended copy constructor.</td> 398</tr> 399<tr> 400<td><code>size_type size1 () const</code></td> 401<td>Returns the number of rows.</td> 402</tr> 403<tr> 404<td><code>size_type size2 () const</code></td> 405<td>Returns the number of columns.</td> 406</tr> 407<tr> 408<td><code>const_reference operator () (size_type i, size_type j) 409const</code></td> 410<td>Returns a <code>const</code> reference of the <code>j</code> 411-th element in the <code>i</code>-th row.</td> 412</tr> 413<tr> 414<td><code>reference operator () (size_type i, size_type 415j)</code></td> 416<td>Returns a reference of the <code>j</code>-th element in the 417<code>i</code>-th row.</td> 418</tr> 419<tr> 420<td><code>symmetric_adaptor &operator = (const 421symmetric_adaptor &m)</code></td> 422<td>The assignment operator.</td> 423</tr> 424<tr> 425<td><code>symmetric_adaptor &assign_temporary 426(symmetric_adaptor &m)</code></td> 427<td>Assigns a temporary. May change the symmetric adaptor 428<code>m</code>.</td> 429</tr> 430<tr> 431<td><code>template<class AE><br /> 432symmetric_adaptor &operator = (const 433matrix_expression<AE> &ae)</code></td> 434<td>The extended assignment operator.</td> 435</tr> 436<tr> 437<td><code>template<class AE><br /> 438symmetric_adaptor &assign (const matrix_expression<AE> 439&ae)</code></td> 440<td>Assigns a matrix expression to the symmetric adaptor. Left and 441right hand side of the assignment should be independent.</td> 442</tr> 443<tr> 444<td><code>template<class AE><br /> 445symmetric_adaptor &operator += (const 446matrix_expression<AE> &ae)</code></td> 447<td>A computed assignment operator. Adds the matrix expression to 448the symmetric adaptor.</td> 449</tr> 450<tr> 451<td><code>template<class AE><br /> 452symmetric_adaptor &plus_assign (const 453matrix_expression<AE> &ae)</code></td> 454<td>Adds a matrix expression to the symmetric adaptor. Left and 455right hand side of the assignment should be independent.</td> 456</tr> 457<tr> 458<td><code>template<class AE><br /> 459symmetric_adaptor &operator -= (const 460matrix_expression<AE> &ae)</code></td> 461<td>A computed assignment operator. Subtracts the matrix expression 462from the symmetric adaptor.</td> 463</tr> 464<tr> 465<td><code>template<class AE><br /> 466symmetric_adaptor &minus_assign (const 467matrix_expression<AE> &ae)</code></td> 468<td>Subtracts a matrix expression from the symmetric adaptor. Left 469and right hand side of the assignment should be independent.</td> 470</tr> 471<tr> 472<td><code>template<class AT><br /> 473symmetric_adaptor &operator *= (const AT &at)</code></td> 474<td>A computed assignment operator. Multiplies the symmetric 475adaptor with a scalar.</td> 476</tr> 477<tr> 478<td><code>template<class AT><br /> 479symmetric_adaptor &operator /= (const AT &at)</code></td> 480<td>A computed assignment operator. Divides the symmetric adaptor 481through a scalar.</td> 482</tr> 483<tr> 484<td><code>void swap (symmetric_adaptor &m)</code></td> 485<td>Swaps the contents of the symmetric adaptors.</td> 486</tr> 487<tr> 488<td><code>const_iterator1 begin1 () const</code></td> 489<td>Returns a <code>const_iterator1</code> pointing to the 490beginning of the <code>symmetric_adaptor</code>.</td> 491</tr> 492<tr> 493<td><code>const_iterator1 end1 () const</code></td> 494<td>Returns a <code>const_iterator1</code> pointing to the end of 495the <code>symmetric_adaptor</code>.</td> 496</tr> 497<tr> 498<td><code>iterator1 begin1 ()</code></td> 499<td>Returns a <code>iterator1</code> pointing to the beginning of 500the <code>symmetric_adaptor</code>.</td> 501</tr> 502<tr> 503<td><code>iterator1 end1 ()</code></td> 504<td>Returns a <code>iterator1</code> pointing to the end of the 505<code>symmetric_adaptor</code>.</td> 506</tr> 507<tr> 508<td><code>const_iterator2 begin2 () const</code></td> 509<td>Returns a <code>const_iterator2</code> pointing to the 510beginning of the <code>symmetric_adaptor</code>.</td> 511</tr> 512<tr> 513<td><code>const_iterator2 end2 () const</code></td> 514<td>Returns a <code>const_iterator2</code> pointing to the end of 515the <code>symmetric_adaptor</code>.</td> 516</tr> 517<tr> 518<td><code>iterator2 begin2 ()</code></td> 519<td>Returns a <code>iterator2</code> pointing to the beginning of 520the <code>symmetric_adaptor</code>.</td> 521</tr> 522<tr> 523<td><code>iterator2 end2 ()</code></td> 524<td>Returns a <code>iterator2</code> pointing to the end of the 525<code>symmetric_adaptor</code>.</td> 526</tr> 527<tr> 528<td><code>const_reverse_iterator1 rbegin1 () const</code></td> 529<td>Returns a <code>const_reverse_iterator1</code> pointing to the 530beginning of the reversed <code>symmetric_adaptor</code>.</td> 531</tr> 532<tr> 533<td><code>const_reverse_iterator1 rend1 () const</code></td> 534<td>Returns a <code>const_reverse_iterator1</code> pointing to the 535end of the reversed <code>symmetric_adaptor</code>.</td> 536</tr> 537<tr> 538<td><code>reverse_iterator1 rbegin1 ()</code></td> 539<td>Returns a <code>reverse_iterator1</code> pointing to the 540beginning of the reversed <code>symmetric_adaptor</code>.</td> 541</tr> 542<tr> 543<td><code>reverse_iterator1 rend1 ()</code></td> 544<td>Returns a <code>reverse_iterator1</code> pointing to the end of 545the reversed <code>symmetric_adaptor</code>.</td> 546</tr> 547<tr> 548<td><code>const_reverse_iterator2 rbegin2 () const</code></td> 549<td>Returns a <code>const_reverse_iterator2</code> pointing to the 550beginning of the reversed <code>symmetric_adaptor</code>.</td> 551</tr> 552<tr> 553<td><code>const_reverse_iterator2 rend2 () const</code></td> 554<td>Returns a <code>const_reverse_iterator2</code> pointing to the 555end of the reversed <code>symmetric_adaptor</code>.</td> 556</tr> 557<tr> 558<td><code>reverse_iterator2 rbegin2 ()</code></td> 559<td>Returns a <code>reverse_iterator2</code> pointing to the 560beginning of the reversed <code>symmetric_adaptor</code>.</td> 561</tr> 562<tr> 563<td><code>reverse_iterator2 rend2 ()</code></td> 564<td>Returns a <code>reverse_iterator2</code> pointing to the end of 565the reversed <code>symmetric_adaptor</code>.</td> 566</tr> 567</tbody> 568</table> 569<h4>Notes</h4> 570<p><a name="symmetric_adaptor_1">[1]</a> 571Supported parameters for the type of the symmetric adaptor are 572<code>lower</code> and <code>upper</code>.</p> 573<hr /> 574<p>Copyright (©) 2000-2002 Joerg Walter, Mathias Koch<br /> 575 Use, modification and distribution are subject to the 576 Boost Software License, Version 1.0. 577 (See accompanying file LICENSE_1_0.txt 578 or copy at <a href="http://www.boost.org/LICENSE_1_0.txt"> 579 http://www.boost.org/LICENSE_1_0.txt 580 </a>). 581</p> 582<script type="text/javascript"> 583(function($) { 584 $('#toc').toc(); 585})(jQuery); 586</script> 587</body> 588</html> 589