[simd.math] # 29 Numerics library [[numerics]](./#numerics) ## 29.10 Data-parallel types [[simd]](simd#math) ### 29.10.8 basic_vec non-member operations [[simd.nonmembers]](simd.nonmembers#simd.math) #### 29.10.8.13 Mathematical functions [simd.math] [🔗](#lib:ilogb,simd) `template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr rebind_t> ilogb(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t ldexp(const V& x, const rebind_t>& exp); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t scalbn(const V& x, const rebind_t>& n); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t scalbln(const V& x, const rebind_t>& n); template<[signed_integral](concepts.arithmetic#concept:signed_integral "18.4.7 Arithmetic concepts [concepts.arithmetic]") T, class Abi> constexpr basic_vec abs(const basic_vec& j); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t abs(const V& j); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t fabs(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t ceil(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t floor(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> deduced-vec-t nearbyint(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> deduced-vec-t rint(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> rebind_t> lrint(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> rebind_t> llrint(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t round(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr rebind_t> lround(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr rebind_t> llround(const V& x); template constexpr math-common-simd-t fmod(const V0& x, const V1& y); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t trunc(const V& x); template constexpr math-common-simd-t remainder(const V0& x, const V1& y); template constexpr math-common-simd-t copysign(const V0& x, const V1& y); template constexpr math-common-simd-t nextafter(const V0& x, const V1& y); template constexpr math-common-simd-t fdim(const V0& x, const V1& y); template constexpr math-common-simd-t fmax(const V0& x, const V1& y); template constexpr math-common-simd-t fmin(const V0& x, const V1& y); template constexpr math-common-simd-t fma(const V0& x, const V1& y, const V2& z); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr rebind_t> fpclassify(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr typename deduced-vec-t::mask_type isfinite(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr typename deduced-vec-t::mask_type isinf(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr typename deduced-vec-t::mask_type isnan(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr typename deduced-vec-t::mask_type isnormal(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr typename deduced-vec-t::mask_type signbit(const V& x); template constexpr typename math-common-simd-t::mask_type isgreater(const V0& x, const V1& y); template constexpr typename math-common-simd-t::mask_type isgreaterequal(const V0& x, const V1& y); template constexpr typename math-common-simd-t::mask_type isless(const V0& x, const V1& y); template constexpr typename math-common-simd-t::mask_type islessequal(const V0& x, const V1& y); template constexpr typename math-common-simd-t::mask_type islessgreater(const V0& x, const V1& y); template constexpr typename math-common-simd-t::mask_type isunordered(const V0& x, const V1& y); ` [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19451) Let Ret denote the return type of the specialization of a function template with the name *math-func*[.](#1.sentence-1) Let *math-func-vec* denote:template Ret *math-func-vec*(Args... args) {return Ret([&](*simd-size-type* i) {*math-func*(*make-compatible-simd-t*(args)[i]...); });} [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19464) *Returns*: A value ret of type Ret, that is element-wise equal to the result of calling *math-func-vec* with the arguments of the above functions[.](#2.sentence-1) If in an invocation of a scalar overload of *math-func* for indexi in *math-func-vec* a domain, pole, or range error would occur, the value of ret[i] is unspecified[.](#2.sentence-2) [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19473) *Remarks*: It is unspecified whether errno ([[errno]](errno "19.4 Error numbers")) is accessed[.](#3.sentence-1) [🔗](#lib:acos,simd) `template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t acos(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t asin(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t atan(const V& x); template constexpr math-common-simd-t atan2(const V0& y, const V1& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t cos(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t sin(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t tan(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t acosh(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t asinh(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t atanh(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t cosh(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t sinh(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t tanh(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t exp(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t exp2(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t expm1(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t log(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t log10(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t log1p(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t log2(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t logb(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t cbrt(const V& x); template constexpr math-common-simd-t hypot(const V0& x, const V1& y); template constexpr math-common-simd-t hypot(const V0& x, const V1& y, const V2& z); template constexpr math-common-simd-t pow(const V0& x, const V1& y); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t sqrt(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t erf(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t erfc(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t lgamma(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t tgamma(const V& x); template constexpr math-common-simd-t lerp(const V0& a, const V1& b, const V2& t) noexcept; template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> deduced-vec-t assoc_laguerre(const rebind_t>& n, const rebind_t>& m, const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> deduced-vec-t assoc_legendre(const rebind_t>& l, const rebind_t>& m, const V& x); template math-common-simd-t beta(const V0& x, const V1& y); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> deduced-vec-t comp_ellint_1(const V& k); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> deduced-vec-t comp_ellint_2(const V& k); template math-common-simd-t comp_ellint_3(const V0& k, const V1& nu); template math-common-simd-t cyl_bessel_i(const V0& nu, const V1& x); template math-common-simd-t cyl_bessel_j(const V0& nu, const V1& x); template math-common-simd-t cyl_bessel_k(const V0& nu, const V1& x); template math-common-simd-t cyl_neumann(const V0& nu, const V1& x); template math-common-simd-t ellint_1(const V0& k, const V1& phi); template math-common-simd-t ellint_2(const V0& k, const V1& phi); template math-common-simd-t ellint_3(const V0& k, const V1& nu, const V2& phi); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> deduced-vec-t expint(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> deduced-vec-t hermite(const rebind_t>& n, const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> deduced-vec-t laguerre(const rebind_t>& n, const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> deduced-vec-t legendre(const rebind_t>& l, const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> deduced-vec-t riemann_zeta(const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> deduced-vec-t sph_bessel(const rebind_t>& n, const V& x); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> deduced-vec-t sph_legendre(const rebind_t>& l, const rebind_t>& m, const V& theta); template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> deduced-vec-t sph_neumann(const rebind_t>& n, const V& x); ` [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19614) Let Ret denote the return type of the specialization of a function template with the name *math-func*[.](#4.sentence-1) Let *math-func-vec* denote:template Ret *math-func-vec*(Args... args) {return Ret([&](*simd-size-type* i) {*math-func*(*make-compatible-simd-t*(args)[i]...); });} [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19627) *Returns*: A value ret of type Ret, that is element-wise approximately equal to the result of calling *math-func-vec* with the arguments of the above functions[.](#5.sentence-1) If in an invocation of a scalar overload of *math-func* for indexi in *math-func-vec* a domain, pole, or range error would occur, the value of ret[i] is unspecified[.](#5.sentence-2) [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19636) *Remarks*: It is unspecified whether errno ([[errno]](errno "19.4 Error numbers")) is accessed[.](#6.sentence-1) [🔗](#lib:frexp,simd) `template<[math-floating-point](simd.expos#concept:math-floating-point "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") V> constexpr deduced-vec-t frexp(const V& value, rebind_t>* exp); ` [7](#7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19648) Let Ret be *deduced-vec-t*[.](#7.sentence-1) Let *frexp-vec* denote:template pair> *frexp-vec*(const V& x) {int r1[Ret::size()]; Ret r0([&](*simd-size-type* i) { frexp(*make-compatible-simd-t*(x)[i], &r1[i]); }); return {r0, rebind_t(r1)};} Let ret be a value of type pair> that is the same value as the result of calling*frexp-vec*(x)[.](#7.sentence-3) [8](#8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19665) *Effects*: Sets *exp to ret.second[.](#8.sentence-1) [9](#9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19669) *Returns*: ret.first[.](#9.sentence-1) [🔗](#lib:remquo,simd) `template constexpr math-common-simd-t remquo(const V0& x, const V1& y, rebind_t>* quo); ` [10](#10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19682) Let Ret be *math-common-simd-t*[.](#10.sentence-1) Let *remquo-vec* denote:template pair> *remquo-vec*(const V0& x, const V1& y) {int r1[Ret::size()]; Ret r0([&](*simd-size-type* i) { remquo(*make-compatible-simd-t*(x)[i], *make-compatible-simd-t*(y)[i], &r1[i]); }); return {r0, rebind_t(r1)};} Let ret be a value of type pair> that is the same value as the result of calling*remquo-vec*(x, y)[.](#10.sentence-3) If in an invocation of a scalar overload of remquo for index i in *remquo-vec* a domain, pole, or range error would occur, the value of ret[i] is unspecified[.](#10.sentence-4) [11](#11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19703) *Effects*: Sets *quo to ret.second[.](#11.sentence-1) [12](#12) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19707) *Returns*: ret.first[.](#12.sentence-1) [13](#13) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19711) *Remarks*: It is unspecified whether errno ([[errno]](errno "19.4 Error numbers")) is accessed[.](#13.sentence-1) [🔗](#lib:modf,simd) `template constexpr basic_vec modf(const type_identity_t>& value, basic_vec* iptr); ` [14](#14) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19724) Let V be basic_vec[.](#14.sentence-1) Let *modf-vec* denote:pair *modf-vec*(const V& x) { T r1[Ret::size()]; V r0([&](*simd-size-type* i) { modf(V(x)[i], &r1[i]); }); return {r0, V(r1)};} Let ret be a value of type pair that is the same value as the result of calling *modf-vec*(value)[.](#14.sentence-3) [15](#15) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19739) *Effects*: Sets *iptr to ret.second[.](#15.sentence-1) [16](#16) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19743) *Returns*: ret.first[.](#16.sentence-1)