I can suggest you that to carefully go through the following code of lines that can demonstrates you how to use the tanh() function in the C++ programming as follows :
Code:
#include <iostream>
#include <cmath>
#include <valarray>
using namespace std;
int main ()
{
double vl[] = {0.35, 1.22, 3.4};
vlarray<double> f (vl,3);
vlarray<double> br = tanh (f);
cout << "f: ";
for (size_t k=0; k<f.size(); ++k)
cout << f[k] << ' ';
cout << endl;
cout << "br: ";
for (size_t k=0; k<br.size(); ++k)
cout << br[k] << ' ';
cout << endl;
return 0;
}
Output:
Code:
f: 0.35 1.22 3.4
br: 0.335376 0.839654 0.997775
Bookmarks