~ubuntu-branches/ubuntu/raring/blitz++/raring

« back to all changes in this revision

Viewing changes to manual/vector.html

  • Committer: Bazaar Package Importer
  • Author(s): Konstantinos Margaritis
  • Date: 2005-02-28 20:25:01 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050228202501-3i4f2sknnprsqfhz
Tags: 1:0.8-4
Added missing build-depends (Closes: #297323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<html>
2
 
<title>Blitz++ Class Reference: Vector&lt;T&gt;</title>
3
 
<body>
4
 
 
5
 
<h1>Blitz++ Class Reference: Vector&lt;T&gt;</h1>
6
 
 
7
 
<table border cellpadding=10 align=top>
8
 
<tr valign=top><td>
9
 
<h3>Sections</h3>
10
 
<ul>
11
 
<li><a href="#summary">Summary</a></li>
12
 
<li><a href="#synopsis">Synopsis</a></li>
13
 
<li><a href="#template">Template parameter</a></li>
14
 
<li><a href="#publictype">Public types</a></li>
15
 
<li><a href="#construct">Constructors</a></li>
16
 
<li><a href="#member">Member functions</a></li>
17
 
<li><a href="#memberops">Member operators</a></li>
18
 
<li><a href="#ops">Operators</a></li>
19
 
<li><a href="#global">Global math functions</a></li>
20
 
<li><a href="#global2">Other global functions</a></li>
21
 
<li><a href="#example">Example</a></li>
22
 
</ul>
23
 
</td>
24
 
<td>
25
 
<h3>Related topics and classes</h3>
26
 
<ul>
27
 
<li>The <a href="range.html">Range</a> class</li>
28
 
<!-- <li>Aliasing and the <a href="restrict.html">restrict</a> keyword</li> -->
29
 
<!-- <li>Data/view model</li> -->
30
 
<!-- <li>Expression templates</li> -->
31
 
<!-- <li>Type promotion</li> -->
32
 
<!-- <li>Performance benchmarks</li> -->
33
 
<!-- <li>where/elsewhere/endwhere</li> -->
34
 
<!-- <li>Matrix&lt;T&gt;</li> -->
35
 
<!-- <li>FFTServer&lt;T&gt;</li> -->
36
 
</ul>
37
 
</td>
38
 
 
39
 
<td align=center>
40
 
<h3>Inheritance diagram</h3>
41
 
MemoryBlockReference&lt;T&gt;<br>
42
 
|<br>
43
 
Vector&lt;T&gt;
44
 
</td>
45
 
</table>
46
 
 
47
 
<a name="summary">
48
 
<!-- <h2>Summary</h2> -->
49
 
 
50
 
<a name="synopsis">
51
 
<h2>Synopsis</h2>
52
 
 
53
 
<pre>
54
 
#include &lt;blitz/vector.h&gt;
55
 
using namespace blitz;
56
 
Vector&lt;double&gt; x(100);
57
 
</pre>
58
 
 
59
 
<a name="template">
60
 
<h2>Template parameter</h2>
61
 
 
62
 
<p>
63
 
The template parameter of Vector&lt;T&gt; is the element type of the 
64
 
vector.  This should an integral, floating point, or complex type.  
65
 
These choices of <b>T</b> should work: 
66
 
<ul>
67
 
<li>bool, char, unsigned char, short int, short unsigned int, int, unsigned int,
68
 
long, unsigned long</li>
69
 
<li>float, double, long double</li>
70
 
<li>complex&lt;float&gt;, complex&lt;double&gt;, and 
71
 
complex&lt;long double&gt;</li>
72
 
</ul>
73
 
Other types
74
 
may work provided they have the necessary numeric semantics.
75
 
</p>
76
 
 
77
 
<a name="publictype">
78
 
<h2>Public types</h2>
79
 
 
80
 
<p>Vector&lt;T&gt; declares several publicly accessible
81
 
types.  They may be accessed using the scope (::) operator: e.g.
82
 
<pre>
83
 
Vector&lt;double&gt; x(50);                       // Create a vector of length 50
84
 
Vector&lt;double&gt;::T_iterator z = x.begin();   // Get an iterator for x
85
 
</pre>
86
 
 
87
 
<table border cellpadding=2>
88
 
<tr>
89
 
<th>
90
 
Type
91
 
</th>
92
 
<th>
93
 
Description
94
 
</th>
95
 
</tr>
96
 
<tr align=left>
97
 
<td>
98
 
<b>T_numtype</b></td>
99
 
<td>The numeric type of the vector elements (e.g. double)</td>
100
 
</tr>
101
 
 
102
 
<tr align=left><td>
103
 
<b>T_vector</b></td>
104
 
<td>Complete type of the vector itself (e.g. Vector&lt;double&gt;)</td></tr>
105
 
 
106
 
<tr align=left><td>
107
 
<b>T_iterator</b></td>
108
 
<td>STL-like iterator to be used on this vector (see begin(), end())
109
 
** Not yet supported</td>
110
 
</tr>
111
 
 
112
 
<tr align=left><td>
113
 
<b>T_constIterator</b></td>
114
 
<td>STL-like const iterator to be used on this vector (see begin(), end())
115
 
** Not yet supported</td>
116
 
</tr>
117
 
</table>
118
 
 
119
 
<a name="construct">
120
 
<h2>Constructors</h2>
121
 
 
122
 
<ul>
123
 
<li><b>Vector()</b><br><br>
124
 
Default constructor.  No memory is allocated; the length of the vector is
125
 
zero. The
126
 
vector may subsequently be resized using resize(), or used to refer to another
127
 
vector's data using reference().<br></li>
128
 
 
129
 
<br><li>
130
 
<b>Vector(size_t length)</b><br><br>
131
 
Create a new vector of the given length.  Memory is allocated using
132
 
<b>new</b>.  Elements are not initialized.<br></li>
133
 
 
134
 
<br><li>
135
 
<b>Vector(Vector&lt;T_numtype&gt;& x)</b><br><br>
136
 
Creates a reference (or alias) to the data of vector x.  Both x and this
137
 
vector now refer to the same underlying data, so any changes made to the
138
 
data via x will be visible in this vector.  (Note: T_numtype is a publicly
139
 
declared typedef for the template parameter).<br></li>
140
 
 
141
 
<br><li>
142
 
<b>Vector(Vector&lt;T_numtype&gt;& x, <a href="range.html">Range</a> r)</b><br><br>
143
 
Creates a reference (or alias) to a portion of the data of vector x.  
144
 
The range object specifies an interval of the index set.  For example,
145
 
<pre>
146
 
Vector&lt;double&gt; x(50);                // Create a vector of length 50
147
 
Vector&lt;double&gt; y(x, Range(10,20));  // y is now of length 11, and
148
 
                                     // refers to elements 10-20 of x
149
 
y[5] = 3;                            // y[5] is aliased to x[15]
150
 
</pre>
151
 
</li>
152
 
 
153
 
<li>
154
 
<b>Vector(size_t length, T_numtype initValue)</b><br><br>
155
 
Creates a new vector of the given length, and initializes all elements
156
 
to initValue.  Memory is allocated using <b>new</b>.</li>
157
 
 
158
 
<br><br><li>
159
 
<b>Vector(size_t length, T_numtype firstValue, T_numtype inc)</b><br><br>
160
 
Creates a new vector of the given length, and initializes the elements
161
 
to [ firstValue, firstValue + inc, firstValue + 2 * inc, ...,
162
 
firstValue + (length-1) * inc ].  Memory is allocated using <b>new</b>.</li>
163
 
 
164
 
<br><br><li>
165
 
<b>Vector(<a href="range.html">Range</a> r)</b><br><br>
166
 
Creates a vector and initializes the elements to the range r.  For
167
 
example,
168
 
<pre>
169
 
Vector&lt;int&gt; z(Range(0,5));    // z = [ 0, 1, 2, 3, 4, 5 ]
170
 
</pre>
171
 
</li>
172
 
 
173
 
<li>
174
 
<b>Vector(size_t length, Random&lt;P_distribution&gt;& random)</b><br><br>
175
 
Creates a vector and initializes its elements with random numbers.
176
 
For example,
177
 
<pre>
178
 
#include &lt;blitz/rand-normal.h&gt;
179
 
Random&lt;Normal&gt; gaussianNoise(0.0, 2.5);     // Zero-mean, variance 2.5
180
 
Vector&lt;double&gt; x(50, gaussianNoise);  
181
 
</pre>
182
 
</li>
183
 
 
184
 
<li>
185
 
<b>Vector(size_t length, T_numtype* [restrict] data, int stride = 1)</b><br><br>
186
 
Creates a vector which refers to the given data.  The <a href="restrict.html">
187
 
NCEG <b>restrict</b></a>
188
 
keyword can be used only with compilers which support it.  The stride
189
 
parameter gives the spacing of elements: in the created vector, element 
190
 
<b>i</b> will be <b>data[i * stride]</b>.  When the vector object is
191
 
destroyed, the memory is not freed (i.e. the vector does not assume
192
 
ownership of the data).</li>
193
 
 
194
 
<br><br><li>
195
 
<b>Vector(<i>vector expression</i>)</b><br><br>
196
 
Creates a vector of appropriate length and stores the result of
197
 
<i>vector expression</i> in it.  (See the explanation of expression
198
 
templates).   Examples:
199
 
<pre>
200
 
// Create a vector of length 16 containing a sampled cosine (full period)
201
 
Vector&lt;double&gt; x(cos(Range(0,15) * 2 * M_PI / 16.0));
202
 
 
203
 
// Create a new vector containing an approximation of the derivative
204
 
// of x.
205
 
Range I(1,15);
206
 
double delta = 1 / 16.;    // Spacing between samples
207
 
Vector&lt;double&gt; y = (x(I) - x(I-1)) / delta;
208
 
</pre>
209
 
</li>
210
 
 
211
 
</ul>
212
 
 
213
 
 
214
 
 
215
 
<a name="member">
216
 
<h2>Member functions</h2>
217
 
 
218
 
<ul>
219
 
<li>
220
 
<b>T_iterator      begin()</b>    ** NOT YET SUPPORTED<br><br>
221
 
Returns an STL-compliant iterator positioned at the beginning of the vector's
222
 
data.  T_iterator is a public type declared by Vector&lt;T_numtype&gt;, and
223
 
should be used to specify the type of the iterator:
224
 
<pre>
225
 
Vector&lt;double&gt; x(50);
226
 
Vector&lt;double&gt;::T_iterator iter = x.begin();
227
 
</pre>
228
 
Since T_iterator is STL-compliant, it may be used with the standard
229
 
template library routines.  [GIVE EXAMPLES]  See also end().
230
 
</li>
231
 
 
232
 
<br><br><li>
233
 
<b>T_constIterator begin()  const</b>    ** NOT YET SUPPORTED<br><br>
234
 
Returns an STL-compliant const iterator positioned at the beginning of
235
 
the vector's data.  A const iterator has read-only access to the vector
236
 
elements.  T_constIterator is a public type declared by Vector&lt;T_numtype&gt;,
237
 
and should be used to specify the type of the iterator:
238
 
<pre>
239
 
Vector&lt;int&gt; z(50,0,1);       // Creates the vector [ 0 1 2 ... 49 ]
240
 
const Vector&lt;int&gt;& zref = z; // Create a const reference to z
241
 
Vector&lt;int&gt;::T_constIterator iter = zref.begin();
242
 
</pre>
243
 
Since T_constIterator is STL-compliant, it may be used with the
244
 
standard template library routines.  [GIVE EXAMPLES]  See also end().<br><br>
245
 
 
246
 
The begin() method is const-overloaded.  By default, a non-const iterator
247
 
is returned.  A const iterator is returned only when the vector itself
248
 
is const.
249
 
</li>
250
 
 
251
 
<br><br><li>
252
 
<b>T_vector        copy()   const</b><br><br>
253
 
Returns a copy of the vector.  A new block of memory is allocated, and
254
 
the vector copy is guaranteed to have unit stride.
255
 
</li>
256
 
 
257
 
<br><br><li>
258
 
<b>T_iterator      end()</b><br><br>
259
 
Returns an STL-compliant iterator positioned at the end of the
260
 
vector's data.  See begin() above.
261
 
</li>
262
 
 
263
 
<br><br><li>
264
 
<b>T_constIterator end()    const</b><br><br>
265
 
Returns an STL-compliant const iterator positioned at the end of the
266
 
vector's data.  See begin() above.
267
 
</li>
268
 
 
269
 
<br><br><li>
270
 
<b>T_numtype * [<i>restrict</i>] data()<br>
271
 
const T_numtype * [<i>restrict</i>] data() const</b><br><br>
272
 
Obtain a pointer to the beginning of the vector data.  This method
273
 
should be used with caution, since it has the potential to
274
 
cause data corruption and/or segment violations if used improperly.
275
 
The vector data is not necessarily stored contiguously; the
276
 
spacing between vector elements can be obtained via the stride()
277
 
member function.  Here is an example:
278
 
<pre>
279
 
Vector&lt;float&gt; x(10,0,1);          // Creates [ 0 1 2 3 4 5 6 7 8 9 ]
280
 
float* xptr = x.data();           // Get a pointer to the vector data
281
 
int length = x.length();          // Obtain the length of the vector (10)
282
 
int stride = x.stride();          // Note that stride may be negative
283
 
 
284
 
for (int i=0; i < length; ++i)
285
 
    xptr[i * stride] = 7;         // Set each element to 7
286
 
 
287
 
// Now the vector contains [ 7 7 7 7 7 7 7 7 7 7 ]
288
 
// Note that "x = 7;" would accomplish the same result.
289
 
</pre>
290
 
The <a href="restrict.html">NCEG restrict</a> keyword is applicable 
291
 
only if the compiler supports it.<br><br>
292
 
 
293
 
The data() method is const-overloaded: if the vector is const, then 
294
 
data() returns a const T_numtype* pointer.
295
 
</li>
296
 
 
297
 
<br><br><li>
298
 
<b>size_t          length() const</b><br><br>
299
 
Returns the length of the vector.</li>
300
 
 
301
 
<br><br><li>
302
 
<b>void            makeUnique()</b><br><br>
303
 
If the vector's elements are referenced (or aliased) by another vector,
304
 
a copy is made, and on return the vector refers to the new copy.
305
 
</li>
306
 
 
307
 
<br><br><li>
308
 
<b>void            reference(T_vector& x)</b><br><br>
309
 
Makes the vector an alias for vector x.  After this member function is
310
 
used, both the vector and x refer to the same underlying data.</li>
311
 
 
312
 
<br><br><li>
313
 
<b>void            resize(size_t length)</b><br><br>
314
 
If length is different than the current length of the vector, the
315
 
vector is resized.  The current contents are lost.
316
 
</li>
317
 
 
318
 
<br><br><li>
319
 
<b>void            resizeAndPreserve(size_t newLength)</b><br><br>
320
 
Allocates a new vector of size newLength, and copies as much of
321
 
the current vector as will fit into the new vector.  If the new
322
 
vector is larger than the previous vector, then the unused elements
323
 
are left uninitialized.</li>
324
 
 
325
 
<br><br><li>
326
 
<b>Vector&lt;T_numtype&gt; reverse()</b><br><br>
327
 
Returns a view of the vector in reverse order.  This is done using
328
 
a negative stride.</li>
329
 
 
330
 
<br><br><li>
331
 
<b>int             stride() const</b><br><br>
332
 
Returns the distance between vector elements in memory.  This
333
 
will normally be 1 (referred to as <i>unit stride</i>).</li>
334
 
 
335
 
</ul>
336
 
 
337
 
<a name="memberops">
338
 
<h2>Member operators</h2>
339
 
 
340
 
<pre>
341
 
T_numtype        operator()(unsigned i) const
342
 
T_numtype&       operator()(unsigned i)
343
 
T_numtype        operator[](unsigned i) const
344
 
T_numtype&       operator[](unsigned i)
345
 
T_vector         operator()(Range r)
346
 
T_vector         operator[](Range r)
347
 
T_pick           operator[](Vector&lt;int&gt;)        ** Currently broken
348
 
</pre>
349
 
 
350
 
<a name="ops">
351
 
 
352
 
<h3>Iostream operators</h3>
353
 
 
354
 
<pre>
355
 
ostream& operator>>(ostream& os, const <i>vector expression</i>&);
356
 
</pre>
357
 
Formats a vector or vector expression for output.  In future releases,
358
 
several output formats will be supported.
359
 
 
360
 
<h3>Arithmetic operators</h3>
361
 
 
362
 
Arithmetic operators are implemented using expression templates.  These
363
 
assignment operators are supported:
364
 
 
365
 
<pre>
366
 
operator=(<i>vector expression</i>)
367
 
operator+=(<i>vector expression</i>)
368
 
operator-=(<i>vector expression</i>)
369
 
operator*=(<i>vector expression</i>)
370
 
operator/=(<i>vector expression</i>)
371
 
operator%=(<i>vector expression</i>)
372
 
operator^=(<i>vector expression</i>)
373
 
operator&=(<i>vector expression</i>)
374
 
operator|=(<i>vector expression</i>)
375
 
operator>>=(<i>vector expression</i>)
376
 
operator=(<i>vector expression</i>)
377
 
</pre>
378
 
 
379
 
<p>
380
 
A <i>vector expression</i> can be any combination of these operators
381
 
and operands, as well as use of the math functions listed later.
382
 
</p>
383
 
 
384
 
<h4>Vector expression operators</h4>
385
 
<pre>
386
 
+ - * / % ^ & | >> << 
387
 
> < >= <= == != && ||
388
 
</pre>
389
 
 
390
 
<h4>Vector expression operands</h4>
391
 
<ul>
392
 
<li>Vector&lt;T_numtype&gt;</li>
393
 
<li>Vector&lt;T_numtype2&gt; (A vector of a different type)</li>
394
 
<li>VectorPick&lt;T_numtype&gt;</li>
395
 
<li><a href="range.html">Range</a></li>
396
 
<li>Random  ** NOT YET FULLY SUPPORTED</li>
397
 
<li>Scalar constants (int,float,double,long double)</li>
398
 
<li>Complex constants (complex&lt;float&gt;, complex&lt;double&gt;, 
399
 
    complex&lt;long double&gt;)</li>
400
 
</ul>
401
 
 
402
 
<p>
403
 
Arithmetic type promotion for vectors is identical to type promotion
404
 
for built-in types. For example, adding a double constant to a 
405
 
Vector&lt;int&gt; will result in a Vector&lt;double&gt;; multiplying
406
 
a Vector&lt;long double&gt; by a Vector&lt;float&gt; will result in
407
 
a Vector&lt;long double&gt;.  Generally, the result is promoted to
408
 
which ever type preserves the greatest precision.</p>
409
 
 
410
 
<p>Note that division and multiplication of integers may result in
411
 
truncation and/or wraparound, since the result remains an integer
412
 
type.  The solution is to cast the elements of one of the vectors 
413
 
as floating-point types; see <b>cast&lt;T2&gt;</b> below.
414
 
** the cast() function is not yet implemented</p>
415
 
 
416
 
<pre>
417
 
Vector&lt;int&gt; x(5), y(5);
418
 
Vector&lt;double&gt; z(5);
419
 
 
420
 
// ...
421
 
 
422
 
z = x / y;      // Calculated using integer math, then cast as double
423
 
                // Results in truncation
424
 
 
425
 
z = x / cast&lt;double&gt;(y);   // Calculated using floating point 
426
 
 
427
 
</pre>
428
 
 
429
 
<a name="global">
430
 
<!-- <h2>Global functions</h2> -->
431
 
 
432
 
<h3>Single-operand math functions</h3>
433
 
 
434
 
<h5>Notes</h5>
435
 
<ul>
436
 
<li>Single operand math functions are evaluated using expression templates.</li>
437
 
<li>If used on an integer vector, most of the functions below will return
438
 
the answer type as a double.</li>
439
 
</ul>
440
 
 
441
 
<table border cellpadding=2>
442
 
<tr align=center><th>Function</th><th>Description</th><th>Real vectors</th><th>Complex vectors</th><th>Availability</th></tr>
443
 
<tr><td>abs</td><td>Absolute value</td>     <td>Y</td>     <td>Y</td>  <td>all</td><td>     </td></tr>
444
 
<tr><td>acos</td><td>Inverse cosine.  Elements must be in the range [-1,+1].  The resulting elements lie in [-Pi,+Pi].</td>     <td>Y</td>     <td>Y</td>  <td>all</td><td>     </td></tr>
445
 
<tr><td>acosh</td><td>Inverse hyperbolic cosine</td> <td>Y</td>     <td></td>  <td>all</td><td>     </td></tr>
446
 
 
447
 
<tr><td>arg</td>
448
 
<td>Argument (phase/angle) of a complex vector. Result is a scalar vector whose elements lie in [-Pi, +Pi].</td>
449
 
<td></td>
450
 
<td>Y</td>
451
 
<td>all<sup>b</sup></td></tr>
452
 
 
453
 
<tr><td>asin</td><td>Inverse sine.  Elements must be in the range [-1,+1].  The resulting elements lie in [-Pi,+Pi].</td>     <td>Y</td>     <td>Y</td>  <td>all</td><td>     </td></tr>
454
 
<tr><td>asinh</td><td>Inverse hyperbolic sine</td>     <td>Y</td>     <td></td>  <td>all</td><td>     </td></tr>
455
 
<tr><td>atan</td><td>Inverse tangent.  Resulting elements lie in [-Pi,+Pi].</td>     <td>Y</td>     <td>Y</td>  <td>all</td><td>     </td></tr>
456
 
<tr><td>atanh</td><td>Inverse hyperbolic tangent</td>     <td>Y</td>     <td></td>  <td>all</td><td>     </td></tr>
457
 
<tr><td>cast&lt;T2&gt;</td><td>Cast vector elements to type T2<br>** NOT YET AVAILABLE</td><td>Y</td><td>Y</td><td>some<sup>e</sup></td></tr>
458
 
<tr><td>cbrt</td><td>Cubic root</td>     <td>Y</td>     <td></td>  <td>some<sup>d</sup></td><td>     </td></tr>
459
 
<tr><td>ceil</td><td>Smallest floating integer not less than element</td>     <td>Y</td>     <td></td>  <td>all</td><td>     </td></tr>
460
 
<tr><td>class</td><td>Floating-point classification.  Result is an integer
461
 
vector with elements taking values FP_PLUS_NORM,
462
 
FP_MINUS_NORM, FP_PLUS_ZERO, FP_MINUS_ZERO, FP_PLUS_INF, FP_MINUS_INF,
463
 
FP_PLUS_DENORM, FP_MINUS_DENORM, FP_SNAN, FP_QNAN as defined in &lt;float.h&gt;
464
 
</td>
465
 
     <td>Y</td>     <td></td>  <td>some<sup>d</sup></td><td>     </td></tr>
466
 
 
467
 
<tr><td>conj</td>
468
 
<td>Complex conjugate</td>
469
 
<td></td>
470
 
<td>Y</td>
471
 
<td>all<sup>b</sup></td></tr>
472
 
 
473
 
<tr><td>cos</td><td>Cosine.  Resulting elements lie in [-1,+1].</td>     <td>Y</td>     <td>Y</td>  <td>all</td><td>     </td></tr>
474
 
<tr><td>cosh</td><td>Hyperbolic cosine</td>     <td>Y</td>     <td>Y</td>  <td>all</td><td>     </td></tr>
475
 
<tr><td>exp</td><td>Exponential.</td>     <td>Y</td>     <td>Y</td>  <td>all</td><td>     </td></tr>
476
 
<tr><td>expm1</td><td>Exponential minus one: exp(x)-1</td>     <td>Y</td>     <td></td>  <td>some<sup>c</sup></td><td>     </td></tr>
477
 
<tr><td>erf</td><td>Error function</td>     <td>Y</td>     <td></td>  <td>some<sup>c</sup></td><td>     </td></tr>
478
 
<tr><td>erfc</td><td>Complementary error function (1-erf(x)).</td>     <td>Y</td>     <td></td>  <td>some<sup>c</sup></td><td>     </td></tr>
479
 
<tr><td>fabs</td><td>Same as <b>abs</b></td>     <td>Y</td>     <td></td>  <td>all</td><td>     </td></tr>
480
 
<tr><td>finite</td><td>Nonzero if finite.  Result is integer.</td>     <td>Y</td>     <td></td>  <td>some<sup>d</sup></td><td>     </td></tr>
481
 
<tr><td>floor</td><td>Largest floating int not greater than x</td>     <td>Y</td>     <td></td>  <td>all</td><td>     </td></tr>
482
 
<tr><td>ilogb</td><td>Integer unbiased exponent</td>     <td>Y</td>     <td></td>  <td>some<sup>d</sup></td><td>     </td></tr>
483
 
 
484
 
<tr><td>imag</td>
485
 
<td>Imaginary portion of a complex vector. Result is a scalar vector which
486
 
may be used as an lvalue.</td>
487
 
<td></td>
488
 
<td>Y</td>
489
 
<td>all<sup>b</sup></td></tr>
490
 
 
491
 
<tr><td>isnan</td><td>Nonzero if x is NaNS (Signalling Not a Number) or NaNQ (Quiet Not A Number).  Result is integer.</td>     <td>Y</td>     <td></td>  <td>some<sup>d</sup></td><td>     </td></tr>
492
 
<tr><td>itrunc</td><td>Truncate and convert to integer.  Result is integer.</td>     <td>Y</td>     <td></td>  <td>some<sup>d</sup></td><td>     </td></tr>
493
 
 
494
 
<tr><td>inv</td>
495
 
<td>Inverse of a complex number</td>
496
 
<td></td>
497
 
<td>Y</td>
498
 
<td>all<sup>b</sup></td></tr>
499
 
 
500
 
<tr><td>j0</td><td>Bessel function first kind, order 0</td>     <td>Y</td>     <td></td>  <td>some<sup>c</sup></td><td>     </td></tr>
501
 
<tr><td>j1</td><td>Bessel function first kind, order 1<br>
502
 
See also y0(x), y1(x), jn(x,y) and yn(x,y).
503
 
</td>     <td>Y</td>     <td></td>  <td>some<sup>c</sup></td><td>     </td></tr>
504
 
<tr><td>lgamma</td><td>Log absolute gamma</td>     <td>Y</td>     <td></td>  <td>some<sup>c</sup></td><td>     </td></tr>
505
 
<tr><td>log</td><td>Natural logarithm</td>     <td>Y</td>     <td>Y</td>  <td>all</td><td>     </td></tr>
506
 
<tr><td>logb</td><td>Unbiased exponent (IEEE)</td>     <td>Y</td>     <td></td>  <td>some<sup>c</sup></td><td>     </td></tr>
507
 
<tr><td>log1p</td><td>Natural logarithm of (1+x)</td>     <td>Y</td>     <td></td>  <td>some<sup>c</sup></td><td>     </td></tr>
508
 
<tr><td>log10</td><td>Logarithm base 10</td>     <td>Y</td>     <td>Y</td>  <td>all</td><td>     </td></tr>
509
 
<tr><td>nearest</td><td>Nearest floating point integer to x.</td>     <td>Y</td>     <td></td>  <td>some<sup>d</sup></td><td>     </td></tr>
510
 
 
511
 
<tr><td>norm</td>
512
 
<td>Norm (magnitude) of a complex vector. Result is a scalar vector.</td>
513
 
<td></td>
514
 
<td>Y</td>
515
 
<td>all<sup>b</sup></td></tr>
516
 
 
517
 
<tr><td>real</td>
518
 
<td>Real portion of a complex vector. Result is a scalar vector which may
519
 
be used as an lvalue.</td>
520
 
<td></td>
521
 
<td>Y</td>  
522
 
<td>all<sup>b</sup></td></tr>
523
 
 
524
 
<tr><td>rint</td><td>Round to floating point integer, using the current 
525
 
floating-point rounding mode.  Rounding mode is read and set by
526
 
the functions fp_read_rnd() and fp_swap_rnd().  (See system man pages)</td>       <td>Y</td>     <td></td>  <td>some<sup>c</sup></td><td>     </td></tr>
527
 
<tr><td>rsqrt</td><td>Reciprocal square root (i.e. 1.0/sqrt(x))</td>     <td>Y</td>     <td></td>  <td>some<sup>d</sup></td><td>     </td></tr>
528
 
<tr><td>sin</td><td>Sine.  Resulting elements lie in [-1,+1].</td>     <td>Y</td>     <td>Y</td>  <td>all</td><td>     </td></tr>
529
 
<tr><td>sinh</td><td>Hyperbolic sine</td>     <td>Y</td>     <td>Y</td>  <td>all</td><td>     </td></tr>
530
 
<tr><td>sqr</td><td>Square: equivalent to x*x</td>     <td>Y</td>     <td>Y</td>  <td>all<sup>e</sup></td><td>     </td></tr>
531
 
<tr><td>sqrt</td><td>Square root</td>     <td>Y</td>     <td>Y</td>  <td>all</td><td>     </td></tr>
532
 
<tr><td>tan</td><td>Tangent</td>     <td>Y</td>     <td>Y</td>  <td>all</td><td>     </td></tr>
533
 
<tr><td>tanh</td><td>Hyperbolic tangent</td>     <td>Y</td>     <td>Y</td>  <td>all</td><td>     </td></tr>
534
 
<tr><td>trunc</td><td>Nearest floating-point integer in the direction of zero</td>     <td>Y</td>     <td></td>  <td>some<sup>c</sup></td><td>     </td></tr>
535
 
<tr><td>uitrunc</td><td>Truncate and convert to unsigned.  Result is unsigned integer.</td>     <td>Y</td>     <td></td> <td>some<sup>d</sup></td>  </tr>
536
 
<tr><td>y0</td><td>Bessel function 2nd kind, order 0</td>     <td>Y</td>     <td></td>  <td>some<sup>c</sup></td><td>     </td></tr>
537
 
<tr><td>y1</td><td>Bessel function 2nd kind, order 1
538
 
<br>See also yn(x,y) below</br></td>     <td>Y</td>     <td></td>  <td>some<sup>c</sup></td><td>     </td></tr>
539
 
</table>
540
 
 
541
 
<sup>a</sup>ANSI C math function<br>
542
 
<sup>b</sup>ANSI C++ math function<br>
543
 
<sup>c</sup>IEEE 754 standard required function<br>
544
 
<sup>d</sup>IEEE 754 recommended function<br>
545
 
<sup>e</sup>Nonstandard function specific to Blitz++<br>
546
 
<br>
547
 
 
548
 
<h3>Global math functions with two operands</h3>
549
 
 
550
 
** These functions are not yet implemented **
551
 
<pre>
552
 
 
553
 
All the two operand math functions are provided in three forms:<br>
554
 
atan2(double,vector)
555
 
atan2(vector,double)
556
 
atan2(vector,vector)
557
 
copysign(vector,double)
558
 
drem(d,d)
559
 
fmod(d,d)
560
 
frexp(d, Vector&lt;int&gt;& e)  NOT INCLUDED
561
 
hypot(d,d)
562
 
jn(int, d)                      NOT INCLUDED
563
 
ldexp(d,i)                      NOT INCLUDED
564
 
modf(d, Vector&lt;int&gt;& e)   NOT INCLUDED
565
 
max(d, d)
566
 
min(d, d)
567
 
nextafter(d, d)
568
 
polar(d,d)                      NOT INCLUDED
569
 
pow(d,d)
570
 
remainder(d,d)
571
 
scalb(d,d)
572
 
unordered(d,d)
573
 
yn(int,d)                       NOT INCLUDED
574
 
</pre>
575
 
 
576
 
<a name="global2">
577
 
<h2>Other global functions</h2>
578
 
 
579
 
(These functions <i>are</i> available)
580
 
 
581
 
<pre>
582
 
accumulate
583
 
<!-- convolve -->
584
 
dot 
585
 
delta
586
 
<!-- even -->
587
 
<!-- innerProduct  (same as dot) -->
588
 
<!-- imag -->
589
 
<!-- inversePermute -->
590
 
<!-- kronecker -->
591
 
<!-- kurtosis -->
592
 
max
593
 
maxIndex
594
 
maxValue
595
 
mean
596
 
min
597
 
minIndex
598
 
minValue
599
 
norm
600
 
<!-- odd -->
601
 
<!-- outerProduct  (same as kronecker) -->
602
 
<!-- permute -->
603
 
<!-- real -->
604
 
reverse
605
 
<!-- skewness -->
606
 
<!-- sort -->
607
 
sum
608
 
<!-- variance -->
609
 
</pre>
610
 
 
611
 
<h2>The <i>where</i> function</h2>
612
 
 
613
 
<p>
614
 
The <i>where(X,Y,Z)</i> function provides the same functionality as
615
 
the operator X ? Y : Z.  If X is logical true, then Y is returned;
616
 
otherwise, Z is returned.
617
 
</p>
618
 
 
619
 
<p>
620
 
The <i>where</i> function is implemented using expression templates.
621
 
The arguments X, Y, and Z can each be vectors, vector expressions,
622
 
<a href="range.html">Range</a>, or Vector picks.
623
 
</p>
624
 
 
625
 
<a name="example">
626
 
<h2>Example</h2>
627
 
 
628
 
Please see the files in the <a href="../examples/"><b>Blitz++/examples</b></a> directory.
629
 
</body>
630
 
</html>