Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
Miscellaneous
complex
exception
functional
iterator
limits
locale
memory
new
numeric
stdexcept
typeinfo
utility
valarray
valarray
classes:
gslice
gslice_array
indirect_array
mask_array
slice
slice_array
valarray
global functions:
abs
acos
asin
atan
atan2
cos
cosh
exp
log
log10
pow
sin
sinh
sqrt
tan
tanh


exp

function template
<valarray>
template<class T> valarray<T> exp (const valarray<T>& x);

Compute exponential of valarray elements

Returns a valarray object containing the exponential function values of all the elements of x.

This function overloads cmath's exp function.

Parameters

x
valarray containing elements of a type for which the unary function exp is defined.

Return value

A valarray object with the exponential function values of the elements of x.

Example

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
// exp valarray example
#include <iostream>
#include <cmath>
#include <valarray>
using namespace std;
int main ()
{
  double val[] = {1.1, 2.2, 4.4, 8.8};
  valarray<double> foo (val,4);
  valarray<double> bar = exp (foo);
  cout << "foo: ";
  for (size_t i=0; i<foo.size(); ++i)
	  cout << foo[i] << ' ';
  cout << endl;
  cout << "bar: ";
  for (size_t i=0; i<bar.size(); ++i)
	  cout << bar[i] << ' ';
  cout << endl;
  return 0;
}


Output:

foo: 1.1 2.2 4.4 8.8
bar: 3.00417 9.02501 81.4509 6634.24

See also