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