A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/valarray/log10/ below:

function template

<valarray>

std::log10
template<class T> valarray<T> log10 (const valarray<T>& x);

Compute common logarithm of valarray elements

Returns a valarray containing the common logarithm (base-10 logarithm) of all the elements of x, in the same order.

The function calls log10 (unqualified) once for each element.

This function overloads cmath's log10.



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

Return value A valarray object with the common logarithms 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
// log10 valarray example
#include <iostream>     // std::cout
#include <cstddef>      // std::size_t
#include <cmath>        // std::log10(double)
#include <valarray>     // std::valarray, std::log10(valarray)

int main ()
{
  double val[] = {1.0, 10.0, 100.0, 200.0};
  std::valarray<double> foo (val,4);

  std::valarray<double> bar = log10 (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;
}

Output:
foo: 1 10 100 200
bar: 0 1 2 2.30103


See also
log10 (cmath)
Compute common logarithm (function)
log
Compute natural logarithm of valarray elements (function template)
exp
Compute exponential of valarray elements (function template)
pow
Compute power of valarray elements (function template)

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