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>Container Concepts</title> |
---|
11 | </head> |
---|
12 | <body> |
---|
13 | <h1><img src="../../../../boost.png" align="middle" /> |
---|
14 | Container Concepts</h1> |
---|
15 | <h2><a name="vector" id="vector"></a>Vector</h2> |
---|
16 | <h4>Description</h4> |
---|
17 | <p>A Vector describes common aspects of dense, packed and sparse |
---|
18 | vectors.</p> |
---|
19 | <h4>Refinement of</h4> |
---|
20 | <p><a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a>, |
---|
21 | <a href="http://www.sgi.com/tech/stl/RandomAccessContainer.html">RandomAccessContainer</a> and |
---|
22 | <a href="expression_concept.htm#vector_expression">Vector Expression</a> |
---|
23 | <a href="#vector_expression_note">[1]</a>.</p> |
---|
24 | <h4>Associated types</h4> |
---|
25 | <p>In addition to the types defined by <a href="http://www.sgi.com/tech/stl/RandomAccessContainer.html">RandomAccessContainer</a> and <a href="expression_concept.htm#vector_expression">Vector Expression</a></p> |
---|
26 | <table border="1" summary="types"> |
---|
27 | <tbody> |
---|
28 | <tr> |
---|
29 | <td>Public base</td> |
---|
30 | <td>vector_container<V></td> |
---|
31 | <td>V must be derived from this public base type.</td> |
---|
32 | </tr> |
---|
33 | <tr> |
---|
34 | <td>Storage array</td> |
---|
35 | <td>V::array_type</td> |
---|
36 | <td> |
---|
37 | Dense Vector ONLY. The type of underlying storage array used to store the elements. The array_type must model the |
---|
38 | <a href="storage_concept.htm"><b>Storage</b></a> concept.</td> |
---|
39 | </tr> |
---|
40 | </tbody> |
---|
41 | </table> |
---|
42 | <h4>Notation</h4> |
---|
43 | <table border="0" summary="notation"> |
---|
44 | <tbody> |
---|
45 | <tr> |
---|
46 | <td><code>V</code></td> |
---|
47 | <td>A type that is a model of Vector</td> |
---|
48 | </tr> |
---|
49 | <tr> |
---|
50 | <td><code>v</code></td> |
---|
51 | <td>Objects of type <code>V</code></td> |
---|
52 | </tr> |
---|
53 | <tr> |
---|
54 | <td><code>n, i</code></td> |
---|
55 | <td>Objects of a type convertible to <code>size_type</code></td> |
---|
56 | </tr> |
---|
57 | <tr> |
---|
58 | <td><code>t</code></td> |
---|
59 | <td>Object of a type convertible to <code>value_type</code></td> |
---|
60 | </tr> |
---|
61 | <tr> |
---|
62 | <td><code>p</code></td> |
---|
63 | <td>Object of a type convertible to <code>bool</code></td> |
---|
64 | </tr> |
---|
65 | </tbody> |
---|
66 | </table> |
---|
67 | <h4>Definitions</h4> |
---|
68 | <h4>Valid expressions</h4> |
---|
69 | <p>In addition to the expressions defined in <a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a>, |
---|
70 | <a href="http://www.sgi.com/tech/stl/RandomAccessContainer.html">RandomAccessContainer</a> and |
---|
71 | <a href="expression_concept.htm#vector_expression">Vector Expression</a> the following expressions must be valid.</p> |
---|
72 | <table border="1" summary="expressions"> |
---|
73 | <tbody> |
---|
74 | <tr> |
---|
75 | <th>Name</th> |
---|
76 | <th>Expression</th> |
---|
77 | <th>Type requirements</th> |
---|
78 | <th>Return type</th> |
---|
79 | </tr> |
---|
80 | <tr> |
---|
81 | <td>Sizing constructor</td> |
---|
82 | <td><code>V v (n)</code></td> |
---|
83 | <td> </td> |
---|
84 | <td><code>V</code></td> |
---|
85 | </tr> |
---|
86 | <tr> |
---|
87 | <td>Insert</td> |
---|
88 | <td><code>v.insert_element (i, t)</code></td> |
---|
89 | <td><code>v</code> is mutable.</td> |
---|
90 | <td><code>void</code></td> |
---|
91 | </tr> |
---|
92 | <tr> |
---|
93 | <td>Erase</td> |
---|
94 | <td><code>v.erase_element (i)</code></td> |
---|
95 | <td><code>v</code> is mutable.</td> |
---|
96 | <td><code>void</code></td> |
---|
97 | </tr> |
---|
98 | <tr> |
---|
99 | <td>Clear</td> |
---|
100 | <td><code>v.clear ()</code></td> |
---|
101 | <td><code>v</code> is mutable.</td> |
---|
102 | <td><code>void</code></td> |
---|
103 | </tr> |
---|
104 | <tr> |
---|
105 | <td>Resize</td> |
---|
106 | <td><code>v.resize (n)</code><br /> |
---|
107 | <code>v.resize (n, p)</code></td> |
---|
108 | <td><code>v</code> is mutable.</td> |
---|
109 | <td><code>void</code></td> |
---|
110 | </tr> |
---|
111 | <tr> |
---|
112 | <td>Storage</td> |
---|
113 | <td><code>v.data()</code></td> |
---|
114 | <td><code>v</code> is mutable and Dense.</td> |
---|
115 | <td><code>array_type&</code> if a is mutable, <code>const array_type&</code> otherwise</td> |
---|
116 | </tr> |
---|
117 | </tbody> |
---|
118 | </table> |
---|
119 | <h4>Expression semantics</h4> |
---|
120 | <p>Semantics of an expression is defined only where it differs |
---|
121 | from, or is not defined in <a href= |
---|
122 | "expression_concept.htm#vector_expression">Vector Expression</a> .</p> |
---|
123 | <table border="1" summary="semantics"> |
---|
124 | <tr> |
---|
125 | <th>Name</th> |
---|
126 | <th>Expression</th> |
---|
127 | <th>Precondition</th> |
---|
128 | <th>Semantics</th> |
---|
129 | <th>Postcondition</th> |
---|
130 | </tr> |
---|
131 | <tr> |
---|
132 | <td>Sizing constructor</td> |
---|
133 | <td><code>V v (n)</code></td> |
---|
134 | <td><code>n >= 0</code></td> |
---|
135 | <td>Allocates a vector of<code>n</code> elements.</td> |
---|
136 | <td><code>v.size () == n</code>.</td> |
---|
137 | </tr> |
---|
138 | <tr> |
---|
139 | <td>Element access <a href="#element_access_note">[2]</a></td> |
---|
140 | <td><code>v[n]</code></td> |
---|
141 | <td><code>0<n>v.size()</code></td> |
---|
142 | <td>returns the n-th element in v</td> |
---|
143 | <td> </td> |
---|
144 | </tr> |
---|
145 | <tr> |
---|
146 | <td>Insert</td> |
---|
147 | <td><code>v.insert_element (i, t)</code></td> |
---|
148 | <td><code>0 <= i < v.size ()</code>.</td> |
---|
149 | <td>Inserts an element at <code>v (i)</code> with value <code>t</code>. |
---|
150 | The storage requirement of the Vector may be increased.</td> |
---|
151 | <td><code>v (i)</code> is equal to <code>t</code>.</td> |
---|
152 | </tr> |
---|
153 | <tr> |
---|
154 | <td>Erase</td> |
---|
155 | <td><code>v.erase_element (i)</code></td> |
---|
156 | <td><code>0 <= i < v.size ()</code></td> |
---|
157 | <td>Destroys the element as <code>v (i)</code> and replaces it with the default |
---|
158 | <code>value_type ()</code>. |
---|
159 | The storage requirement of the Vector may be decreased.</td> |
---|
160 | <td><code>v (i)</code> is equal to <code>value_type ()</code>.</td> |
---|
161 | </tr> |
---|
162 | <tr> |
---|
163 | <td>Clear</td> |
---|
164 | <td><code>v.clear ()</code></td> |
---|
165 | <td> </td> |
---|
166 | <td>Equivalent to<br /> |
---|
167 | <code>for (i = 0; i < v.size (); ++ i)</code><br /> |
---|
168 | <code>v.erase_element (i);</code></td> |
---|
169 | <td> </td> |
---|
170 | </tr> |
---|
171 | <tr> |
---|
172 | <td>Resize</td> |
---|
173 | <td><code>v.resize (n) |
---|
174 | <br />v.resize (n, p)</code></td> |
---|
175 | <td> </td> |
---|
176 | <td>Reallocates the vector so that it can hold <code>n</code> |
---|
177 | elements.<br /> |
---|
178 | Erases or appends elements in order to bring the vector to the prescribed size. Appended elements copies of <code>value_type()</code>. |
---|
179 | <br /> |
---|
180 | When <code>p == false</code> then existing elements are not preserved and elements will not appended as normal. Instead the vector is in the same state as that after an equivalent sizing constructor.</td> |
---|
181 | <td><code>v.size () == n</code>.</td> |
---|
182 | </tr> |
---|
183 | <tr> |
---|
184 | <td>Storage</td> |
---|
185 | <td><code>v.data()</code></td> |
---|
186 | <td></td> |
---|
187 | <td>Returns a reference to the underlying dense storage.</td> |
---|
188 | <td> </td> |
---|
189 | </tr> |
---|
190 | </table> |
---|
191 | <h4>Complexity guarantees</h4> |
---|
192 | <p>The run-time complexity of the sizing constructor is linear in |
---|
193 | the vector's size.</p> |
---|
194 | <p>The run-time complexity of insert_element and erase_element is specific for the |
---|
195 | Vector model and it depends on increases/decreases in storage requirements.</p> |
---|
196 | <p>The run-time complexity of resize is linear in the vector's |
---|
197 | size.</p> |
---|
198 | <h4>Invariants</h4> |
---|
199 | <h4>Models</h4> |
---|
200 | <ul> |
---|
201 | <li><code>vector</code>, <code>bounded_vector</code>, <code>c_vector</code></li> |
---|
202 | <li><code>unit_vector</code>, <code>zero_vector</code>, <code>scalar_vector</code></li> |
---|
203 | <li><code>mapped_vector;</code>, <code>compressed_vector</code>, <code>coordinate_vector</code></li> |
---|
204 | </ul> |
---|
205 | <h4>Notes</h4> |
---|
206 | <p><a name="vector_expression_note">[1]</a> |
---|
207 | As a user you need not care about <tt>Vector</tt> being a refinement of the VectorExpression. Being a refinement of the VectorExpression is only important for the template-expression engine but not the user.</p> |
---|
208 | <p><a name="element_access_note">[2]</a> |
---|
209 | The <code>operator[]</code> is added purely for convenience |
---|
210 | and compatibility with the <code>std::vector</code>. In uBLAS however, |
---|
211 | generally <code>operator()</code> is used for indexing because this can be |
---|
212 | used for both vectors and matrices.</p> |
---|
213 | <h2><a name="matrix" id="matrix"></a>Matrix</h2> |
---|
214 | <h4>Description</h4> |
---|
215 | <p>A Matrix describes common aspects of dense, packed and sparse |
---|
216 | matrices.</p> |
---|
217 | <h4>Refinement of</h4> |
---|
218 | <p><a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a>, |
---|
219 | <a href="expression_concept.htm#matrix_expression">Matrix Expression</a> |
---|
220 | <a href="#matrix_expression_note">[1]</a> |
---|
221 | .</p> |
---|
222 | <h4>Associated types</h4> |
---|
223 | <p>In addition to the types defined by <a href="http://www.sgi.com/tech/stl/RandomAccessContainer.html">RandomAccessContainer</a> and <a href="expression_concept.htm#matrix_expression">Matrix Expression</a></p> |
---|
224 | <table border="1" summary="types"> |
---|
225 | <tbody> |
---|
226 | <tr> |
---|
227 | <td>Public base</td> |
---|
228 | <td>matrix_container<M></td> |
---|
229 | <td>M must be derived from this public base type.</td> |
---|
230 | </tr> |
---|
231 | <tr> |
---|
232 | <td>Storage array</td> |
---|
233 | <td>M::array_type</td> |
---|
234 | <td>Dense Matrix ONLY. The type of underlying storage array used to store the elements. The array_type must model |
---|
235 | the <a href="storage_concept.htm"><b>Storage</b></a> concept.</td> |
---|
236 | </tr> |
---|
237 | </tbody> |
---|
238 | </table> |
---|
239 | <h4>Notation</h4> |
---|
240 | <table border="0" summary="notation"> |
---|
241 | <tbody> |
---|
242 | <tr> |
---|
243 | <td><code>M</code></td> |
---|
244 | <td>A type that is a model of Matrix</td> |
---|
245 | </tr> |
---|
246 | <tr> |
---|
247 | <td><code>m</code></td> |
---|
248 | <td>Objects of type <code>M</code></td> |
---|
249 | </tr> |
---|
250 | <tr> |
---|
251 | <td><code>n1, n2, i, j</code></td> |
---|
252 | <td>Objects of a type convertible to <code>size_type</code></td> |
---|
253 | </tr> |
---|
254 | <tr> |
---|
255 | <td><code>t</code></td> |
---|
256 | <td>Object of a type convertible to <code>value_type</code></td> |
---|
257 | </tr> |
---|
258 | <tr> |
---|
259 | <td><code>p</code></td> |
---|
260 | <td>Object of a type convertible to <code>bool</code></td> |
---|
261 | </tr> |
---|
262 | </tbody> |
---|
263 | </table> |
---|
264 | <h4>Definitions</h4> |
---|
265 | <h4>Valid expressions</h4> |
---|
266 | <p>In addition to the expressions defined in <a href= |
---|
267 | "expression_concept.htm#matrix_expression">Matrix Expression</a> the |
---|
268 | following expressions must be valid.</p> |
---|
269 | <table border="1" summary="expressions"> |
---|
270 | <tbody> |
---|
271 | <tr> |
---|
272 | <th>Name</th> |
---|
273 | <th>Expression</th> |
---|
274 | <th>Type requirements</th> |
---|
275 | <th>Return type</th> |
---|
276 | </tr> |
---|
277 | <tr> |
---|
278 | <td>Sizing constructor</td> |
---|
279 | <td><code>M m (n1, n2)</code></td> |
---|
280 | <td> </td> |
---|
281 | <td><code>M</code></td> |
---|
282 | </tr> |
---|
283 | <tr> |
---|
284 | <td>Insert</td> |
---|
285 | <td><code>m.insert_element (i, j, t)</code></td> |
---|
286 | <td><code>m</code> is mutable.</td> |
---|
287 | <td><code>void</code></td> |
---|
288 | </tr> |
---|
289 | <tr> |
---|
290 | <td>Erase</td> |
---|
291 | <td><code>m.erase_element (i, j)</code></td> |
---|
292 | <td><code>m</code> is mutable.</td> |
---|
293 | <td><code>void</code></td> |
---|
294 | </tr> |
---|
295 | <tr> |
---|
296 | <td>Clear</td> |
---|
297 | <td><code>m.clear ()</code></td> |
---|
298 | <td><code>m</code> is mutable.</td> |
---|
299 | <td><code>void</code></td> |
---|
300 | </tr> |
---|
301 | <tr> |
---|
302 | <td>Resize</td> |
---|
303 | <td><code>m.resize (n1, n2)</code><br /> |
---|
304 | <code>m.resize (n1, n2, p)</code></td> |
---|
305 | <td><code>m</code> is mutable.</td> |
---|
306 | <td><code>void</code></td> |
---|
307 | </tr> |
---|
308 | <tr> |
---|
309 | <td>Storage</td> |
---|
310 | <td><code>m.data()</code></td> |
---|
311 | <td><code>m</code> is mutable and Dense.</td> |
---|
312 | <td><code>array_type&</code> if a is mutable, <code>const array_type&</code> otherwise</td> |
---|
313 | </tr> |
---|
314 | </tbody> |
---|
315 | </table> |
---|
316 | <h4>Expression semantics</h4> |
---|
317 | <p>Semantics of an expression is defined only where it differs |
---|
318 | from, or is not defined in <a href= |
---|
319 | "expression_concept.htm#matrix_expression">Matrix Expression</a> .</p> |
---|
320 | <table border="1" summary="semantics"> |
---|
321 | <tbody> |
---|
322 | <tr> |
---|
323 | <th>Name</th> |
---|
324 | <th>Expression</th> |
---|
325 | <th>Precondition</th> |
---|
326 | <th>Semantics</th> |
---|
327 | <th>Postcondition</th> |
---|
328 | </tr> |
---|
329 | <tr> |
---|
330 | <td>Sizing constructor</td> |
---|
331 | <td><code>M m (n1, n2)</code></td> |
---|
332 | <td><code>n1 >= 0</code> and <code>n2 >= 0</code></td> |
---|
333 | <td>Allocates a matrix of <code>n1</code> rows and <code>n2</code> |
---|
334 | columns.</td> |
---|
335 | <td><code>m.size1 () == n1</code> and <code>m.size2 () == |
---|
336 | n2</code>.</td> |
---|
337 | </tr> |
---|
338 | <tr> |
---|
339 | <td>Insert</td> |
---|
340 | <td><code>m.insert_element (i, j, t)</code></td> |
---|
341 | <td><code>0 <= i < m.size1 ()</code>,<br /> |
---|
342 | <code>0 <= j < m.size2 ()</code>.</td> |
---|
343 | <td>Inserts an element at <code>m (i, j)</code> with value <code>t</code>. |
---|
344 | The storage requirement of the Matrix may be increased.</td> |
---|
345 | <td><code>m (i, j)</code> is equal to <code>t</code>.</td> |
---|
346 | </tr> |
---|
347 | <tr> |
---|
348 | <td>Erase</td> |
---|
349 | <td><code>m.erase_element (i, j)</code></td> |
---|
350 | <td><code>0 <= i < m.size1 ()</code>and <code><br /> |
---|
351 | 0 <= j < m.size2</code></td> |
---|
352 | <td>Destroys the element as <code>m (i, j)</code> and replaces it with the default |
---|
353 | <code>value_type ()</code>. |
---|
354 | The storage requirement of the Matrix may be decreased.</td> |
---|
355 | <td><code>m (i, j)</code> is equal to <code>value_type ()</code>.</td> |
---|
356 | </tr> |
---|
357 | <tr> |
---|
358 | <td>Clear</td> |
---|
359 | <td><code>m.clear ()</code></td> |
---|
360 | <td> </td> |
---|
361 | <td>Equivalent to<br /> |
---|
362 | <code>for (i = 0; i < m.size1 (); ++ i)</code><br /> |
---|
363 | <code>for (j = 0; j < m.size2 (); ++ j)</code><br /> |
---|
364 | <code>m.erase_element (i, j);</code></td> |
---|
365 | <td> </td> |
---|
366 | </tr> |
---|
367 | <tr> |
---|
368 | <td>Resize</td> |
---|
369 | <td><code>m.resize (n1, n2) |
---|
370 | <br /> |
---|
371 | m.resize (n1, n2, p) |
---|
372 | </code></td> |
---|
373 | <td> </td> |
---|
374 | <td>Reallocate the matrix so that it can hold <code>n1</code> rows |
---|
375 | and <code>n2</code> columns.<br /> |
---|
376 | Erases or appends elements in order to bring the matrix to the |
---|
377 | prescribed size. Appended elements are <code>value_type()</code> |
---|
378 | copies.<br /> |
---|
379 | When <code>p == false</code> then existing elements are not preserved and elements will not appended as normal. Instead the matrix is in the same state as that after an equivalent sizing constructor.</td> |
---|
380 | <td><code>m.size1 () == n1</code> and <code>m.size2 () == n2</code>.</td> |
---|
381 | </tr> |
---|
382 | <tr> |
---|
383 | <td>Storage</td> |
---|
384 | <td><code>m.data()</code></td> |
---|
385 | <td></td> |
---|
386 | <td>Returns a reference to the underlying dense storage.</td> |
---|
387 | <td> </td> |
---|
388 | </tbody> |
---|
389 | </table> |
---|
390 | <h4>Complexity guarantees</h4> |
---|
391 | <p>The run-time complexity of the sizing constructor is quadratic |
---|
392 | in the matrix's size.</p> |
---|
393 | <p>The run-time complexity of insert_element and erase_element is specific for the |
---|
394 | Matrix model and it depends on increases/decreases in storage requirements.</p> |
---|
395 | <p>The run-time complexity of resize is quadratic in the matrix's |
---|
396 | size.</p> |
---|
397 | <h4>Invariants</h4> |
---|
398 | <h4>Models</h4> |
---|
399 | <ul> |
---|
400 | <li><code>matrix</code>, <code>bounded_matrix</code>, <code>c_matrix</code></li> |
---|
401 | <li><code>identity_matrix</code> , <code>zero_matrix</code> , <code>scalar_matrix</code></li> |
---|
402 | <li><code>triangular_matrix</code> , <code>symmetric_matrix</code> , <code>banded_matrix</code></li> |
---|
403 | <li><code>mapped_matrix</code> , <code>compressed_matrix</code> , <code>coordinate_matrix</code></li> |
---|
404 | </ul> |
---|
405 | <h4>Notes</h4> |
---|
406 | <p><a name="matrix_expression_note">[1]</a> |
---|
407 | As a user you need not care about <tt>Matrix</tt> being a refinement of the MatrixExpression. Being a refinement of the MatrixExpression is only important for the template-expression engine but not the user.</p> |
---|
408 | <hr /> |
---|
409 | <p>Copyright (©) 2000-2002 Joerg Walter, Mathias Koch<br /> |
---|
410 | Permission to copy, use, modify, sell and distribute this document |
---|
411 | is granted provided this copyright notice appears in all copies. |
---|
412 | This document is provided ``as is'' without express or implied |
---|
413 | warranty, and with no claim as to its suitability for any |
---|
414 | purpose.</p> |
---|
415 | </body> |
---|
416 | </html> |
---|