Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/numeric/ublas/doc/symmetric.htm @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

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