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">
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>
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>
20 <p>The templated class
<code>hermitian_matrix
<T, F1, F2,
21 A
></code> is the base container adaptor for hermitian matrices.
22 For 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,
25 i
</em></sub><sup><em>-
</em></sup>. The storage of hermitian
26 matrices is packed.
</p>
29 #include
<boost/numeric/ublas/hermitian.hpp
>
30 #include
<boost/numeric/ublas/io.hpp
>
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);
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);
47 std::cout
<< mu
<< std::endl;
51 <p>Defined in the header hermitian.hpp.
</p>
52 <h4>Template parameters
</h4>
53 <table border=
"1" summary=
"parameters">
61 <td><code>T
</code></td>
62 <td>The type of object stored in the matrix.
</td>
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>
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>
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>
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
>
94 <table border=
"1" summary=
"members">
101 <td><code>hermitian_matrix ()
</code></td>
102 <td>Allocates an uninitialized
<code>hermitian_matrix
</code> that
103 holds zero rows of zero elements.
</td>
106 <td><code>hermitian_matrix (size_type size)
</code></td>
107 <td>Allocates an uninitialized
<code>hermitian_matrix
</code> that
108 holds
<code>size
</code> rows of
<code>size
</code> elements.
</td>
111 <td><code>hermitian_matrix (const hermitian_matrix
113 <td>The copy constructor.
</td>
116 <td><code>template
<class AE
><br />
117 hermitian_matrix (const matrix_expression
<AE
>
119 <td>The extended copy constructor.
</td>
122 <td><code>void resize (size_type size, bool preserve =
124 <td>Reallocates a
<code>hermitian_matrix
</code> to hold
125 <code>size
</code> rows of
<code>size
</code> elements. The existing
126 elements of the
<code>hermitian_matrix
</code> are preseved when
130 <td><code>size_type size1 () const
</code></td>
131 <td>Returns the number of rows.
</td>
134 <td><code>size_type size2 () const
</code></td>
135 <td>Returns the number of columns.
</td>
138 <td><code>const_reference operator () (size_type i, size_type j)
140 <td>Returns a
<code>const
</code> reference of the
<code>j
</code>
141 -th element in the
<code>i
</code>-th row.
</td>
144 <td><code>reference operator () (size_type i, size_type
146 <td>Returns a reference of the
<code>j
</code>-th element in the
147 <code>i
</code>-th row.
</td>
150 <td><code>hermitian_matrix
&operator = (const hermitian_matrix
152 <td>The assignment operator.
</td>
155 <td><code>hermitian_matrix
&assign_temporary (hermitian_matrix
157 <td>Assigns a temporary. May change the hermitian matrix
158 <code>m
</code> .
</td>
161 <td><code>template
<class AE
><br />
162 hermitian_matrix
&operator = (const matrix_expression
<AE
>
164 <td>The extended assignment operator.
</td>
167 <td><code>template
<class AE
><br />
168 hermitian_matrix
&assign (const matrix_expression
<AE
>
170 <td>Assigns a matrix expression to the hermitian matrix. Left and
171 right hand side of the assignment should be independent.
</td>
174 <td><code>template
<class AE
><br />
175 hermitian_matrix
&operator += (const
176 matrix_expression
<AE
> &ae)
</code></td>
177 <td>A computed assignment operator. Adds the matrix expression to
178 the hermitian matrix.
</td>
181 <td><code>template
<class AE
><br />
182 hermitian_matrix
&plus_assign (const
183 matrix_expression
<AE
> &ae)
</code></td>
184 <td>Adds a matrix expression to the hermitian matrix. Left and
185 right hand side of the assignment should be independent.
</td>
188 <td><code>template
<class AE
><br />
189 hermitian_matrix
&operator -= (const
190 matrix_expression
<AE
> &ae)
</code></td>
191 <td>A computed assignment operator. Subtracts the matrix expression
192 from the hermitian matrix.
</td>
195 <td><code>template
<class AE
><br />
196 hermitian_matrix
&minus_assign (const
197 matrix_expression
<AE
> &ae)
</code></td>
198 <td>Subtracts a matrix expression from the hermitian matrix. Left
199 and right hand side of the assignment should be independent.
</td>
202 <td><code>template
<class AT
><br />
203 hermitian_matrix
&operator *= (const AT
&at)
</code></td>
204 <td>A computed assignment operator. Multiplies the hermitian matrix
208 <td><code>template
<class AT
><br />
209 hermitian_matrix
&operator /= (const AT
&at)
</code></td>
210 <td>A computed assignment operator. Divides the hermitian matrix
211 through a scalar.
</td>
214 <td><code>void swap (hermitian_matrix
&m)
</code></td>
215 <td>Swaps the contents of the hermitian matrices.
</td>
218 <td><code>void insert (size_type i, size_type j, const_reference
220 <td>Inserts the value
<code>t
</code> at the
<code>j
</code>-th
221 element of the
<code>i
</code>-th row.
</td>
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>
229 <td><code>void clear ()
</code></td>
230 <td>Clears the matrix.
</td>
233 <td><code>const_iterator1 begin1 () const
</code></td>
234 <td>Returns a
<code>const_iterator1
</code> pointing to the
235 beginning of the
<code>hermitian_matrix
</code>.
</td>
238 <td><code>const_iterator1 end1 () const
</code></td>
239 <td>Returns a
<code>const_iterator1
</code> pointing to the end of
240 the
<code>hermitian_matrix
</code>.
</td>
243 <td><code>iterator1 begin1 ()
</code></td>
244 <td>Returns a
<code>iterator1
</code> pointing to the beginning of
245 the
<code>hermitian_matrix
</code>.
</td>
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>
253 <td><code>const_iterator2 begin2 () const
</code></td>
254 <td>Returns a
<code>const_iterator2
</code> pointing to the
255 beginning of the
<code>hermitian_matrix
</code>.
</td>
258 <td><code>const_iterator2 end2 () const
</code></td>
259 <td>Returns a
<code>const_iterator2
</code> pointing to the end of
260 the
<code>hermitian_matrix
</code>.
</td>
263 <td><code>iterator2 begin2 ()
</code></td>
264 <td>Returns a
<code>iterator2
</code> pointing to the beginning of
265 the
<code>hermitian_matrix
</code>.
</td>
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>
273 <td><code>const_reverse_iterator1 rbegin1 () const
</code></td>
274 <td>Returns a
<code>const_reverse_iterator1
</code> pointing to the
275 beginning of the reversed
<code>hermitian_matrix
</code>.
</td>
278 <td><code>const_reverse_iterator1 rend1 () const
</code></td>
279 <td>Returns a
<code>const_reverse_iterator1
</code> pointing to the
280 end of the reversed
<code>hermitian_matrix
</code>.
</td>
283 <td><code>reverse_iterator1 rbegin1 ()
</code></td>
284 <td>Returns a
<code>reverse_iterator1
</code> pointing to the
285 beginning of the reversed
<code>hermitian_matrix
</code>.
</td>
288 <td><code>reverse_iterator1 rend1 ()
</code></td>
289 <td>Returns a
<code>reverse_iterator1
</code> pointing to the end of
290 the reversed
<code>hermitian_matrix
</code>.
</td>
293 <td><code>const_reverse_iterator2 rbegin2 () const
</code></td>
294 <td>Returns a
<code>const_reverse_iterator2
</code> pointing to the
295 beginning of the reversed
<code>hermitian_matrix
</code>.
</td>
298 <td><code>const_reverse_iterator2 rend2 () const
</code></td>
299 <td>Returns a
<code>const_reverse_iterator2
</code> pointing to the
300 end of the reversed
<code>hermitian_matrix
</code>.
</td>
303 <td><code>reverse_iterator2 rbegin2 ()
</code></td>
304 <td>Returns a
<code>reverse_iterator2
</code> pointing to the
305 beginning of the reversed
<code>hermitian_matrix
</code>.
</td>
308 <td><code>reverse_iterator2 rend2 ()
</code></td>
309 <td>Returns a
<code>reverse_iterator2
</code> pointing to the end of
310 the reversed
<code>hermitian_matrix
</code>.
</td>
315 <p><a name=
"hermitian_matrix_1" id=
"hermitian_matrix_1">[
1]
</a>
316 Supported 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>
319 Supported 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>
322 Supported 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>
328 <p>The templated class
<code>hermitian_adaptor
<M, F
></code>
329 is a hermitian matrix adaptor for other matrices.
</p>
332 #include
<boost/numeric/ublas/hermitian.hpp
>
333 #include
<boost/numeric/ublas/io.hpp
>
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);
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);
351 std::cout
<< hau
<< std::endl;
355 <p>Defined in the header hermitian.hpp.
</p>
356 <h4>Template parameters
</h4>
357 <table border=
"1" summary=
"parameters">
365 <td><code>M
</code></td>
366 <td>The type of the adapted matrix.
</td>
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>
378 <p><a href=
"expression_concept.html#matrix_expression">Matrix Expression
</a>
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
>
387 <table border=
"1" summary=
"members">
394 <td><code>hermitian_adaptor (matrix_type
&data)
</code></td>
395 <td>Constructs a
<code>hermitian_adaptor
</code> of a matrix.
</td>
398 <td><code>hermitian_adaptor (const hermitian_adaptor
400 <td>The copy constructor.
</td>
403 <td><code>template
<class AE
><br />
404 hermitian_adaptor (const matrix_expression
<AE
>
406 <td>The extended copy constructor.
</td>
409 <td><code>size_type size1 () const
</code></td>
410 <td>Returns the number of rows.
</td>
413 <td><code>size_type size2 () const
</code></td>
414 <td>Returns the number of columns.
</td>
417 <td><code>const_reference operator () (size_type i, size_type j)
419 <td>Returns a
<code>const
</code> reference of the
<code>j
</code>
420 -th element in the
<code>i
</code>-th row.
</td>
423 <td><code>reference operator () (size_type i, size_type
425 <td>Returns a reference of the
<code>j
</code>-th element in the
426 <code>i
</code>-th row.
</td>
429 <td><code>hermitian_adaptor
&operator = (const
430 hermitian_adaptor
&m)
</code></td>
431 <td>The assignment operator.
</td>
434 <td><code>hermitian_adaptor
&assign_temporary
435 (hermitian_adaptor
&m)
</code></td>
436 <td>Assigns a temporary. May change the hermitian adaptor
440 <td><code>template
<class AE
><br />
441 hermitian_adaptor
&operator = (const
442 matrix_expression
<AE
> &ae)
</code></td>
443 <td>The extended assignment operator.
</td>
446 <td><code>template
<class AE
><br />
447 hermitian_adaptor
&assign (const matrix_expression
<AE
>
449 <td>Assigns a matrix expression to the hermitian adaptor. Left and
450 right hand side of the assignment should be independent.
</td>
453 <td><code>template
<class AE
><br />
454 hermitian_adaptor
&operator += (const
455 matrix_expression
<AE
> &ae)
</code></td>
456 <td>A computed assignment operator. Adds the matrix expression to
457 the hermitian adaptor.
</td>
460 <td><code>template
<class AE
><br />
461 hermitian_adaptor
&plus_assign (const
462 matrix_expression
<AE
> &ae)
</code></td>
463 <td>Adds a matrix expression to the hermitian adaptor. Left and
464 right hand side of the assignment should be independent.
</td>
467 <td><code>template
<class AE
><br />
468 hermitian_adaptor
&operator -= (const
469 matrix_expression
<AE
> &ae)
</code></td>
470 <td>A computed assignment operator. Subtracts the matrix expression
471 from the hermitian adaptor.
</td>
474 <td><code>template
<class AE
><br />
475 hermitian_adaptor
&minus_assign (const
476 matrix_expression
<AE
> &ae)
</code></td>
477 <td>Subtracts a matrix expression from the hermitian adaptor. Left
478 and right hand side of the assignment should be independent.
</td>
481 <td><code>template
<class AT
><br />
482 hermitian_adaptor
&operator *= (const AT
&at)
</code></td>
483 <td>A computed assignment operator. Multiplies the hermitian
484 adaptor with a scalar.
</td>
487 <td><code>template
<class AT
><br />
488 hermitian_adaptor
&operator /= (const AT
&at)
</code></td>
489 <td>A computed assignment operator. Divides the hermitian adaptor
490 through a scalar.
</td>
493 <td><code>void swap (hermitian_adaptor
&m)
</code></td>
494 <td>Swaps the contents of the hermitian adaptors.
</td>
497 <td><code>const_iterator1 begin1 () const
</code></td>
498 <td>Returns a
<code>const_iterator1
</code> pointing to the
499 beginning of the
<code>hermitian_adaptor
</code>.
</td>
502 <td><code>const_iterator1 end1 () const
</code></td>
503 <td>Returns a
<code>const_iterator1
</code> pointing to the end of
504 the
<code>hermitian_adaptor
</code>.
</td>
507 <td><code>iterator1 begin1 ()
</code></td>
508 <td>Returns a
<code>iterator1
</code> pointing to the beginning of
509 the
<code>hermitian_adaptor
</code>.
</td>
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>
517 <td><code>const_iterator2 begin2 () const
</code></td>
518 <td>Returns a
<code>const_iterator2
</code> pointing to the
519 beginning of the
<code>hermitian_adaptor
</code>.
</td>
522 <td><code>const_iterator2 end2 () const
</code></td>
523 <td>Returns a
<code>const_iterator2
</code> pointing to the end of
524 the
<code>hermitian_adaptor
</code>.
</td>
527 <td><code>iterator2 begin2 ()
</code></td>
528 <td>Returns a
<code>iterator2
</code> pointing to the beginning of
529 the
<code>hermitian_adaptor
</code>.
</td>
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>
537 <td><code>const_reverse_iterator1 rbegin1 () const
</code></td>
538 <td>Returns a
<code>const_reverse_iterator1
</code> pointing to the
539 beginning of the reversed
<code>hermitian_adaptor
</code>.
</td>
542 <td><code>const_reverse_iterator1 rend1 () const
</code></td>
543 <td>Returns a
<code>const_reverse_iterator1
</code> pointing to the
544 end of the reversed
<code>hermitian_adaptor
</code>.
</td>
547 <td><code>reverse_iterator1 rbegin1 ()
</code></td>
548 <td>Returns a
<code>reverse_iterator1
</code> pointing to the
549 beginning of the reversed
<code>hermitian_adaptor
</code>.
</td>
552 <td><code>reverse_iterator1 rend1 ()
</code></td>
553 <td>Returns a
<code>reverse_iterator1
</code> pointing to the end of
554 the reversed
<code>hermitian_adaptor
</code>.
</td>
557 <td><code>const_reverse_iterator2 rbegin2 () const
</code></td>
558 <td>Returns a
<code>const_reverse_iterator2
</code> pointing to the
559 beginning of the reversed
<code>hermitian_adaptor
</code>.
</td>
562 <td><code>const_reverse_iterator2 rend2 () const
</code></td>
563 <td>Returns a
<code>const_reverse_iterator2
</code> pointing to the
564 end of the reversed
<code>hermitian_adaptor
</code>.
</td>
567 <td><code>reverse_iterator2 rbegin2 ()
</code></td>
568 <td>Returns a
<code>reverse_iterator2
</code> pointing to the
569 beginning of the reversed
<code>hermitian_adaptor
</code>.
</td>
572 <td><code>reverse_iterator2 rend2 ()
</code></td>
573 <td>Returns a
<code>reverse_iterator2
</code> pointing to the end of
574 the reversed
<code>hermitian_adaptor
</code>.
</td>
579 <p><a name=
"hermitian_adaptor_1" id=
"hermitian_adaptor_1">[
1]
</a>
580 Supported parameters for the type of the hermitian adaptor are
581 <code>lower
</code> and
<code>upper
</code>.
</p>
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
591 <script type=
"text/javascript">