Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

added boost

File size: 13.6 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>Container Concepts</title>
11</head>
12<body>
13<h1><img src="../../../../boost.png" align="middle" />
14Container 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
18vectors.</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&lt;V&gt;</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>
37Dense 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>&nbsp;</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&amp;</code> if a is mutable, <code>const array_type&amp;</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
121from, 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 &gt;= 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&lt;n&gt;v.size()</code></td>
142<td>returns the n-th element in v</td>
143<td>&nbsp;</td>
144</tr>
145<tr>
146<td>Insert</td>
147<td><code>v.insert_element (i, t)</code></td>
148<td><code>0 &lt;= i &lt; v.size ()</code>.</td>
149<td>Inserts an element at <code>v (i)</code> with value <code>t</code>.
150The 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 &lt;= i &lt; 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>.
159The 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>&nbsp;</td>
166<td>Equivalent to<br />
167<code>for (i = 0; i &lt; v.size (); ++ i)</code><br />
168&nbsp; <code>v.erase_element (i);</code></td>
169<td>&nbsp;</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>&nbsp;</td>
176<td>Reallocates the vector so that it can hold <code>n</code>
177elements.<br />
178Erases or appends elements in order to bring the vector to the prescribed size. Appended elements copies of <code>value_type()</code>.
179<br />
180When <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>&nbsp;</td>
189</tr>
190</table>
191<h4>Complexity guarantees</h4>
192<p>The run-time complexity of the sizing constructor is linear in
193the vector's size.</p>
194<p>The run-time complexity of insert_element and erase_element is specific for the
195Vector 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
197size.</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>
207As 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>
209The <code>operator[]</code> is added purely for convenience
210and compatibility with the <code>std::vector</code>. In uBLAS however,
211generally <code>operator()</code> is used for indexing because this can be
212used 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
216matrices.</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&lt;M&gt;</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
235the <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
268following 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>&nbsp;</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&amp;</code> if a is mutable, <code>const array_type&amp;</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
318from, 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 &gt;= 0</code> and <code>n2 &gt;= 0</code></td>
333<td>Allocates a matrix of <code>n1</code> rows and <code>n2</code>
334columns.</td>
335<td><code>m.size1 () == n1</code> and <code>m.size2 () ==
336n2</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 &lt;= i &lt; m.size1 ()</code>,<br />
342<code>0 &lt;= j &lt; m.size2 ()</code>.</td>
343<td>Inserts an element at <code>m (i, j)</code> with value <code>t</code>.
344The 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 &lt;= i &lt; m.size1 ()</code>and <code><br />
3510 &lt;= j &lt; 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>.
354The 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>&nbsp;</td>
361<td>Equivalent to<br />
362<code>for (i = 0; i &lt; m.size1 (); ++ i)</code><br />
363&nbsp; <code>for (j = 0; j &lt; m.size2 (); ++ j)</code><br />
364&nbsp; &nbsp; <code>m.erase_element (i, j);</code></td>
365<td>&nbsp;</td>
366</tr>
367<tr>
368<td>Resize</td>
369<td><code>m.resize (n1, n2)
370<br />
371m.resize (n1, n2, p)
372</code></td>
373<td>&nbsp;</td>
374<td>Reallocate the matrix so that it can hold <code>n1</code> rows
375and <code>n2</code> columns.<br />
376Erases or appends elements in order to bring the matrix to the
377prescribed size. Appended elements are <code>value_type()</code>
378copies.<br />
379When <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>&nbsp;</td>
388</tbody>
389</table>
390<h4>Complexity guarantees</h4>
391<p>The run-time complexity of the sizing constructor is quadratic
392in the matrix's size.</p>
393<p>The run-time complexity of insert_element and erase_element is specific for the
394Matrix 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
396size.</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>
407As 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 (&copy;) 2000-2002 Joerg Walter, Mathias Koch<br />
410Permission to copy, use, modify, sell and distribute this document
411is granted provided this copyright notice appears in all copies.
412This document is provided ``as is'' without express or implied
413warranty, and with no claim as to its suitability for any
414purpose.</p>
415</body>
416</html>
Note: See TracBrowser for help on using the repository browser.