std::asin(std::valarray)(3)
π NAME π
This is the manual page for std::asin(std::valarray) β thatβs std::asin(std::valarray)(3) in the manual, section 3 β from the C++ Standard Libary manual. Yes bestie, the title is literally std::asin(std::valarray) and this whole page is its moment π
β¨.
πΈ Synopsis πΈ
Defined in header <valarray>
template< class T >
valarray<T> asin( const valarray<T>& va );
For each element in va computes arc sine of the value of the element. Itβs giving βelement-by-element arc sineβ energy, no cap π¦.
π Parameters π
vaβ value array to apply the operation to. Thatβs the whole parameter list, bestie β justvacarrying the array vibes π«Ά.
π Return value π
A value array containing arc sines of the values in va. Slay, it gives you back a whole array of results, not just one number π.
π¦ Notes π¦
Okay so the tea: an unqualified function (asin) is used to perform the computation. If such function is not available, std::asin is used due to argument-dependent lookup. ADL doing its little main-character thing β¨.
The function can be implemented with the return type different from std::valarray. In this case, the replacement type has the following properties:
- All
constmember functions ofstd::valarrayare provided. std::valarray,std::slice_array,std::gslice_array,std::mask_arrayandstd::indirect_arraycan be constructed from the replacement type.- For every function taking a
const std::valarray<T>&exceptbegin()andend()(since C++11), identical functions taking the replacement types shall be added. - For every function taking two
const std::valarray<T>&arguments, identical functions taking every combination ofconst std::valarray<T>&and replacement types shall be added. - The return type does not add more than two levels of template nesting over the most deeply-nested argument type.
π§ Possible implementation π§
template<class T>
valarray<T> asin(const valarray<T>& va)
{
valarray<T> other = va;
for (T& i : other)
i = asin(i);
return other; // proxy object may be returned
}
π Example π
The page says // Run this code right before the snippet:
#include <cmath>
#include <iostream>
#include <numbers>
#include <valarray>
int main()
{
// take common y-values from unit circle
const double s22 = std::sqrt(2.0) / 2.0;
const double s32 = std::sqrt(3.0) / 2.0;
const std::valarray<double> v1 =
{-1.0, -s32, -s22, -0.5, 0.0, 0.5, s22, s32, 1.0};
// fill with results of radians to degrees conversion
const std::valarray<double> v2 =
std::asin(v1) * 180.0 / std::numbers::pi;
for (std::cout << std::showpos; double n : v2)
std::cout << n << "Β° ";
std::cout << '\n';
}
β Output β
-90Β° -60Β° -45Β° -30Β° +0Β° +30Β° +45Β° +60Β° +90Β°
π See also π
acos(std::valarray)β applies the functionstd::acosto each element ofvalarray(function template).atan(std::valarray)β applies the functionstd::atanto each element ofvalarray(function template).atan2(std::valarray)β applies the functionstd::atan2to avalarrayand a value (function template).sin(std::valarray)β applies the functionstd::sinto each element ofvalarray(function template).asinβ computes arc sine (arcsin(x)) (function).asinfβ computes arc sine (arcsin(x)) (function).asinlβ computes arc sine (arcsin(x)) (function);(C++11);(C++11).asin(std::complex)β computes arc sine of a complex number (arcsin(z)) (function template)(C++11).
π Hidden category π
- Pages with unreviewed LWG DR marker
Source/version/date shoutout, bestie: this page is from http://cppreference.com, version/date 2024.06.10, and the page itself is std::asin(std::valarray)(3) β bye, love u, go compute some arc sines ππ«Άβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms