
- The C Standard Library
- The C Standard Library
- The C++ Standard Library
- C++ Library - Home
- C++ Library - <fstream>
- C++ Library - <iomanip>
- C++ Library - <ios>
- C++ Library - <iosfwd>
- C++ Library - <iostream>
- C++ Library - <istream>
- C++ Library - <ostream>
- C++ Library - <sstream>
- C++ Library - <streambuf>
- C++ Library - <atomic>
- C++ Library - <complex>
- C++ Library - <exception>
- C++ Library - <functional>
- C++ Library - <limits>
- C++ Library - <locale>
- C++ Library - <memory>
- C++ Library - <new>
- C++ Library - <numeric>
- C++ Library - <regex>
- C++ Library - <stdexcept>
- C++ Library - <string>
- C++ Library - <thread>
- C++ Library - <tuple>
- C++ Library - <typeinfo>
- C++ Library - <utility>
- C++ Library - <valarray>
- The C++ STL Library
- C++ Library - <array>
- C++ Library - <bitset>
- C++ Library - <deque>
- C++ Library - <forward_list>
- C++ Library - <list>
- C++ Library - <map>
- C++ Library - <queue>
- C++ Library - <set>
- C++ Library - <stack>
- C++ Library - <unordered_map>
- C++ Library - <unordered_set>
- C++ Library - <vector>
- C++ Library - <algorithm>
- C++ Library - <iterator>
- C++ Programming Resources
- C++ Programming Tutorial
- C++ Useful Resources
- C++ Discussion
C++ Valarray Library - acos Function
Description
It returns a valarray containing the principal values of the arc cosine of all the elements of x, expressed in radians, in the same order.
Declaration
Following is the declaration for std::acos function.
template<class T> valarray<T> acos (const valarray<T>& x);
C++11
template<class T> valarray<T> acos (const valarray<T>& x);
Parameters
x − It is containing elements of a type for which the unary function abs is defined.
Return Value
It returns a valarray containing the principal values of the arc cosine of all the elements of x, expressed in radians, in the same order.
Exceptions
Basic guarantee − if any operation performed on the elements throws an exception.
Data races
All elements effectively copied are accessed.
Example
In below example explains about std::acos function.
#include <iostream> #include <cstddef> #include <cmath> #include <valarray> int main () { double val[] = {0.10, 0.25, 0.50, 0.75, 1.5}; std::valarray<double> foo (val,5); std::valarray<double> bar = acos (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; }
Let us compile and run the above program, this will produce the following result −
foo: 0.1 0.25 0.5 0.75 1.5 bar: 1.47063 1.31812 1.0472 0.722734 nan
valarray.htm
Advertisements