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