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