function template
<valarray>
std::logtemplate<class T> valarray<T> log (const valarray<T>& x);
Compute natural logarithm of valarray elements
Returns a valarray containing the natural logarithm (base-e logarithm) of all the elements of x, in the same order.The function calls log (unqualified) once for each element.
This function overloads cmath's log.
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
// log valarray example
#include <iostream> // std::cout
#include <cstddef> // std::size_t
#include <cmath> // std::log(double)
#include <valarray> // std::valarray, std::log(valarray)
int main ()
{
double val[] = {5.0, 6.6, 8.0, 9.9};
std::valarray<double> foo (val,4);
std::valarray<double> bar = log (foo);
std::cout << "foo:";
for (std::size_t i=0; i<foo.size(); ++i)
std::cout << ' ' << foo[i];
std::cout << '\n';
std::cout << "bar:";
for (std::size_t i=0; i<bar.size(); ++i)
std::cout << ' ' << bar[i];
std::cout << '\n';
return 0;
}
foo: 5 6.6 8 9.9 bar: 1.60944 1.88707 2.07944 2.29253
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4