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