Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

added boost

File size: 33.1 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>Sparse Matrix</title>
11</head>
12<body>
13<h1><img src="../../../../boost.png" align="middle" />
14Sparse Matricies</h1>
15<h2><a name="mapped_matrix" id="mapped_matrix"></a>Mapped Matrix</h2>
16<h4>Description</h4>
17<p>The templated class <code>mapped_matrix&lt;T, F, A&gt;</code> is
18the base container adaptor for sparse matricies using element maps.
19For a <em>(m xn</em>)-dimensional sparse matrix and <em>0 &lt;= i &lt; m</em>,
20<em>0 &lt;= j &lt; n</em> the non-zero elements
21<em>m</em><sub><em>i, j</em></sub> are mapped via <em>(i x n +
22j)</em> for row major orientation or via <em>(i + j x m)</em> for
23column major orientation to consecutive elements of the associative
24container, i.e. for elements <em>k</em> =
25<em>m</em><sub><em>i</em></sub><sub><sub><em>1</em></sub></sub><sub>
26<em>,j</em></sub><sub><sub><em>1</em></sub></sub>and <em>k + 1 =
27m</em><sub><em>i</em></sub><sub><sub><em>2</em></sub></sub><sub><em>
28,j</em></sub><sub><sub><em>2</em></sub></sub>of the container holds
29<em>i</em><sub><em>1</em></sub> <em>&lt;
30i</em><sub><em>2</em></sub> or <em>(i</em><sub><em>1</em></sub>
31<em>= i</em><sub><em>2</em></sub> and
32<em>j</em><sub><em>1</em></sub> <em>&lt;
33j</em><sub><em>2</em></sub><em>)</em> with row major orientation or
34<em>j</em><sub><em>1</em></sub> <em>&lt;
35j</em><sub><em>2</em></sub> or <em>(j</em><sub><em>1</em></sub>
36<em>= j</em><sub><em>2</em></sub> and
37<em>i</em><sub><em>1</em></sub> <em>&lt;
38i</em><sub><em>2</em></sub><em>)</em> with column major
39orientation.</p>
40<h4>Example</h4>
41<pre>
42#include &lt;boost/numeric/ublas/matrix_sparse.hpp&gt;
43#include &lt;boost/numeric/ublas/io.hpp&gt;
44
45int main () {
46    using namespace boost::numeric::ublas;
47    mapped_matrix&lt;double&gt; m (3, 3, 3 * 3);
48    for (unsigned i = 0; i &lt; m.size1 (); ++ i)
49        for (unsigned j = 0; j &lt; m.size2 (); ++ j)
50            m (i, j) = 3 * i + j;
51    std::cout &lt;&lt; m &lt;&lt; std::endl;
52}
53</pre>
54<h4>Definition</h4>
55<p>Defined in the header matrix_sparse.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 mapped matrix.</td>
67<td></td>
68</tr>
69<tr>
70<td><code>F</code></td>
71<td>Functor describing the storage organization. <a href=
72"#mapped_matrix_1">[1]</a></td>
73<td><code>row_major</code></td>
74</tr>
75<tr>
76<td><code>A</code></td>
77<td>The type of the adapted array. <a href=
78"#mapped_matrix_2">[2]</a></td>
79<td><code>map_std&lt;std::size_t, T&gt;</code></td>
80</tr>
81</tbody>
82</table>
83<h4>Model of</h4>
84<p><a href="container_concept.htm#matrix">Matrix</a> .</p>
85<h4>Type requirements</h4>
86<p>None, except for those imposed by the requirements of <a href=
87"container_concept.htm#matrix">Matrix</a> .</p>
88<h4>Public base classes</h4>
89<p><code>matrix_container&lt;mapped_matrix&lt;T, F, A&gt;
90&gt;</code></p>
91<h4>Members</h4>
92<table border="1" summary="members">
93<tbody>
94<tr>
95<th>Member</th>
96<th>Description</th>
97</tr>
98<tr>
99<td><code>mapped_matrix ()</code></td>
100<td>Allocates a <code>mapped_matrix</code> that holds at most zero
101rows of zero elements.</td>
102</tr>
103<tr>
104<td><code>mapped_matrix (size_type size1, size_type2, size_type non_zeros = 0)</code></td>
105<td>Allocates a <code>mapped_matrix</code> that holds at most
106<code>size1</code> rows of <code>size2</code> elements.</td>
107</tr>
108<tr>
109<td><code>mapped_matrix (const mapped_matrix &amp;m)</code></td>
110<td>The copy constructor.</td>
111</tr>
112<tr>
113<td><code>template&lt;class AE&gt;<br />
114mapped_matrix (size_type non_zeros, const
115matrix_expression&lt;AE&gt; &amp;ae)</code></td>
116<td>The extended copy constructor.</td>
117</tr>
118<tr>
119<td><code>void resize (size_type size1, size_type size2, bool preserve = true)</code></td>
120<td>Reallocates a <code>mapped_matrix</code> to hold at most
121<code>size1</code> rows of <code>size2</code> elements. The
122existing elements of the <code>mapped_matrix</code> are preseved
123when specified.</td>
124</tr>
125<tr>
126<td><code>size_type size1 () const</code></td>
127<td>Returns the number of rows.</td>
128</tr>
129<tr>
130<td><code>size_type size2 () const</code></td>
131<td>Returns the number of columns.</td>
132</tr>
133<tr>
134<td><code>const_reference operator () (size_type i, size_type j)
135const</code></td>
136<td>Returns the value of the <code>j</code>-th element in the
137<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>mapped_matrix &amp;operator = (const mapped_matrix
147&amp;m)</code></td>
148<td>The assignment operator.</td>
149</tr>
150<tr>
151<td><code>mapped_matrix &amp;assign_temporary (mapped_matrix
152&amp;m)</code></td>
153<td>Assigns a temporary. May change the mapped matrix
154<code>m</code> .</td>
155</tr>
156<tr>
157<td><code>template&lt;class AE&gt;<br />
158mapped_matrix &amp;operator = (const matrix_expression&lt;AE&gt;
159&amp;ae)</code></td>
160<td>The extended assignment operator.</td>
161</tr>
162<tr>
163<td><code>template&lt;class AE&gt;<br />
164mapped_matrix &amp;assign (const matrix_expression&lt;AE&gt;
165&amp;ae)</code></td>
166<td>Assigns a matrix expression to the mapped matrix. Left and
167right hand side of the assignment should be independent.</td>
168</tr>
169<tr>
170<td><code>template&lt;class AE&gt;<br />
171mapped_matrix &amp;operator += (const matrix_expression&lt;AE&gt;
172&amp;ae)</code></td>
173<td>A computed assignment operator. Adds the matrix expression to
174the mapped matrix.</td>
175</tr>
176<tr>
177<td><code>template&lt;class AE&gt;<br />
178mapped_matrix &amp;plus_assign (const matrix_expression&lt;AE&gt;
179&amp;ae)</code></td>
180<td>Adds a matrix expression to the mapped matrix. Left and right
181hand side of the assignment should be independent.</td>
182</tr>
183<tr>
184<td><code>template&lt;class AE&gt;<br />
185mapped_matrix &amp;operator -= (const matrix_expression&lt;AE&gt;
186&amp;ae)</code></td>
187<td>A computed assignment operator. Subtracts the matrix expression
188from the mapped matrix.</td>
189</tr>
190<tr>
191<td><code>template&lt;class AE&gt;<br />
192mapped_matrix &amp;minus_assign (const matrix_expression&lt;AE&gt;
193&amp;ae)</code></td>
194<td>Subtracts a matrix expression from the mapped matrix. Left and
195right hand side of the assignment should be independent.</td>
196</tr>
197<tr>
198<td><code>template&lt;class AT&gt;<br />
199mapped_matrix &amp;operator *= (const AT &amp;at)</code></td>
200<td>A computed assignment operator. Multiplies the mapped matrix
201with a scalar.</td>
202</tr>
203<tr>
204<td><code>template&lt;class AT&gt;<br />
205mapped_matrix &amp;operator /= (const AT &amp;at)</code></td>
206<td>A computed assignment operator. Divides the mapped matrix
207through a scalar.</td>
208</tr>
209<tr>
210<td><code>void swap (mapped_matrix &amp;m)</code></td>
211<td>Swaps the contents of the mapped matrices.</td>
212</tr>
213<tr>
214<td><code>true_refrence insert_element (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. Duplicates elements are not allowed.</td>
218</tr>
219<tr>
220<td><code>void erase_element (size_type i, size_type j)</code></td>
221<td>Erases the value at the <code>j</code>-th element of the
222<code>i</code>-th row.</td>
223</tr>
224<tr>
225<td><code>void clear ()</code></td>
226<td>Clears the mapped 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>mapped_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>mapped_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>mapped_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>mapped_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>mapped_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>mapped_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>mapped_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>mapped_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>mapped_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>mapped_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>mapped_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>mapped_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>mapped_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>mapped_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>mapped_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>mapped_matrix</code>.</td>
307</tr>
308</tbody>
309</table>
310<h4>Notes</h4>
311<p><a name="mapped_matrix_1" id="mapped_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="mapped_matrix_2" id="mapped_matrix_2">[2]</a> Supported
315parameters for the adapted array are
316<code>map_array&lt;std::size_t, T&gt;</code> and
317<code>map_std&lt;std::size_t, T&gt;</code>. The latter is
318equivalent to <code>std::map&lt;std::size_t, T&gt;</code>.</p>
319<h2><a name="compressed_matrix" id="compressed_matrix"></a>Compressed Matrix</h2>
320<h4>Description</h4>
321<p>The templated class <code>compressed_matrix&lt;T, F, IB, IA,
322TA&gt;</code> is the base container adaptor for compressed
323matrices. For a <em>(m x n</em> )-dimensional compressed matrix and
324<em>0 &lt;= i &lt; m</em>, <em>0 &lt;= j &lt; n</em> the non-zero
325elements <em>m</em><sub><em>i, j</em></sub> are mapped via <em>(i x
326n + j)</em> for row major orientation or via <em>(i + j x m)</em>
327for column major orientation to consecutive elements of the index
328and value containers, i.e. for elements <em>k</em> =
329<em>m</em><sub><em>i</em></sub><sub><sub><em>1</em></sub></sub><sub>
330<em>,j</em></sub><sub><sub><em>1</em></sub></sub>and <em>k + 1 =
331m</em><sub><em>i</em></sub><sub><sub><em>2</em></sub></sub><sub><em>
332,j</em></sub><sub><sub><em>2</em></sub></sub>of the container holds
333<em>i</em><sub><em>1</em></sub> <em>&lt;
334i</em><sub><em>2</em></sub> or <em>(i</em><sub><em>1</em></sub>
335<em>= i</em><sub><em>2</em></sub> and
336<em>j</em><sub><em>1</em></sub> <em>&lt;
337j</em><sub><em>2</em></sub><em>)</em> with row major orientation or
338<em>j</em><sub><em>1</em></sub> <em>&lt;
339j</em><sub><em>2</em></sub> or <em>(j</em><sub><em>1</em></sub>
340<em>= j</em><sub><em>2</em></sub> and
341<em>i</em><sub><em>1</em></sub> <em>&lt;
342i</em><sub><em>2</em></sub><em>)</em> with column major
343orientation.</p>
344<h4>Example</h4>
345<pre>
346#include &lt;boost/numeric/ublas/matrix_sparse.hpp&gt;
347#include &lt;boost/numeric/ublas/io.hpp&gt;
348
349int main () {
350    using namespace boost::numeric::ublas;
351    compressed_matrix&lt;double&gt; m (3, 3, 3 * 3);
352    for (unsigned i = 0; i &lt; m.size1 (); ++ i)
353        for (unsigned j = 0; j &lt; m.size2 (); ++ j)
354            m (i, j) = 3 * i + j;
355    std::cout &lt;&lt; m &lt;&lt; std::endl;
356}
357</pre>
358<h4>Definition</h4>
359<p>Defined in the header matrix_sparse.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>T</code></td>
370<td>The type of object stored in the compressed matrix.</td>
371<td></td>
372</tr>
373<tr>
374<td><code>F</code></td>
375<td>Functor describing the storage organization. <a href=
376"#compressed_matrix_1">[1]</a></td>
377<td><code>row_major</code></td>
378</tr>
379<tr>
380<td><code>IB</code></td>
381<td>The index base of the compressed vector. <a href=
382"#compressed_matrix_2">[2]</a></td>
383<td><code>0</code></td>
384</tr>
385<tr>
386<td><code>IA</code></td>
387<td>The type of the adapted array for indices. <a href=
388"#compressed_matrix_3">[3]</a></td>
389<td><code>unbounded_array&lt;std::size_t&gt;</code></td>
390</tr>
391<tr>
392<td><code>TA</code></td>
393<td>The type of the adapted array for values. <a href=
394"#compressed_matrix_3">[3]</a></td>
395<td><code>unbounded_array&lt;T&gt;</code></td>
396</tr>
397</tbody>
398</table>
399<h4>Model of</h4>
400<p><a href="container_concept.htm#matrix">Matrix</a> .</p>
401<h4>Type requirements</h4>
402<p>None, except for those imposed by the requirements of <a href=
403"container_concept.htm#matrix">Matrix</a> .</p>
404<h4>Public base classes</h4>
405<p><code>matrix_container&lt;compressed_matrix&lt;T, F, IB, IA,
406TA&gt; &gt;</code></p>
407<h4>Members</h4>
408<table border="1" summary="members">
409<tbody>
410<tr>
411<th>Member</th>
412<th>Description</th>
413</tr>
414<tr>
415<td><code>compressed_matrix ()</code></td>
416<td>Allocates a <code>compressed_matrix</code> that holds at most
417zero rows of zero elements.</td>
418</tr>
419<tr>
420<td><code>compressed_matrix (size_type size1, size_type2, size_type non_zeros = 0)</code></td>
421<td>Allocates a <code>compressed_matrix</code> that holds at most
422<code>size1</code> rows of <code>size2</code> elements.</td>
423</tr>
424<tr>
425<td><code>compressed_matrix (const compressed_matrix
426&amp;m)</code></td>
427<td>The copy constructor.</td>
428</tr>
429<tr>
430<td><code>template&lt;class AE&gt;<br />
431compressed_matrix (size_type non_zeros, const
432matrix_expression&lt;AE&gt; &amp;ae)</code></td>
433<td>The extended copy constructor.</td>
434</tr>
435<tr>
436<td><code>void resize (size_type size1, size_type size2, bool preserve = true)</code></td>
437<td>Reallocates a <code>compressed_matrix</code> to hold at most
438<code>size1</code> rows of <code>size2</code> elements. The
439existing elements of the <code>compressed_matrix</code> are
440preseved when specified.</td>
441</tr>
442<tr>
443<td><code>size_type size1 () const</code></td>
444<td>Returns the number of rows.</td>
445</tr>
446<tr>
447<td><code>size_type size2 () const</code></td>
448<td>Returns the number of columns.</td>
449</tr>
450<tr>
451<td><code>const_reference operator () (size_type i, size_type j)
452const</code></td>
453<td>Returns the value of the <code>j</code>-th element in the
454<code>i</code>-th row.</td>
455</tr>
456<tr>
457<td><code>reference operator () (size_type i, size_type
458j)</code></td>
459<td>Returns a reference of the <code>j</code>-th element in the
460<code>i</code>-th row.</td>
461</tr>
462<tr>
463<td><code>compressed_matrix &amp;operator = (const
464compressed_matrix &amp;m)</code></td>
465<td>The assignment operator.</td>
466</tr>
467<tr>
468<td><code>compressed_matrix &amp;assign_temporary
469(compressed_matrix &amp;m)</code></td>
470<td>Assigns a temporary. May change the compressed matrix
471<code>m</code>.</td>
472</tr>
473<tr>
474<td><code>template&lt;class AE&gt;<br />
475compressed_matrix &amp;operator = (const
476matrix_expression&lt;AE&gt; &amp;ae)</code></td>
477<td>The extended assignment operator.</td>
478</tr>
479<tr>
480<td><code>template&lt;class AE&gt;<br />
481compressed_matrix &amp;assign (const matrix_expression&lt;AE&gt;
482&amp;ae)</code></td>
483<td>Assigns a matrix expression to the compressed matrix. Left and
484right hand side of the assignment should be independent.</td>
485</tr>
486<tr>
487<td><code>template&lt;class AE&gt;<br />
488compressed_matrix &amp;operator += (const
489matrix_expression&lt;AE&gt; &amp;ae)</code></td>
490<td>A computed assignment operator. Adds the matrix expression to
491the compressed matrix.</td>
492</tr>
493<tr>
494<td><code>template&lt;class AE&gt;<br />
495compressed_matrix &amp;plus_assign (const
496matrix_expression&lt;AE&gt; &amp;ae)</code></td>
497<td>Adds a matrix expression to the compressed matrix. Left and
498right hand side of the assignment should be independent.</td>
499</tr>
500<tr>
501<td><code>template&lt;class AE&gt;<br />
502compressed_matrix &amp;operator -= (const
503matrix_expression&lt;AE&gt; &amp;ae)</code></td>
504<td>A computed assignment operator. Subtracts the matrix expression
505from the compressed matrix.</td>
506</tr>
507<tr>
508<td><code>template&lt;class AE&gt;<br />
509compressed_matrix &amp;minus_assign (const
510matrix_expression&lt;AE&gt; &amp;ae)</code></td>
511<td>Subtracts a matrix expression from the compressed matrix. Left
512and right hand side of the assignment should be independent.</td>
513</tr>
514<tr>
515<td><code>template&lt;class AT&gt;<br />
516compressed_matrix &amp;operator *= (const AT &amp;at)</code></td>
517<td>A computed assignment operator. Multiplies the compressed
518matrix with a scalar.</td>
519</tr>
520<tr>
521<td><code>template&lt;class AT&gt;<br />
522compressed_matrix &amp;operator /= (const AT &amp;at)</code></td>
523<td>A computed assignment operator. Divides the compressed matrix
524through a scalar.</td>
525</tr>
526<tr>
527<td><code>void swap (compressed_matrix &amp;m)</code></td>
528<td>Swaps the contents of the compressed matrices.</td>
529</tr>
530<tr>
531<td><code>true_reference insert_element (size_type i, size_type j, const_reference
532t)</code></td>
533<td>Inserts the value <code>t</code> at the <code>j</code>-th
534element of the <code>i</code>-th row. Duplicates elements are not allowed.</td>
535</tr>
536<tr>
537<td><code>void erase_element (size_type i, size_type j)</code></td>
538<td>Erases the value at the <code>j</code>-th element of the
539<code>i</code>-th row.</td>
540</tr>
541<tr>
542<td><code>void clear ()</code></td>
543<td>Clears the compressed matrix.</td>
544</tr>
545<tr>
546<td><code>const_iterator1 begin1 () const</code></td>
547<td>Returns a <code>const_iterator1</code> pointing to the
548beginning of the <code>compressed_matrix</code>.</td>
549</tr>
550<tr>
551<td><code>const_iterator1 end1 () const</code></td>
552<td>Returns a <code>const_iterator1</code> pointing to the end of
553the <code>compressed_matrix</code>.</td>
554</tr>
555<tr>
556<td><code>iterator1 begin1 ()</code></td>
557<td>Returns a <code>iterator1</code> pointing to the beginning of
558the <code>compressed_matrix</code>.</td>
559</tr>
560<tr>
561<td><code>iterator1 end1 ()</code></td>
562<td>Returns a <code>iterator1</code> pointing to the end of the
563<code>compressed_matrix</code>.</td>
564</tr>
565<tr>
566<td><code>const_iterator2 begin2 () const</code></td>
567<td>Returns a <code>const_iterator2</code> pointing to the
568beginning of the <code>compressed_matrix</code>.</td>
569</tr>
570<tr>
571<td><code>const_iterator2 end2 () const</code></td>
572<td>Returns a <code>const_iterator2</code> pointing to the end of
573the <code>compressed_matrix</code>.</td>
574</tr>
575<tr>
576<td><code>iterator2 begin2 ()</code></td>
577<td>Returns a <code>iterator2</code> pointing to the beginning of
578the <code>compressed_matrix</code>.</td>
579</tr>
580<tr>
581<td><code>iterator2 end2 ()</code></td>
582<td>Returns a <code>iterator2</code> pointing to the end of the
583<code>compressed_matrix</code>.</td>
584</tr>
585<tr>
586<td><code>const_reverse_iterator1 rbegin1 () const</code></td>
587<td>Returns a <code>const_reverse_iterator1</code> pointing to the
588beginning of the reversed <code>compressed_matrix</code>.</td>
589</tr>
590<tr>
591<td><code>const_reverse_iterator1 rend1 () const</code></td>
592<td>Returns a <code>const_reverse_iterator1</code> pointing to the
593end of the reversed <code>compressed_matrix</code>.</td>
594</tr>
595<tr>
596<td><code>reverse_iterator1 rbegin1 ()</code></td>
597<td>Returns a <code>reverse_iterator1</code> pointing to the
598beginning of the reversed <code>compressed_matrix</code>.</td>
599</tr>
600<tr>
601<td><code>reverse_iterator1 rend1 ()</code></td>
602<td>Returns a <code>reverse_iterator1</code> pointing to the end of
603the reversed <code>compressed_matrix</code>.</td>
604</tr>
605<tr>
606<td><code>const_reverse_iterator2 rbegin2 () const</code></td>
607<td>Returns a <code>const_reverse_iterator2</code> pointing to the
608beginning of the reversed <code>compressed_matrix</code>.</td>
609</tr>
610<tr>
611<td><code>const_reverse_iterator2 rend2 () const</code></td>
612<td>Returns a <code>const_reverse_iterator2</code> pointing to the
613end of the reversed <code>compressed_matrix</code>.</td>
614</tr>
615<tr>
616<td><code>reverse_iterator2 rbegin2 ()</code></td>
617<td>Returns a <code>reverse_iterator2</code> pointing to the
618beginning of the reversed <code>compressed_matrix</code>.</td>
619</tr>
620<tr>
621<td><code>reverse_iterator2 rend2 ()</code></td>
622<td>Returns a <code>reverse_iterator2</code> pointing to the end of
623the reversed <code>compressed_matrix</code>.</td>
624</tr>
625</tbody>
626</table>
627<h4>Notes</h4>
628<p><a name="compressed_matrix_1" id="compressed_matrix_1">[1]</a>
629Supported parameters for the storage organization are
630<code>row_major</code> and <code>column_major</code>.</p>
631<p><a name="compressed_matrix_2" id="compressed_matrix_2">[2]</a>
632Supported parameters for the index base are <code>0</code> and
633<code>1</code> at least.</p>
634<p><a name="compressed_matrix_3" id="compressed_matrix_3">[3]</a>
635Supported parameters for the adapted array are
636<code>unbounded_array&lt;&gt;</code> ,
637<code>bounded_array&lt;&gt;</code> and
638<code>std::vector&lt;&gt;</code> .</p>
639<h2><a name="coordinate_matrix" id="coordinate_matrix"></a>Coordinate Matrix</h2>
640<h4>Description</h4>
641<p>The templated class <code>coordinate_matrix&lt;T, F, IB, IA,
642TA&gt;</code> is the base container adaptor for compressed
643matrices. For a <em>(m x n</em> )-dimensional sorted coordinate
644matrix and <em>0 &lt;= i &lt; m</em>, <em>0 &lt;= j &lt; n</em> the
645non-zero elements <em>m</em><sub><em>i, j</em></sub> are mapped via
646<em>(i x n + j)</em> for row major orientation or via <em>(i + j x
647m)</em> for column major orientation to consecutive elements of the
648index and value containers, i.e. for elements <em>k</em> =
649<em>m</em><sub><em>i</em></sub><sub><sub><em>1</em></sub></sub><sub>
650<em>,j</em></sub><sub><sub><em>1</em></sub></sub>and <em>k + 1 =
651m</em><sub><em>i</em></sub><sub><sub><em>2</em></sub></sub><sub><em>
652,j</em></sub><sub><sub><em>2</em></sub></sub>of the container holds
653<em>i</em><sub><em>1</em></sub> <em>&lt;
654i</em><sub><em>2</em></sub> or <em>(i</em><sub><em>1</em></sub>
655<em>= i</em><sub><em>2</em></sub> and
656<em>j</em><sub><em>1</em></sub> <em>&lt;
657j</em><sub><em>2</em></sub><em>)</em> with row major orientation or
658<em>j</em><sub><em>1</em></sub> <em>&lt;
659j</em><sub><em>2</em></sub> or <em>(j</em><sub><em>1</em></sub>
660<em>= j</em><sub><em>2</em></sub> and
661<em>i</em><sub><em>1</em></sub> <em>&lt;
662i</em><sub><em>2</em></sub><em>)</em> with column major
663orientation.</p>
664<h4>Example</h4>
665<pre>
666#include &lt;boost/numeric/ublas/matrix_sparse.hpp&gt;
667#include &lt;boost/numeric/ublas/io.hpp&gt;
668
669int main () {
670    using namespace boost::numeric::ublas;
671    coordinate_matrix&lt;double&gt; m (3, 3, 3 * 3);
672    for (unsigned i = 0; i &lt; m.size1 (); ++ i)
673        for (unsigned j = 0; j &lt; m.size2 (); ++ j)
674            m (i, j) = 3 * i + j;
675    std::cout &lt;&lt; m &lt;&lt; std::endl;
676}
677</pre>
678<h4>Definition</h4>
679<p>Defined in the header matrix_sparse.hpp.</p>
680<h4>Template parameters</h4>
681<table border="1" summary="parameters">
682<tbody>
683<tr>
684<th>Parameter</th>
685<th>Description</th>
686<th>Default</th>
687</tr>
688<tr>
689<td><code>T</code></td>
690<td>The type of object stored in the coordinate matrix.</td>
691<td></td>
692</tr>
693<tr>
694<td><code>F</code></td>
695<td>Functor describing the storage organization. <a href=
696"#coordinate_matrix_1">[1]</a></td>
697<td><code>row_major</code></td>
698</tr>
699<tr>
700<td><code>IB</code></td>
701<td>The index base of the coordinate vector. <a href=
702"#coordinate_matrix_2">[2]</a></td>
703<td><code>0</code></td>
704</tr>
705<tr>
706<td><code>IA</code></td>
707<td>The type of the adapted array for indices. <a href=
708"#coordinate_matrix_3">[3]</a></td>
709<td><code>unbounded_array&lt;std::size_t&gt;</code></td>
710</tr>
711<tr>
712<td><code>TA</code></td>
713<td>The type of the adapted array for values. <a href=
714"#coordinate_matrix_3">[3]</a></td>
715<td><code>unbounded_array&lt;T&gt;</code></td>
716</tr>
717</tbody>
718</table>
719<h4>Model of</h4>
720<p><a href="container_concept.htm#matrix">Matrix</a> .</p>
721<h4>Type requirements</h4>
722<p>None, except for those imposed by the requirements of <a href=
723"container_concept.htm#matrix">Matrix</a> .</p>
724<h4>Public base classes</h4>
725<p><code>matrix_container&lt;coordinate_matrix&lt;T, F, IB, IA,
726TA&gt; &gt;</code></p>
727<h4>Members</h4>
728<table border="1" summary="members">
729<tbody>
730<tr>
731<th>Member</th>
732<th>Description</th>
733</tr>
734<tr>
735<td><code>coordinate_matrix ()</code></td>
736<td>Allocates a <code>coordinate_matrix</code> that holds at most
737zero rows of zero elements.</td>
738</tr>
739<tr>
740<td><code>coordinate_matrix (size_type size1, size_type2, size_type non_zeros = 0)</code></td>
741<td>Allocates a <code>coordinate_matrix</code> that holds at most
742<code>size1</code> rows of <code>size2</code> elements.</td>
743</tr>
744<tr>
745<td><code>coordinate_matrix (const coordinate_matrix
746&amp;m)</code></td>
747<td>The copy constructor.</td>
748</tr>
749<tr>
750<td><code>template&lt;class AE&gt;<br />
751coordinate_matrix (size_type non_zeros, const
752matrix_expression&lt;AE&gt; &amp;ae)</code></td>
753<td>The extended copy constructor.</td>
754</tr>
755<tr>
756<td><code>void resize (size_type size1, size_type size2, bool preserve = true)</code></td>
757<td>Reallocates a <code>coordinate_matrix</code> to hold at most
758<code>size1</code> rows of <code>size2</code> elements. The
759existing elements of the <code>coordinate_matrix</code> are
760preseved when specified.</td>
761</tr>
762<tr>
763<td><code>size_type size1 () const</code></td>
764<td>Returns the number of rows.</td>
765</tr>
766<tr>
767<td><code>size_type size2 () const</code></td>
768<td>Returns the number of columns.</td>
769</tr>
770<tr>
771<td><code>const_reference operator () (size_type i, size_type j)
772const</code></td>
773<td>Returns the value of the <code>j</code>-th element in the
774<code>i</code>-th row.</td>
775</tr>
776<tr>
777<td><code>reference operator () (size_type i, size_type
778j)</code></td>
779<td>Returns a reference of the <code>j</code>-th element in the
780<code>i</code>-th row.</td>
781</tr>
782<tr>
783<td><code>coordinate_matrix &amp;operator = (const
784coordinate_matrix &amp;m)</code></td>
785<td>The assignment operator.</td>
786</tr>
787<tr>
788<td><code>coordinate_matrix &amp;assign_temporary
789(coordinate_matrix &amp;m)</code></td>
790<td>Assigns a temporary. May change the coordinate matrix
791<code>m</code>.</td>
792</tr>
793<tr>
794<td><code>template&lt;class AE&gt;<br />
795coordinate_matrix &amp;operator = (const
796matrix_expression&lt;AE&gt; &amp;ae)</code></td>
797<td>The extended assignment operator.</td>
798</tr>
799<tr>
800<td><code>template&lt;class AE&gt;<br />
801coordinate_matrix &amp;assign (const matrix_expression&lt;AE&gt;
802&amp;ae)</code></td>
803<td>Assigns a matrix expression to the coordinate matrix. Left and
804right hand side of the assignment should be independent.</td>
805</tr>
806<tr>
807<td><code>template&lt;class AE&gt;<br />
808coordinate_matrix &amp;operator += (const
809matrix_expression&lt;AE&gt; &amp;ae)</code></td>
810<td>A computed assignment operator. Adds the matrix expression to
811the coordinate matrix.</td>
812</tr>
813<tr>
814<td><code>template&lt;class AE&gt;<br />
815coordinate_matrix &amp;plus_assign (const
816matrix_expression&lt;AE&gt; &amp;ae)</code></td>
817<td>Adds a matrix expression to the coordinate matrix. Left and
818right hand side of the assignment should be independent.</td>
819</tr>
820<tr>
821<td><code>template&lt;class AE&gt;<br />
822coordinate_matrix &amp;operator -= (const
823matrix_expression&lt;AE&gt; &amp;ae)</code></td>
824<td>A computed assignment operator. Subtracts the matrix expression
825from the coordinate matrix.</td>
826</tr>
827<tr>
828<td><code>template&lt;class AE&gt;<br />
829coordinate_matrix &amp;minus_assign (const
830matrix_expression&lt;AE&gt; &amp;ae)</code></td>
831<td>Subtracts a matrix expression from the coordinate matrix. Left
832and right hand side of the assignment should be independent.</td>
833</tr>
834<tr>
835<td><code>template&lt;class AT&gt;<br />
836coordinate_matrix &amp;operator *= (const AT &amp;at)</code></td>
837<td>A computed assignment operator. Multiplies the coordinate
838matrix with a scalar.</td>
839</tr>
840<tr>
841<td><code>template&lt;class AT&gt;<br />
842coordinate_matrix &amp;operator /= (const AT &amp;at)</code></td>
843<td>A computed assignment operator. Divides the coordinate matrix
844through a scalar.</td>
845</tr>
846<tr>
847<td><code>void swap (coordinate_matrix &amp;m)</code></td>
848<td>Swaps the contents of the coordinate matrices.</td>
849</tr>
850<tr>
851<td><code>true_reference insert_element (size_type i, size_type j, const_reference
852t)</code></td>
853<td>Inserts the value <code>t</code> at the <code>j</code>-th
854element of the <code>i</code>-th row. Duplicates elements are not allowed.</td>
855</tr>
856<tr>
857<td><code>void append_element (size_type i, size_type j, const_reference t)</code></td>
858<td>Appends the value <code>t</code> at the <code>j</code>-th element of the <code>i</code>-th row.
859Duplicate elements can be appended to a <code>coordinate_matrix</code>. They are merged into a single
860arithmetically summed element by the <code>sort</code> function.</td>
861</tr>
862<tr>
863<td><code>void erase_element (size_type i, size_type j)</code></td>
864<td>Erases the value at the <code>j</code>-th element of the
865<code>i</code>-th row.</td>
866</tr>
867<tr>
868<td><code>void clear ()</code></td>
869<td>Clears the coordinate matrix.</td>
870</tr>
871<tr>
872<td><code>const_iterator1 begin1 () const</code></td>
873<td>Returns a <code>const_iterator1</code> pointing to the
874beginning of the <code>coordinate_matrix</code>.</td>
875</tr>
876<tr>
877<td><code>const_iterator1 end1 () const</code></td>
878<td>Returns a <code>const_iterator1</code> pointing to the end of
879the <code>coordinate_matrix</code>.</td>
880</tr>
881<tr>
882<td><code>iterator1 begin1 ()</code></td>
883<td>Returns a <code>iterator1</code> pointing to the beginning of
884the <code>coordinate_matrix</code>.</td>
885</tr>
886<tr>
887<td><code>iterator1 end1 ()</code></td>
888<td>Returns a <code>iterator1</code> pointing to the end of the
889<code>coordinate_matrix</code>.</td>
890</tr>
891<tr>
892<td><code>const_iterator2 begin2 () const</code></td>
893<td>Returns a <code>const_iterator2</code> pointing to the
894beginning of the <code>coordinate_matrix</code>.</td>
895</tr>
896<tr>
897<td><code>const_iterator2 end2 () const</code></td>
898<td>Returns a <code>const_iterator2</code> pointing to the end of
899the <code>coordinate_matrix</code>.</td>
900</tr>
901<tr>
902<td><code>iterator2 begin2 ()</code></td>
903<td>Returns a <code>iterator2</code> pointing to the beginning of
904the <code>coordinate_matrix</code>.</td>
905</tr>
906<tr>
907<td><code>iterator2 end2 ()</code></td>
908<td>Returns a <code>iterator2</code> pointing to the end of the
909<code>coordinate_matrix</code>.</td>
910</tr>
911<tr>
912<td><code>const_reverse_iterator1 rbegin1 () const</code></td>
913<td>Returns a <code>const_reverse_iterator1</code> pointing to the
914beginning of the reversed <code>coordinate_matrix</code>.</td>
915</tr>
916<tr>
917<td><code>const_reverse_iterator1 rend1 () const</code></td>
918<td>Returns a <code>const_reverse_iterator1</code> pointing to the
919end of the reversed <code>coordinate_matrix</code>.</td>
920</tr>
921<tr>
922<td><code>reverse_iterator1 rbegin1 ()</code></td>
923<td>Returns a <code>reverse_iterator1</code> pointing to the
924beginning of the reversed <code>coordinate_matrix</code>.</td>
925</tr>
926<tr>
927<td><code>reverse_iterator1 rend1 ()</code></td>
928<td>Returns a <code>reverse_iterator1</code> pointing to the end of
929the reversed <code>coordinate_matrix</code>.</td>
930</tr>
931<tr>
932<td><code>const_reverse_iterator2 rbegin2 () const</code></td>
933<td>Returns a <code>const_reverse_iterator2</code> pointing to the
934beginning of the reversed <code>coordinate_matrix</code>.</td>
935</tr>
936<tr>
937<td><code>const_reverse_iterator2 rend2 () const</code></td>
938<td>Returns a <code>const_reverse_iterator2</code> pointing to the
939end of the reversed <code>coordinate_matrix</code>.</td>
940</tr>
941<tr>
942<td><code>reverse_iterator2 rbegin2 ()</code></td>
943<td>Returns a <code>reverse_iterator2</code> pointing to the
944beginning of the reversed <code>coordinate_matrix</code>.</td>
945</tr>
946<tr>
947<td><code>reverse_iterator2 rend2 ()</code></td>
948<td>Returns a <code>reverse_iterator2</code> pointing to the end of
949the reversed <code>coordinate_matrix</code>.</td>
950</tr>
951</tbody>
952</table>
953<h4>Notes</h4>
954<p><a name="coordinate_matrix_1" id="coordinate_matrix_1">[1]</a>
955Supported parameters for the storage organization are
956<code>row_major</code> and <code>column_major</code>.</p>
957<p><a name="coordinate_matrix_2" id="coordinate_matrix_2">[2]</a>
958Supported parameters for the index base are <code>0</code> and
959<code>1</code> at least.</p>
960<p><a name="coordinate_matrix_3" id="coordinate_matrix_3">[3]</a>
961Supported parameters for the adapted array are
962<code>unbounded_array&lt;&gt;</code> ,
963<code>bounded_array&lt;&gt;</code> and
964<code>std::vector&lt;&gt;</code> .</p>
965<hr />
966<p>Copyright (&copy;) 2000-2002 Joerg Walter, Mathias Koch<br />
967Permission to copy, use, modify, sell and distribute this document
968is granted provided this copyright notice appears in all copies.
969This document is provided ``as is'' without express or implied
970warranty, and with no claim as to its suitability for any
971purpose.</p>
972</body>
973</html>
Note: See TracBrowser for help on using the repository browser.