<valarray>
template<class T> valarray<T> cosh (const valarray<T>& x);
Compute hyperbolic cosine of valarray elements
Returns a valarray object containing the hyperbolic cosines of all the elements of x.
This function overloads cmath's cosh function.
Parameters
- x
- valarray containing elements of a type for which the unary function cosh is defined.
Return value
A valarray object with the hyperbolic cosine 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
|
// cosh valarray example
#include <iostream>
#include <cmath>
#include <valarray>
using namespace std;
int main ()
{
double val[] = {0.35, 1.22, 3.4};
valarray<double> foo (val,3);
valarray<double> bar = cosh (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: 0.35 1.22 3.4
bar: 1.06188 1.84121 14.9987
|
See also
sinh | Compute hyperbolic sine of valarray elements (function template) |
tanh | Compute hyperbolic tangent of valarray elements (function template) |
|