File: vector_proxy.htm

package info (click to toggle)
boost 1.33.1-10
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 100,948 kB
  • ctags: 145,103
  • sloc: cpp: 573,492; xml: 49,055; python: 15,626; ansic: 13,588; sh: 2,099; yacc: 858; makefile: 660; perl: 427; lex: 111; csh: 6
file content (517 lines) | stat: -rw-r--r-- 17,332 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 1st March 2004), see www.w3.org" />
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii" />
<link href="ublas.css" type="text/css" />
<title>Vector Proxies</title>
</head>
<body>
<h1><img src="../../../../boost.png" align="middle" />
Vector Proxies</h1>
<h2><a name="vector_range" id="vector_range"></a>Vector Range</h2>
<h4>Description</h4>
<p>The templated class <code>vector_range&lt;V&gt;</code> allows
addressing a sub-range of a vector's element.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/vector.hpp&gt;
#include &lt;boost/numeric/ublas/vector_proxy.hpp&gt;
#include &lt;boost/numeric/ublas/io.hpp&gt;

int main () {
    using namespace boost::numeric::ublas;
    vector&lt;double&gt; v (3);
    vector_range&lt;vector&lt;double&gt; &gt; vr (v, range (0, 3));
    for (unsigned i = 0; i &lt; vr.size (); ++ i)
        vr (i) = i;
    std::cout &lt;&lt; vr &lt;&lt; std::endl;
}
</pre>
<h4>Definition</h4>
<p>Defined in the header vector_proxy.hpp.</p>
<h4>Template parameters</h4>
<table border="1" summary="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>V</code></td>
<td>The type of vector referenced.</td>
<td></td>
</tr>
</tbody>
</table>
<h4>Model of</h4>
<p><a href="expression_concept.htm#vector_expression">Vector Expression</a>
.</p>
<p>If the specified range falls outside that of the index range of
the vector, then the <code>vector_range</code> is not a well formed
Vector Expression. That is, access to an element which is outside
of index range of the vector is <i>undefined</i>.</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of <a href=
"expression_concept.htm#vector_expression">Vector Expression</a> .</p>
<h4>Public base classes</h4>
<p><code>vector_expression&lt;vector_range&lt;V&gt; &gt;</code></p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>vector_range (vector_type &amp;data, const range
&amp;r)</code></td>
<td>Constructs a sub vector.</td>
</tr>
<tr>
<td><code>size_type start () const</code></td>
<td>Returns the start of the sub vector.</td>
</tr>
<tr>
<td><code>size_type size () const</code></td>
<td>Returns the size of the sub vector.</td>
</tr>
<tr>
<td><code>const_reference operator () (size_type i)
const</code></td>
<td>Returns the value of the <code>i</code>-th element.</td>
</tr>
<tr>
<td><code>reference operator () (size_type i)</code></td>
<td>Returns a reference of the <code>i</code>-th element.</td>
</tr>
<tr>
<td><code>const_reference operator [] (size_type i)
const</code></td>
<td>Returns the value of the <code>i</code>-th element.</td>
</tr>
<tr>
<td><code>reference operator [] (size_type i)</code></td>
<td>Returns a reference of the <code>i</code>-th element.</td>
</tr>
<tr>
<td><code>vector_range &amp;operator = (const vector_range
&amp;vr)</code></td>
<td>The assignment operator.</td>
</tr>
<tr>
<td><code>vector_range &amp;assign_temporary (vector_range
&amp;vr)</code></td>
<td>Assigns a temporary. May change the vector range
<code>vr</code> .</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
vector_range &amp;operator = (const vector_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>The extended assignment operator.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
vector_range &amp;assign (const vector_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Assigns a vector expression to the sub vector. Left and right
hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
vector_range &amp;operator += (const vector_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>A computed assignment operator. Adds the vector expression to
the sub vector.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
vector_range &amp;plus_assign (const vector_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Adds a vector expression to the sub vector. Left and right hand
side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
vector_range &amp;operator -= (const vector_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>A computed assignment operator. Subtracts the vector expression
from the sub vector.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
vector_range &amp;minus_assign (const vector_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Subtracts a vector expression from the sub vector. Left and
right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
vector_range &amp;operator *= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Multiplies the sub vector with
a scalar.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
vector_range &amp;operator /= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Divides the sub vector through
a scalar.</td>
</tr>
<tr>
<td><code>void swap (vector_range &amp;vr)</code></td>
<td>Swaps the contents of the sub vectors.</td>
</tr>
<tr>
<td><code>const_iterator begin () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the beginning
of the <code>vector_range</code>.</td>
</tr>
<tr>
<td><code>const_iterator end () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the end of
the <code>vector_range</code>.</td>
</tr>
<tr>
<td><code>iterator begin ()</code></td>
<td>Returns a <code>iterator</code> pointing to the beginning of
the <code>vector_range</code>.</td>
</tr>
<tr>
<td><code>iterator end ()</code></td>
<td>Returns a <code>iterator</code> pointing to the end of the
<code>vector_range</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rbegin () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
beginning of the reversed <code>vector_range</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rend () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
end of the reversed <code>vector_range</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator rbegin ()</code></td>
<td>Returns a <code>reverse_iterator</code> pointing to the
beginning of the reversed <code>vector_range</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator rend ()</code></td>
<td>Returns a <code>reverse_iterator</code> pointing to the end of
the reversed <code>vector_range</code>.</td>
</tr>
</tbody>
</table>
<h3>Simple Projections</h3>
<h4>Description</h4>
<p>The free <code>subrange</code> functions support the construction
of vector ranges.</p>
<h4>Prototypes</h4>
<pre><code>
    template&lt;class V&gt;
    vector_range&lt;V&gt; subrange (V &amp;data,
       V::size_type start, V::size_type stop);
    template&lt;class V&gt;
    const vector_range&lt;const V&gt; subrange (const V &amp;data,
       V::size_type start, V::size_type stop);
</code></pre>
<h3>Generic Projections</h3>
<h4>Description</h4>
<p>The free <code>project</code> functions support the construction
of vector ranges. Existing <code>matrix_range</code>'s can be composed with a further range. The resulting range is computed using this existing range's <code>compose</code> function.</p>
<h4>Prototypes</h4>
<pre><code>
    template&lt;class V&gt;
    vector_range&lt;V&gt; project (V &amp;data, const range &amp;r);
    template&lt;class V&gt;
    const vector_range&lt;const V&gt; project (const V &amp;data, const range &amp;r);
    template&lt;class V&gt;
    vector_range&lt;V&gt; project (vector_range&lt;V&gt; &amp;data, const range &amp;r);
    template&lt;class V&gt;
    const vector_range&lt;V&gt; project (const vector_range&lt;V&gt; &amp;data, const range &amp;r);
</code></pre>
<h4>Definition</h4>
<p>Defined in the header vector_proxy.hpp.</p>
<h4>Type requirements</h4>
<ul>
<li><code>V</code> is a model of <a href=
"expression_concept.htm#vector_expression">Vector Expression</a> .</li>
</ul>
<h4>Complexity</h4>
<p>Linear depending from the size of the range.</p>
<h4>Examples</h4>
<pre>
#include &lt;boost/numeric/ublas/vector.hpp&gt;
#include &lt;boost/numeric/ublas/vector_proxy.hpp&gt;
#include &lt;boost/numeric/ublas/io.hpp&gt;

int main () {
    using namespace boost::numeric::ublas;
    vector&lt;double&gt; v (3);
    for (int i = 0; i &lt; 3; ++ i)
        project (v, range (0, 3)) (i) = i;
    std::cout &lt;&lt; project (v, range (0, 3)) &lt;&lt; std::endl;
}
</pre>
<h2><a name="vector_slice" id="vector_slice"></a>Vector Slice</h2>
<h4>Description</h4>
<p>The templated class <code>vector_slice&lt;V&gt;</code> allows
addressing a slice of a vector.</p>
<h4>Example</h4>
<pre>
#include &lt;boost/numeric/ublas/vector.hpp&gt;
#include &lt;boost/numeric/ublas/vector_proxy.hpp&gt;
#include &lt;boost/numeric/ublas/io.hpp&gt;

int main () {
    using namespace boost::numeric::ublas;
    vector&lt;double&gt; v (3);
    vector_slice&lt;vector&lt;double&gt; &gt; vs (v, slice (0, 1, 3));
    for (unsigned i = 0; i &lt; vs.size (); ++ i)
        vs (i) = i;
    std::cout &lt;&lt; vs &lt;&lt; std::endl;
}
</pre>
<h4>Definition</h4>
<p>Defined in the header vector_proxy.hpp.</p>
<h4>Template parameters</h4>
<table border="1" summary="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>V</code></td>
<td>The type of vector referenced.</td>
<td></td>
</tr>
</tbody>
</table>
<h4>Model of</h4>
<p><a href="expression_concept.htm#vector_expression">Vector Expression</a>
.</p>
<p>If the specified slice falls outside that of the index range of
the vector, then the <code>vector_slice</code> is not a well formed
Vector Expression. That is, access to an element which is outside
of index range of the vector is <i>undefined</i>.</p>
<h4>Type requirements</h4>
<p>None, except for those imposed by the requirements of <a href=
"expression_concept.htm#vector_expression">Vector Expression</a> .</p>
<h4>Public base classes</h4>
<p><code>vector_expression&lt;vector_slice&lt;V&gt; &gt;</code></p>
<h4>Members</h4>
<table border="1" summary="members">
<tbody>
<tr>
<th>Member</th>
<th>Description</th>
</tr>
<tr>
<td><code>vector_slice (vector_type &amp;data, const slice
&amp;s)</code></td>
<td>Constructs a sub vector.</td>
</tr>
<tr>
<td><code>size_type size () const</code></td>
<td>Returns the size of the sub vector.</td>
</tr>
<tr>
<td><code>const_reference operator () (size_type i)
const</code></td>
<td>Returns the value of the <code>i</code>-th element.</td>
</tr>
<tr>
<td><code>reference operator () (size_type i)</code></td>
<td>Returns a reference of the <code>i</code>-th element.</td>
</tr>
<tr>
<td><code>const_reference operator [] (size_type i)
const</code></td>
<td>Returns the value of the <code>i</code>-th element.</td>
</tr>
<tr>
<td><code>reference operator [] (size_type i)</code></td>
<td>Returns a reference of the <code>i</code>-th element.</td>
</tr>
<tr>
<td><code>vector_slice &amp;operator = (const vector_slice
&amp;vs)</code></td>
<td>The assignment operator.</td>
</tr>
<tr>
<td><code>vector_slice &amp;assign_temporary (vector_slice
&amp;vs)</code></td>
<td>Assigns a temporary. May change the vector slice
<code>vs</code> .</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
vector_slice &amp;operator = (const vector_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>The extended assignment operator.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
vector_slice &amp;assign (const vector_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Assigns a vector expression to the sub vector. Left and right
hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
vector_slice &amp;operator += (const vector_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>A computed assignment operator. Adds the vector expression to
the sub vector.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
vector_slice &amp;plus_assign (const vector_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Adds a vector expression to the sub vector. Left and right hand
side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
vector_slice &amp;operator -= (const vector_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>A computed assignment operator. Subtracts the vector expression
from the sub vector.</td>
</tr>
<tr>
<td><code>template&lt;class AE&gt;<br />
vector_slice &amp;minus_assign (const vector_expression&lt;AE&gt;
&amp;ae)</code></td>
<td>Subtracts a vector expression from the sub vector. Left and
right hand side of the assignment should be independent.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
vector_slice &amp;operator *= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Multiplies the sub vector with
a scalar.</td>
</tr>
<tr>
<td><code>template&lt;class AT&gt;<br />
vector_slice &amp;operator /= (const AT &amp;at)</code></td>
<td>A computed assignment operator. Divides the sub vector through
a scalar.</td>
</tr>
<tr>
<td><code>void swap (vector_slice &amp;vs)</code></td>
<td>Swaps the contents of the sub vectors.</td>
</tr>
<tr>
<td><code>const_iterator begin () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the beginning
of the <code>vector_slice</code>.</td>
</tr>
<tr>
<td><code>const_iterator end () const</code></td>
<td>Returns a <code>const_iterator</code> pointing to the end of
the <code>vector_slice</code>.</td>
</tr>
<tr>
<td><code>iterator begin ()</code></td>
<td>Returns a <code>iterator</code> pointing to the beginning of
the <code>vector_slice</code>.</td>
</tr>
<tr>
<td><code>iterator end ()</code></td>
<td>Returns a <code>iterator</code> pointing to the end of the
<code>vector_slice</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rbegin () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
beginning of the reversed <code>vector_slice</code>.</td>
</tr>
<tr>
<td><code>const_reverse_iterator rend () const</code></td>
<td>Returns a <code>const_reverse_iterator</code> pointing to the
end of the reversed <code>vector_slice</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator rbegin ()</code></td>
<td>Returns a <code>reverse_iterator</code> pointing to the
beginning of the reversed <code>vector_slice</code>.</td>
</tr>
<tr>
<td><code>reverse_iterator rend ()</code></td>
<td>Returns a <code>reverse_iterator</code> pointing to the end of
the reversed <code>vector_slice</code>.</td>
</tr>
</tbody>
</table>
<h3>Simple Projections</h3>
<h4>Description</h4>
<p>The free <code>subslice</code> functions support the construction
of vector slices.</p>
<h4>Prototypes</h4>
<pre><code>
    template&lt;class V&gt;
    vector_slice&lt;V&gt; subslice (V &amp;data,
       V::size_type start, V::difference_type stride, V::size_type size);
    template&lt;class V&gt;
    const vector_slice&lt;const V&gt; subslice (const V &amp;data,
       V::size_type start, V::difference_type stride, V::size_type size);
</code></pre>
<h3>Generic Projections</h3>
<h4>Description</h4>
<p>The free <code>project</code> functions support the construction
of vector slices. Existing <code>vector_slice</code>'s can be composed with a further range or slices. The resulting slice is computed using this existing slices's <code>compose</code> function.</p>
<h4>Prototypes</h4>
<pre><code>
    template&lt;class V&gt;
    vector_slice&lt;V&gt; project (V &amp;data, const slice &amp;s);
    template&lt;class V&gt;
    const vector_slice&lt;const V&gt; project (const V &amp;data, const slice &amp;s);
    template&lt;class V&gt;
    vector_slice&lt;V&gt; project (vector_slice&lt;V&gt; &amp;data, const range &amp;r);
    template&lt;class V&gt;
    const vector_slice&lt;V&gt; project (const vector_slice&lt;V&gt; &amp;data, const range &amp;r);
    template&lt;class V&gt;
    vector_slice&lt;V&gt; project (vector_slice&lt;V&gt; &amp;data, const slice &amp;s);
    template&lt;class V&gt;
    const vector_slice&lt;V&gt; project (const vector_slice&lt;V&gt; &amp;data, const slice &amp;s);
</code></pre>
<h4>Definition</h4>
<p>Defined in the header vector_proxy.hpp.</p>
<h4>Type requirements</h4>
<ul>
<li><code>V</code> is a model of <a href=
"expression_concept.htm#vector_expression">Vector Expression</a> .</li>
</ul>
<h4>Complexity</h4>
<p>Linear depending from the size of the slice.</p>
<h4>Examples</h4>
<pre>
#include &lt;boost/numeric/ublas/vector.hpp&gt;
#include &lt;boost/numeric/ublas/vector_proxy.hpp&gt;
#include &lt;boost/numeric/ublas/io.hpp&gt;

int main () {
    using namespace boost::numeric::ublas;
    vector&lt;double&gt; v (3);
    for (int i = 0; i &lt; 3; ++ i)
        project (v, slice (0, 1, 3)) (i) = i;
    std::cout &lt;&lt; project (v, slice (0, 1, 3)) &lt;&lt; std::endl;
}
</pre>
<hr />
<p>Copyright (&copy;) 2000-2002 Joerg Walter, Mathias Koch<br />
Permission to copy, use, modify, sell and distribute this document
is granted provided this copyright notice appears in all copies.
This document is provided ``as is'' without express or implied
warranty, and with no claim as to its suitability for any
purpose.</p>
</body>
</html>