]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | <link rel="stylesheet" href="../../../../boost.css" type="text/css"/> | |
11 | <link rel="stylesheet" href="ublas.css" type="text/css" /> | |
12 | <script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script> | |
13 | <script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script> | |
14 | </head> | |
15 | <body> | |
16 | <h1><img src="../../../../boost.png" align="middle" />Sparse Vector</h1> | |
17 | <div class="toc" id="toc"></div> | |
18 | <h2><a name="mapped_vector"></a>Mapped Vector</h2> | |
19 | <h4>Description</h4> | |
20 | <p>The templated class <code>mapped_vector<T, A></code> is | |
21 | the base container adaptor for sparse vectors using element maps. For a | |
22 | <em>n</em>-dimensional sparse vector and <em>0 <= i < n</em> | |
23 | the non-zero elements <em>v</em><sub><em>i</em></sub> are mapped to | |
24 | consecutive elements of the associative container, i.e. for | |
25 | elements <em>k</em> = | |
26 | <em>v</em><sub><em>i</em></sub><sub><sub><em>1</em></sub></sub>and | |
27 | <em>k + 1 = | |
28 | v</em><sub><em>i</em></sub><sub><sub><em>2</em></sub></sub>of the | |
29 | container holds <em>i</em><sub><em>1</em></sub> <em>< | |
30 | i</em><sub><em>2</em></sub>.</p> | |
31 | <h4>Example</h4> | |
32 | <pre> | |
33 | #include <boost/numeric/ublas/vector_sparse.hpp> | |
34 | #include <boost/numeric/ublas/io.hpp> | |
35 | ||
36 | int main () { | |
37 | using namespace boost::numeric::ublas; | |
38 | mapped_vector<double> v (3, 3); | |
39 | for (unsigned i = 0; i < v.size (); ++ i) | |
40 | v (i) = i; | |
41 | std::cout << v << std::endl; | |
42 | } | |
43 | </pre> | |
44 | <h4>Definition</h4> | |
45 | <p>Defined in the header vector_sparse.hpp.</p> | |
46 | <h4>Template parameters</h4> | |
47 | <table border="1" summary="parameters"> | |
48 | <tbody> | |
49 | <tr> | |
50 | <th>Parameter</th> | |
51 | <th>Description</th> | |
52 | <th>Default</th> | |
53 | </tr> | |
54 | <tr> | |
55 | <td><code>T</code></td> | |
56 | <td>The type of object stored in the mapped vector.</td> | |
57 | <td></td> | |
58 | </tr> | |
59 | <tr> | |
60 | <td><code>A</code></td> | |
61 | <td>The type of the adapted array. <a href= | |
62 | "#mapped_vector_1">[1]</a></td> | |
63 | <td><code>map_std<std::size_t, T></code></td> | |
64 | </tr> | |
65 | </tbody> | |
66 | </table> | |
67 | <h4>Model of</h4> | |
68 | <p><a href="container_concept.html#vector">Vector</a> .</p> | |
69 | <h4>Type requirements</h4> | |
70 | <p>None, except for those imposed by the requirements of <a href= | |
71 | "container_concept.html#vector">Vector</a> .</p> | |
72 | <h4>Public base classes</h4> | |
73 | <p><code>vector_container<mapped_vector<T, A> | |
74 | ></code></p> | |
75 | <h4>Members</h4> | |
76 | <table border="1" summary="members"> | |
77 | <tbody> | |
78 | <tr> | |
79 | <th>Member</th> | |
80 | <th>Description</th> | |
81 | </tr> | |
82 | <tr> | |
83 | <td><code>mapped_vector ()</code></td> | |
84 | <td>Allocates a <code>mapped_vector</code> that holds zero | |
85 | elements.</td> | |
86 | </tr> | |
87 | <tr> | |
88 | <td><code>mapped_vector (size_type size, size_type | |
89 | non_zeros = 0)</code></td> | |
90 | <td>Allocates a <code>mapped_vector</code> that holds at most | |
91 | <code>size</code> elements.</td> | |
92 | </tr> | |
93 | <tr> | |
94 | <td><code>mapped_vector (const mapped_vector &v)</code></td> | |
95 | <td>The copy constructor.</td> | |
96 | </tr> | |
97 | <tr> | |
98 | <td><code>template<class AE><br /> | |
99 | mapped_vector (size_type non_zeros, const | |
100 | vector_expression<AE> &ae)</code></td> | |
101 | <td>The extended copy constructor.</td> | |
102 | </tr> | |
103 | <tr> | |
104 | <td><code>void resize (size_type size, bool | |
105 | preserve = true)</code></td> | |
106 | <td>Reallocates a <code>mapped_vector</code> to hold at most | |
107 | <code>size</code> elements. The existing elements of the | |
108 | <code>mapped_vector</code> are preseved when specified.</td> | |
109 | </tr> | |
110 | <tr> | |
111 | <td><code>size_type size () const</code></td> | |
112 | <td>Returns the size of the <code>mapped_vector</code>.</td> | |
113 | </tr> | |
114 | <tr> | |
115 | <td><code>const_reference operator () (size_type i) | |
116 | const</code></td> | |
117 | <td>Returns the value of the <code>i</code>-th element.</td> | |
118 | </tr> | |
119 | <tr> | |
120 | <td><code>reference operator () (size_type i)</code></td> | |
121 | <td>Returns a reference of the <code>i</code>-th element.</td> | |
122 | </tr> | |
123 | <tr> | |
124 | <td><code>const_reference operator [] (size_type i) | |
125 | const</code></td> | |
126 | <td>Returns the value of the <code>i</code>-th element.</td> | |
127 | </tr> | |
128 | <tr> | |
129 | <td><code>reference operator [] (size_type i)</code></td> | |
130 | <td>Returns a reference of the <code>i</code>-th element.</td> | |
131 | </tr> | |
132 | <tr> | |
133 | <td><code>mapped_vector &operator = (const mapped_vector | |
134 | &v)</code></td> | |
135 | <td>The assignment operator.</td> | |
136 | </tr> | |
137 | <tr> | |
138 | <td><code>mapped_vector &assign_temporary (mapped_vector | |
139 | &v)</code></td> | |
140 | <td>Assigns a temporary. May change the mapped vector | |
141 | <code>v</code> .</td> | |
142 | </tr> | |
143 | <tr> | |
144 | <td><code>template<class AE><br /> | |
145 | mapped_vector &operator = (const vector_expression<AE> | |
146 | &ae)</code></td> | |
147 | <td>The extended assignment operator.</td> | |
148 | </tr> | |
149 | <tr> | |
150 | <td><code>template<class AE><br /> | |
151 | mapped_vector &assign (const vector_expression<AE> | |
152 | &ae)</code></td> | |
153 | <td>Assigns a vector expression to the mapped vector. Left and | |
154 | right hand side of the assignment should be independent.</td> | |
155 | </tr> | |
156 | <tr> | |
157 | <td><code>template<class AE><br /> | |
158 | mapped_vector &operator += (const vector_expression<AE> | |
159 | &ae)</code></td> | |
160 | <td>A computed assignment operator. Adds the vector expression to | |
161 | the mapped vector.</td> | |
162 | </tr> | |
163 | <tr> | |
164 | <td><code>template<class AE><br /> | |
165 | mapped_vector &plus_assign (const vector_expression<AE> | |
166 | &ae)</code></td> | |
167 | <td>Adds a vector expression to the mapped vector. Left and right | |
168 | hand side of the assignment should be independent.</td> | |
169 | </tr> | |
170 | <tr> | |
171 | <td><code>template<class AE><br /> | |
172 | mapped_vector &operator -= (const vector_expression<AE> | |
173 | &ae)</code></td> | |
174 | <td>A computed assignment operator. Subtracts the vector expression | |
175 | from the mapped vector.</td> | |
176 | </tr> | |
177 | <tr> | |
178 | <td><code>template<class AE><br /> | |
179 | mapped_vector &minus_assign (const vector_expression<AE> | |
180 | &ae)</code></td> | |
181 | <td>Subtracts a vector expression from the mapped vector. Left and | |
182 | right hand side of the assignment should be independent.</td> | |
183 | </tr> | |
184 | <tr> | |
185 | <td><code>template<class AT><br /> | |
186 | mapped_vector &operator *= (const AT &at)</code></td> | |
187 | <td>A computed assignment operator. Multiplies the mapped vector | |
188 | with a scalar.</td> | |
189 | </tr> | |
190 | <tr> | |
191 | <td><code>template<class AT><br /> | |
192 | mapped_vector &operator /= (const AT &at)</code></td> | |
193 | <td>A computed assignment operator. Divides the mapped vector | |
194 | through a scalar.</td> | |
195 | </tr> | |
196 | <tr> | |
197 | <td><code>void swap (mapped_vector &v)</code></td> | |
198 | <td>Swaps the contents of the mapped vectors.</td> | |
199 | </tr> | |
200 | <tr> | |
201 | <td><code>true_reference insert_element (size_type i, const_reference t)</code></td> | |
202 | <td>Inserts the value <code>t</code> at the <code>i</code>-th | |
203 | element. Duplicates elements are not allowed.</td> | |
204 | </tr> | |
205 | <tr> | |
206 | <td><code>void erase_element (size_type i)</code></td> | |
207 | <td>Erases the value at the <code>i</code>-th element.</td> | |
208 | </tr> | |
209 | <tr> | |
210 | <td><code>void clear ()</code></td> | |
211 | <td>Clears the mapped vector.</td> | |
212 | </tr> | |
213 | <tr> | |
214 | <td><code>const_iterator begin () const</code></td> | |
215 | <td>Returns a <code>const_iterator</code> pointing to the beginning | |
216 | of the <code>mapped_vector</code>.</td> | |
217 | </tr> | |
218 | <tr> | |
219 | <td><code>const_iterator end () const</code></td> | |
220 | <td>Returns a <code>const_iterator</code> pointing to the end of | |
221 | the <code>mapped_vector</code>.</td> | |
222 | </tr> | |
223 | <tr> | |
224 | <td><code>iterator begin ()</code></td> | |
225 | <td>Returns a <code>iterator</code> pointing to the beginning of | |
226 | the <code>mapped_vector</code>.</td> | |
227 | </tr> | |
228 | <tr> | |
229 | <td><code>iterator end ()</code></td> | |
230 | <td>Returns a <code>iterator</code> pointing to the end of the | |
231 | <code>mapped_vector</code>.</td> | |
232 | </tr> | |
233 | <tr> | |
234 | <td><code>const_reverse_iterator rbegin () const</code></td> | |
235 | <td>Returns a <code>const_reverse_iterator</code> pointing to the | |
236 | beginning of the reversed <code>mapped_vector</code>.</td> | |
237 | </tr> | |
238 | <tr> | |
239 | <td><code>const_reverse_iterator rend () const</code></td> | |
240 | <td>Returns a <code>const_reverse_iterator</code> pointing to the | |
241 | end of the reversed <code>mapped_vector</code>.</td> | |
242 | </tr> | |
243 | <tr> | |
244 | <td><code>reverse_iterator rbegin ()</code></td> | |
245 | <td>Returns a <code>reverse_iterator</code> pointing to the | |
246 | beginning of the reversed <code>mapped_vector</code>.</td> | |
247 | </tr> | |
248 | <tr> | |
249 | <td><code>reverse_iterator rend ()</code></td> | |
250 | <td>Returns a <code>reverse_iterator</code> pointing to the end of | |
251 | the reversed <code>mapped_vector</code>.</td> | |
252 | </tr> | |
253 | </tbody> | |
254 | </table> | |
255 | <h4>Notes</h4> | |
256 | <p><a name="mapped_vector_1">[1]</a> Supported | |
257 | parameters for the adapted array are | |
258 | <code>map_array<std::size_t, T></code> and | |
259 | <code>map_std<std::size_t, T></code>. The latter is | |
260 | equivalent to <code>std::map<std::size_t, T></code>.</p> | |
261 | <h2><a name="compressed_vector"></a>Compressed Vector</h2> | |
262 | <h4>Description</h4> | |
263 | <p>The templated class <code>compressed_vector<T, IB, IA, | |
264 | TA></code> is the base container adaptor for compressed vectors. | |
265 | For a <em>n</em>-dimensional compressed vector and <em>0 <= i | |
266 | < n</em> the non-zero elements <em>v</em><sub><em>i</em></sub> | |
267 | are mapped to consecutive elements of the index and value | |
268 | container, i.e. for elements <em>k</em> = | |
269 | <em>v</em><sub><em>i</em></sub><sub><sub><em>1</em></sub></sub>and | |
270 | <em>k + 1 = | |
271 | v</em><sub><em>i</em></sub><sub><sub><em>2</em></sub></sub>of these | |
272 | containers holds <em>i</em><sub><em>1</em></sub> <em>< | |
273 | i</em><sub><em>2</em></sub>.</p> | |
274 | <h4>Example</h4> | |
275 | <pre> | |
276 | #include <boost/numeric/ublas/vector_sparse.hpp> | |
277 | #include <boost/numeric/ublas/io.hpp> | |
278 | ||
279 | int main () { | |
280 | using namespace boost::numeric::ublas; | |
281 | compressed_vector<double> v (3, 3); | |
282 | for (unsigned i = 0; i < v.size (); ++ i) | |
283 | v (i) = i; | |
284 | std::cout << v << std::endl; | |
285 | } | |
286 | </pre> | |
287 | <h4>Definition</h4> | |
288 | <p>Defined in the header vector_sparse.hpp.</p> | |
289 | <h4>Template parameters</h4> | |
290 | <table border="1" summary="parameters"> | |
291 | <tbody> | |
292 | <tr> | |
293 | <th>Parameter</th> | |
294 | <th>Description</th> | |
295 | <th>Default</th> | |
296 | </tr> | |
297 | <tr> | |
298 | <td><code>T</code></td> | |
299 | <td>The type of object stored in the compressed vector.</td> | |
300 | <td></td> | |
301 | </tr> | |
302 | <tr> | |
303 | <td><code>IB</code></td> | |
304 | <td>The index base of the compressed vector. <a href= | |
305 | "#compressed_vector_1">[1]</a></td> | |
306 | <td><code>0</code></td> | |
307 | </tr> | |
308 | <tr> | |
309 | <td><code>IA</code></td> | |
310 | <td>The type of the adapted array for indices. <a href= | |
311 | "#compressed_vector_2">[2]</a></td> | |
312 | <td><code>unbounded_array<std::size_t></code></td> | |
313 | </tr> | |
314 | <tr> | |
315 | <td><code>TA</code></td> | |
316 | <td>The type of the adapted array for values. <a href= | |
317 | "#compressed_vector_2">[2]</a></td> | |
318 | <td><code>unbounded_array<T></code></td> | |
319 | </tr> | |
320 | </tbody> | |
321 | </table> | |
322 | <h4>Model of</h4> | |
323 | <p><a href="container_concept.html#vector">Vector</a> .</p> | |
324 | <h4>Type requirements</h4> | |
325 | <p>None, except for those imposed by the requirements of <a href= | |
326 | "container_concept.html#vector">Vector</a> .</p> | |
327 | <h4>Public base classes</h4> | |
328 | <p><code>vector_container<compressed_vector<T, IB, IA, | |
329 | TA> ></code></p> | |
330 | <h4>Members</h4> | |
331 | <table border="1" summary="members"> | |
332 | <tbody> | |
333 | <tr> | |
334 | <th>Member</th> | |
335 | <th>Description</th> | |
336 | </tr> | |
337 | <tr> | |
338 | <td><code>compressed_vector ()</code></td> | |
339 | <td>Allocates a <code>compressed_vector</code> that holds zero | |
340 | elements.</td> | |
341 | </tr> | |
342 | <tr> | |
343 | <td><code>compressed_vector (size_type size, size_type | |
344 | non_zeros)</code></td> | |
345 | <td>Allocates a <code>compressed_vector</code> that holds at most | |
346 | <code>size</code> elements.</td> | |
347 | </tr> | |
348 | <tr> | |
349 | <td><code>compressed_vector (const compressed_vector | |
350 | &v)</code></td> | |
351 | <td>The copy constructor.</td> | |
352 | </tr> | |
353 | <tr> | |
354 | <td><code>template<class AE><br /> | |
355 | compressed_vector (size_type non_zeros, const | |
356 | vector_expression<AE> &ae)</code></td> | |
357 | <td>The extended copy constructor.</td> | |
358 | </tr> | |
359 | <tr> | |
360 | <td><code>void resize (size_type size, bool | |
361 | preserve = true)</code></td> | |
362 | <td>Reallocates a <code>compressed_vector</code> to hold at most | |
363 | <code>size</code> elements. The existing elements of the | |
364 | <code>compress_vector</code> are preseved when specified.</td> | |
365 | </tr> | |
366 | <tr> | |
367 | <td><code>size_type size () const</code></td> | |
368 | <td>Returns the size of the <code>compressed_vector</code>.</td> | |
369 | </tr> | |
370 | <tr> | |
371 | <td><code>const_reference operator () (size_type i) | |
372 | const</code></td> | |
373 | <td>Returns the value of the <code>i</code>-th element.</td> | |
374 | </tr> | |
375 | <tr> | |
376 | <td><code>reference operator () (size_type i)</code></td> | |
377 | <td>Returns a reference of the <code>i</code>-th element.</td> | |
378 | </tr> | |
379 | <tr> | |
380 | <td><code>const_reference operator [] (size_type i) | |
381 | const</code></td> | |
382 | <td>Returns the value of the <code>i</code>-th element.</td> | |
383 | </tr> | |
384 | <tr> | |
385 | <td><code>reference operator [] (size_type i)</code></td> | |
386 | <td>Returns a reference of the <code>i</code>-th element.</td> | |
387 | </tr> | |
388 | <tr> | |
389 | <td><code>compressed_vector &operator = (const | |
390 | compressed_vector &v)</code></td> | |
391 | <td>The assignment operator.</td> | |
392 | </tr> | |
393 | <tr> | |
394 | <td><code>compressed_vector &assign_temporary | |
395 | (compressed_vector &v)</code></td> | |
396 | <td>Assigns a temporary. May change the compressed vector | |
397 | <code>v</code>.</td> | |
398 | </tr> | |
399 | <tr> | |
400 | <td><code>template<class AE><br /> | |
401 | compressed_vector &operator = (const | |
402 | vector_expression<AE> &ae)</code></td> | |
403 | <td>The extended assignment operator.</td> | |
404 | </tr> | |
405 | <tr> | |
406 | <td><code>template<class AE><br /> | |
407 | compressed_vector &assign (const vector_expression<AE> | |
408 | &ae)</code></td> | |
409 | <td>Assigns a vector expression to the compressed vector. Left and | |
410 | right hand side of the assignment should be independent.</td> | |
411 | </tr> | |
412 | <tr> | |
413 | <td><code>template<class AE><br /> | |
414 | compressed_vector &operator += (const | |
415 | vector_expression<AE> &ae)</code></td> | |
416 | <td>A computed assignment operator. Adds the vector expression to | |
417 | the compressed vector.</td> | |
418 | </tr> | |
419 | <tr> | |
420 | <td><code>template<class AE><br /> | |
421 | compressed_vector &plus_assign (const | |
422 | vector_expression<AE> &ae)</code></td> | |
423 | <td>Adds a vector expression to the compressed vector. Left and | |
424 | right hand side of the assignment should be independent.</td> | |
425 | </tr> | |
426 | <tr> | |
427 | <td><code>template<class AE><br /> | |
428 | compressed_vector &operator -= (const | |
429 | vector_expression<AE> &ae)</code></td> | |
430 | <td>A computed assignment operator. Subtracts the vector expression | |
431 | from the compressed vector.</td> | |
432 | </tr> | |
433 | <tr> | |
434 | <td><code>template<class AE><br /> | |
435 | compressed_vector &minus_assign (const | |
436 | vector_expression<AE> &ae)</code></td> | |
437 | <td>Subtracts a vector expression from the compressed vector. Left | |
438 | and right hand side of the assignment should be independent.</td> | |
439 | </tr> | |
440 | <tr> | |
441 | <td><code>template<class AT><br /> | |
442 | compressed_vector &operator *= (const AT &at)</code></td> | |
443 | <td>A computed assignment operator. Multiplies the compressed | |
444 | vector with a scalar.</td> | |
445 | </tr> | |
446 | <tr> | |
447 | <td><code>template<class AT><br /> | |
448 | compressed_vector &operator /= (const AT &at)</code></td> | |
449 | <td>A computed assignment operator. Divides the compressed vector | |
450 | through a scalar.</td> | |
451 | </tr> | |
452 | <tr> | |
453 | <td><code>void swap (compressed_vector &v)</code></td> | |
454 | <td>Swaps the contents of the compressed vectors.</td> | |
455 | </tr> | |
456 | <tr> | |
457 | <td><code>true_reference insert_element (size_type i, const_reference t)</code></td> | |
458 | <td>Inserts the value <code>t</code> at the <code>i</code>-th | |
459 | element. Duplicates elements are not allowed.</td> | |
460 | </tr> | |
461 | <tr> | |
462 | <td><code>void erase_element (size_type i)</code></td> | |
463 | <td>Erases the value at the <code>i</code>-th element.</td> | |
464 | </tr> | |
465 | <tr> | |
466 | <td><code>void clear ()</code></td> | |
467 | <td>Clears the compressed vector.</td> | |
468 | </tr> | |
469 | <tr> | |
470 | <td><code>const_iterator begin () const</code></td> | |
471 | <td>Returns a <code>const_iterator</code> pointing to the beginning | |
472 | of the <code>compressed_vector</code>.</td> | |
473 | </tr> | |
474 | <tr> | |
475 | <td><code>const_iterator end () const</code></td> | |
476 | <td>Returns a <code>const_iterator</code> pointing to the end of | |
477 | the <code>compressed_vector</code>.</td> | |
478 | </tr> | |
479 | <tr> | |
480 | <td><code>iterator begin ()</code></td> | |
481 | <td>Returns a <code>iterator</code> pointing to the beginning of | |
482 | the <code>compressed_vector</code>.</td> | |
483 | </tr> | |
484 | <tr> | |
485 | <td><code>iterator end ()</code></td> | |
486 | <td>Returns a <code>iterator</code> pointing to the end of the | |
487 | <code>compressed_vector</code>.</td> | |
488 | </tr> | |
489 | <tr> | |
490 | <td><code>const_reverse_iterator rbegin () const</code></td> | |
491 | <td>Returns a <code>const_reverse_iterator</code> pointing to the | |
492 | beginning of the reversed <code>compressed_vector</code>.</td> | |
493 | </tr> | |
494 | <tr> | |
495 | <td><code>const_reverse_iterator rend () const</code></td> | |
496 | <td>Returns a <code>const_reverse_iterator</code> pointing to the | |
497 | end of the reversed <code>compressed_vector</code>.</td> | |
498 | </tr> | |
499 | <tr> | |
500 | <td><code>reverse_iterator rbegin ()</code></td> | |
501 | <td>Returns a <code>reverse_iterator</code> pointing to the | |
502 | beginning of the reversed <code>compressed_vector</code>.</td> | |
503 | </tr> | |
504 | <tr> | |
505 | <td><code>reverse_iterator rend ()</code></td> | |
506 | <td>Returns a <code>reverse_iterator</code> pointing to the end of | |
507 | the reversed <code>compressed_vector</code>.</td> | |
508 | </tr> | |
509 | </tbody> | |
510 | </table> | |
511 | <h4>Notes</h4> | |
512 | <p><a name="compressed_vector_1">[1]</a> | |
513 | Supported parameters for the index base are <code>0</code> and | |
514 | <code>1</code> at least.</p> | |
515 | <p><a name="compressed_vector_2">[2]</a> | |
516 | Supported parameters for the adapted array are | |
517 | <code>unbounded_array<></code> , | |
518 | <code>bounded_array<></code> and | |
519 | <code>std::vector<></code> .</p> | |
520 | <h2><a name="coordinate_vector"></a>Coordinate Vector</h2> | |
521 | <h4>Description</h4> | |
522 | <p>The templated class <code>coordinate_vector<T, IB, IA, | |
523 | TA></code> is the base container adaptor for compressed vectors. | |
524 | For a <em>n</em>-dimensional sorted coordinate vector and <em>0 | |
525 | <= i < n</em> the non-zero elements | |
526 | <em>v</em><sub><em>i</em></sub> are mapped to consecutive elements | |
527 | of the index and value container, i.e. for elements <em>k</em> = | |
528 | <em>v</em><sub><em>i</em></sub><sub><sub><em>1</em></sub></sub>and | |
529 | <em>k + 1 = | |
530 | v</em><sub><em>i</em></sub><sub><sub><em>2</em></sub></sub>of these | |
531 | containers holds <em>i</em><sub><em>1</em></sub> <em>< | |
532 | i</em><sub><em>2</em></sub>.</p> | |
533 | <h4>Example</h4> | |
534 | <pre> | |
535 | #include <boost/numeric/ublas/vector_sparse.hpp> | |
536 | #include <boost/numeric/ublas/io.hpp> | |
537 | ||
538 | int main () { | |
539 | using namespace boost::numeric::ublas; | |
540 | coordinate_vector<double> v (3, 3); | |
541 | for (unsigned i = 0; i < v.size (); ++ i) | |
542 | v (i) = i; | |
543 | std::cout << v << std::endl; | |
544 | } | |
545 | </pre> | |
546 | <h4>Definition</h4> | |
547 | <p>Defined in the header vector_sparse.hpp.</p> | |
548 | <h4>Template parameters</h4> | |
549 | <table border="1" summary="parameters"> | |
550 | <tbody> | |
551 | <tr> | |
552 | <th>Parameter</th> | |
553 | <th>Description</th> | |
554 | <th>Default</th> | |
555 | </tr> | |
556 | <tr> | |
557 | <td><code>T</code></td> | |
558 | <td>The type of object stored in the coordinate vector.</td> | |
559 | <td></td> | |
560 | </tr> | |
561 | <tr> | |
562 | <td><code>IB</code></td> | |
563 | <td>The index base of the coordinate vector. <a href= | |
564 | "#coordinate_vector_1">[1]</a></td> | |
565 | <td><code>0</code></td> | |
566 | </tr> | |
567 | <tr> | |
568 | <td><code>IA</code></td> | |
569 | <td>The type of the adapted array for indices. <a href= | |
570 | "#coordinate_vector_2">[2]</a></td> | |
571 | <td><code>unbounded_array<std::size_t></code></td> | |
572 | </tr> | |
573 | <tr> | |
574 | <td><code>TA</code></td> | |
575 | <td>The type of the adapted array for values. <a href= | |
576 | "#coordinate_vector_2">[2]</a></td> | |
577 | <td><code>unbounded_array<T></code></td> | |
578 | </tr> | |
579 | </tbody> | |
580 | </table> | |
581 | <h4>Model of</h4> | |
582 | <p><a href="container_concept.html#vector">Vector</a> .</p> | |
583 | <h4>Type requirements</h4> | |
584 | <p>None, except for those imposed by the requirements of <a href= | |
585 | "container_concept.html#vector">Vector</a> .</p> | |
586 | <h4>Public base classes</h4> | |
587 | <p><code>vector_container<coordinate_vector<T, IB, IA, | |
588 | TA> ></code></p> | |
589 | <h4>Members</h4> | |
590 | <table border="1" summary="members"> | |
591 | <tbody> | |
592 | <tr> | |
593 | <th>Member</th> | |
594 | <th>Description</th> | |
595 | </tr> | |
596 | <tr> | |
597 | <td><code>coordinate_vector ()</code></td> | |
598 | <td>Allocates a <code>coordinate_vector</code> that holds zero | |
599 | elements.</td> | |
600 | </tr> | |
601 | <tr> | |
602 | <td><code>coordinate_vector (size_type size, size_type | |
603 | non_zeros)</code></td> | |
604 | <td>Allocates a <code>coordinate_vector</code> that holds at most | |
605 | <code>size</code> elements.</td> | |
606 | </tr> | |
607 | <tr> | |
608 | <td><code>coordinate_vector (const coordinate_vector | |
609 | &v)</code></td> | |
610 | <td>The copy constructor.</td> | |
611 | </tr> | |
612 | <tr> | |
613 | <td><code>template<class AE><br /> | |
614 | coordinate_vector (size_type non_zeros, const | |
615 | vector_expression<AE> &ae)</code></td> | |
616 | <td>The extended copy constructor.</td> | |
617 | </tr> | |
618 | <tr> | |
619 | <td><code>void resize (size_type size, bool | |
620 | preserve = true)</code></td> | |
621 | <td>Reallocates a <code>coordinate_vector</code> to hold at most | |
622 | <code>size</code> elements. The existing elements of the | |
623 | <code>coordinate_vector</code> are preseved when specified.</td> | |
624 | </tr> | |
625 | <tr> | |
626 | <td><code>size_type size () const</code></td> | |
627 | <td>Returns the size of the <code>coordinate_vector</code>.</td> | |
628 | </tr> | |
629 | <tr> | |
630 | <td><code>const_reference operator () (size_type i) | |
631 | const</code></td> | |
632 | <td>Returns the value of the <code>i</code>-th element.</td> | |
633 | </tr> | |
634 | <tr> | |
635 | <td><code>reference operator () (size_type i)</code></td> | |
636 | <td>Returns a reference of the <code>i</code>-th element.</td> | |
637 | </tr> | |
638 | <tr> | |
639 | <td><code>const_reference operator [] (size_type i) | |
640 | const</code></td> | |
641 | <td>Returns the value of the <code>i</code>-th element.</td> | |
642 | </tr> | |
643 | <tr> | |
644 | <td><code>reference operator [] (size_type i)</code></td> | |
645 | <td>Returns a reference of the <code>i</code>-th element.</td> | |
646 | </tr> | |
647 | <tr> | |
648 | <td><code>coordinate_vector &operator = (const | |
649 | coordinate_vector &v)</code></td> | |
650 | <td>The assignment operator.</td> | |
651 | </tr> | |
652 | <tr> | |
653 | <td><code>coordinate_vector &assign_temporary | |
654 | (coordinate_vector &v)</code></td> | |
655 | <td>Assigns a temporary. May change the coordinate vector | |
656 | <code>v</code>.</td> | |
657 | </tr> | |
658 | <tr> | |
659 | <td><code>template<class AE><br /> | |
660 | coordinate_vector &operator = (const | |
661 | vector_expression<AE> &ae)</code></td> | |
662 | <td>The extended assignment operator.</td> | |
663 | </tr> | |
664 | <tr> | |
665 | <td><code>template<class AE><br /> | |
666 | coordinate_vector &assign (const vector_expression<AE> | |
667 | &ae)</code></td> | |
668 | <td>Assigns a vector expression to the coordinate vector. Left and | |
669 | right hand side of the assignment should be independent.</td> | |
670 | </tr> | |
671 | <tr> | |
672 | <td><code>template<class AE><br /> | |
673 | coordinate_vector &operator += (const | |
674 | vector_expression<AE> &ae)</code></td> | |
675 | <td>A computed assignment operator. Adds the vector expression to | |
676 | the coordinate vector.</td> | |
677 | </tr> | |
678 | <tr> | |
679 | <td><code>template<class AE><br /> | |
680 | coordinate_vector &plus_assign (const | |
681 | vector_expression<AE> &ae)</code></td> | |
682 | <td>Adds a vector expression to the coordinate vector. Left and | |
683 | right hand side of the assignment should be independent.</td> | |
684 | </tr> | |
685 | <tr> | |
686 | <td><code>template<class AE><br /> | |
687 | coordinate_vector &operator -= (const | |
688 | vector_expression<AE> &ae)</code></td> | |
689 | <td>A computed assignment operator. Subtracts the vector expression | |
690 | from the coordinate vector.</td> | |
691 | </tr> | |
692 | <tr> | |
693 | <td><code>template<class AE><br /> | |
694 | coordinate_vector &minus_assign (const | |
695 | vector_expression<AE> &ae)</code></td> | |
696 | <td>Subtracts a vector expression from the coordinate vector. Left | |
697 | and right hand side of the assignment should be independent.</td> | |
698 | </tr> | |
699 | <tr> | |
700 | <td><code>template<class AT><br /> | |
701 | coordinate_vector &operator *= (const AT &at)</code></td> | |
702 | <td>A computed assignment operator. Multiplies the coordinate | |
703 | vector with a scalar.</td> | |
704 | </tr> | |
705 | <tr> | |
706 | <td><code>template<class AT><br /> | |
707 | coordinate_vector &operator /= (const AT &at)</code></td> | |
708 | <td>A computed assignment operator. Divides the coordinate vector | |
709 | through a scalar.</td> | |
710 | </tr> | |
711 | <tr> | |
712 | <td><code>void swap (coordinate_vector &v)</code></td> | |
713 | <td>Swaps the contents of the coordinate vectors.</td> | |
714 | </tr> | |
715 | <tr> | |
716 | <td><code>true_reference insert_element (size_type i, const_reference t)</code></td> | |
717 | <td>Inserts the value <code>t</code> at the <code>i</code>-th | |
718 | element. Duplicates elements are not allowed.</td> | |
719 | </tr> | |
720 | <tr> | |
721 | <td><code>void append_element (size_type i, size_type j, const_reference t)</code></td> | |
722 | <td>Appends the value <code>t</code> at the <code>i</code>-th element. | |
723 | Duplicate elements can be appended to a <code>coordinate_vector</code>. They are merged into a single | |
724 | arithmetically summed element by the <code>sort</code> function.</td> | |
725 | </tr> | |
726 | <tr> | |
727 | <td><code>void erase_element (size_type i)</code></td> | |
728 | <td>Erases the value at the <code>i</code>-th element.</td> | |
729 | </tr> | |
730 | <tr> | |
731 | <td><code>void clear ()</code></td> | |
732 | <td>Clears the coordinate vector.</td> | |
733 | </tr> | |
734 | <tr> | |
735 | <td><code>const_iterator begin () const</code></td> | |
736 | <td>Returns a <code>const_iterator</code> pointing to the beginning | |
737 | of the <code>coordinate_vector</code>.</td> | |
738 | </tr> | |
739 | <tr> | |
740 | <td><code>const_iterator end () const</code></td> | |
741 | <td>Returns a <code>const_iterator</code> pointing to the end of | |
742 | the <code>coordinate_vector</code>.</td> | |
743 | </tr> | |
744 | <tr> | |
745 | <td><code>iterator begin ()</code></td> | |
746 | <td>Returns a <code>iterator</code> pointing to the beginning of | |
747 | the <code>coordinate_vector</code>.</td> | |
748 | </tr> | |
749 | <tr> | |
750 | <td><code>iterator end ()</code></td> | |
751 | <td>Returns a <code>iterator</code> pointing to the end of the | |
752 | <code>coordinate_vector</code>.</td> | |
753 | </tr> | |
754 | <tr> | |
755 | <td><code>const_reverse_iterator rbegin () const</code></td> | |
756 | <td>Returns a <code>const_reverse_iterator</code> pointing to the | |
757 | beginning of the reversed <code>coordinate_vector</code>.</td> | |
758 | </tr> | |
759 | <tr> | |
760 | <td><code>const_reverse_iterator rend () const</code></td> | |
761 | <td>Returns a <code>const_reverse_iterator</code> pointing to the | |
762 | end of the reversed <code>coordinate_vector</code>.</td> | |
763 | </tr> | |
764 | <tr> | |
765 | <td><code>reverse_iterator rbegin ()</code></td> | |
766 | <td>Returns a <code>reverse_iterator</code> pointing to the | |
767 | beginning of the reversed <code>coordinate_vector</code>.</td> | |
768 | </tr> | |
769 | <tr> | |
770 | <td><code>reverse_iterator rend ()</code></td> | |
771 | <td>Returns a <code>reverse_iterator</code> pointing to the end of | |
772 | the reversed <code>coordinate_vector</code>.</td> | |
773 | </tr> | |
774 | </tbody> | |
775 | </table> | |
776 | <h4>Notes</h4> | |
777 | <p><a name="coordinate_vector_1">[1]</a> | |
778 | Supported parameters for the index base are <code>0</code> and | |
779 | <code>1</code> at least.</p> | |
780 | <p><a name="coordinate_vector_2">[2]</a> | |
781 | Supported parameters for the adapted array are | |
782 | <code>unbounded_array<></code> , | |
783 | <code>bounded_array<></code> and | |
784 | <code>std::vector<></code> .</p> | |
785 | <hr /> | |
786 | <p>Copyright (©) 2000-2002 Joerg Walter, Mathias Koch<br /> | |
787 | Use, modification and distribution are subject to the | |
788 | Boost Software License, Version 1.0. | |
789 | (See accompanying file LICENSE_1_0.txt | |
790 | or copy at <a href="http://www.boost.org/LICENSE_1_0.txt"> | |
791 | http://www.boost.org/LICENSE_1_0.txt | |
792 | </a>). | |
793 | </p> | |
794 | <script type="text/javascript"> | |
795 | (function($) { | |
796 | $('#toc').toc(); | |
797 | })(jQuery); | |
798 | </script> | |
799 | </body> | |
800 | </html> |