11constexpr float inf = std::numeric_limits<float>::infinity();
 
   20  if (x == -std::numeric_limits<float>::infinity()) {
 
   22  } 
else if (x == std::numeric_limits<float>::infinity() || std::isnan(x)) {
 
   28  x = std::max(-80.f, std::min(x, 80.f));
 
   29  ipart = std::floor(x + 0.5);
 
   32  x = 1.535336188319500e-4f;
 
   33  x = x * fpart + 1.339887440266574e-3f;
 
   34  x = x * fpart + 9.618437357674640e-3f;
 
   35  x = x * fpart + 5.550332471162809e-2f;
 
   36  x = x * fpart + 2.402264791363012e-1f;
 
   37  x = x * fpart + 6.931472028550421e-1f;
 
   38  x = x * fpart + 1.000000000000000f;
 
   42  epart.
i = (int(ipart) + 127) << 23;
 
 
   51  if (t > 0.927734375f) {
 
   54        -1.72853470e-5f, t, 3.83197126e-4f); 
 
   56        -3.88396438e-3f, t, 2.42546219e-2f); 
 
   57    r = std::fma(r, s, 
u);
 
   58    r = std::fma(r, t, -1.06777877e-1f); 
 
   59    r = std::fma(r, t, -6.34846687e-1f); 
 
   60    r = std::fma(r, t, -1.28717512e-1f); 
 
   61    r = std::fma(r, t, -t);
 
   63    r = 1.0f - std::exp(r);
 
   64    r = std::copysign(r, a);
 
   68    r = std::fma(r, s, 4.99119423e-3f); 
 
   69    r = std::fma(r, s, -2.67681349e-2f); 
 
   70    r = std::fma(r, s, 1.12819925e-1f); 
 
   71    r = std::fma(r, s, -3.76125336e-1f); 
 
   72    r = std::fma(r, s, 1.28379166e-1f); 
 
   73    r = std::fma(r, a, a);
 
 
   79  auto t = std::fma(a, 0.0f - a, 1.0f);
 
   82  if (std::abs(t) > 6.125f) { 
 
   84    p = std::fma(p, t, 2.93243101e-8f); 
 
   85    p = std::fma(p, t, 1.22150334e-6f); 
 
   86    p = std::fma(p, t, 2.84108955e-5f); 
 
   87    p = std::fma(p, t, 3.93552968e-4f); 
 
   88    p = std::fma(p, t, 3.02698812e-3f); 
 
   89    p = std::fma(p, t, 4.83185798e-3f); 
 
   90    p = std::fma(p, t, -2.64646143e-1f); 
 
   91    p = std::fma(p, t, 8.40016484e-1f); 
 
   94    p = std::fma(p, t, 1.43285448e-7f); 
 
   95    p = std::fma(p, t, 1.22774793e-6f); 
 
   96    p = std::fma(p, t, 1.12963626e-7f); 
 
   97    p = std::fma(p, t, -5.61530760e-5f); 
 
   98    p = std::fma(p, t, -1.47697632e-4f); 
 
   99    p = std::fma(p, t, 2.31468678e-3f); 
 
  100    p = std::fma(p, t, 1.15392581e-2f); 
 
  101    p = std::fma(p, t, -2.32015476e-1f); 
 
  102    p = std::fma(p, t, 8.86226892e-1f); 
 
 
  108  template <
typename T>
 
 
  130  template <
typename T>
 
 
  137  template <
typename T>
 
  139    return std::acosh(x);
 
 
 
  144  template <
typename T>
 
 
  151  template <
typename T>
 
  153    return std::asinh(x);
 
 
 
  158  template <
typename T>
 
 
  165  template <
typename T>
 
  167    return std::atan2(y, x);
 
 
 
  172  template <
typename T>
 
  174    return std::atanh(x);
 
 
 
  179  template <
typename T>
 
 
  219  template <
typename T>
 
 
  226  template <
typename T>
 
 
  233  template <
typename T>
 
  235    return static_cast<T
>(
fast_erf(
static_cast<float>(x)));
 
 
 
  240  template <
typename T>
 
  242    return static_cast<T
>(
fast_erfinv(
static_cast<float>(x)));
 
 
 
  247  template <
typename T>
 
 
  258  template <
typename T>
 
 
  265  template <
typename T>
 
  267    return std::floor(x);
 
 
 
  299  template <
typename T>
 
 
  306  template <
typename T>
 
 
  313  template <
typename T>
 
  315    return std::log10(x);
 
 
 
  320  template <
typename T>
 
 
  327  template <
typename T>
 
 
  334  template <
typename T>
 
 
  341  template <
typename T>
 
  347    return {std::rint(x.real()), std::rint(x.imag())};
 
 
 
  352  template <
typename T>
 
  354    auto one = 
static_cast<decltype(x)
>(1.0);
 
 
 
  360  template <
typename T>
 
  362    return (x > T(0)) - (x < T(0));
 
 
 
  383  template <
typename T>
 
 
  390  template <
typename T>
 
 
  397  template <
typename T>
 
 
  404  template <
typename T>
 
 
  411  template <
typename T>
 
  413    return static_cast<decltype(x)
>(1.0) / std::sqrt(x);
 
 
 
  418  template <
typename T>
 
 
  425  template <
typename T>
 
 
  432  template <
typename T>
 
 
  439  template <
typename T>
 
 
  446  template <
typename T>
 
  447  std::enable_if_t<std::is_integral_v<T> & !std::is_signed_v<T>, T> 
operator()(
 
  450    return numerator % denominator;
 
 
  453  template <
typename T>
 
  454  std::enable_if_t<std::is_integral_v<T> & std::is_signed_v<T>, T> 
operator()(
 
  457    auto r = numerator % denominator;
 
  458    if (r != 0 && (r < 0 != denominator < 0))
 
 
  463  template <
typename T>
 
  467    auto r = std::fmod(numerator, denominator);
 
  468    if (r != 0 && (r < 0 != denominator < 0)) {
 
 
  475    return numerator % denominator;
 
 
 
  480  template <
typename T>
 
 
  487  template <
typename T>
 
  489    return x == y || (std::isnan(x) && std::isnan(y));
 
 
 
  494  template <
typename T>
 
 
  501  template <
typename T>
 
 
  508  template <
typename T>
 
 
  515  template <
typename T>
 
 
  522  template <
typename T>
 
  523  std::enable_if_t<std::is_integral_v<T>, T> 
operator()(T x, T y) {
 
  524    return (x > y) ? x : y;
 
 
  527  template <
typename T>
 
  528  std::enable_if_t<!std::is_integral_v<T>, T> 
operator()(T x, T y) {
 
  532    return (x > y) ? x : y;
 
 
 
  537  template <
typename T>
 
  538  std::enable_if_t<std::is_integral_v<T>, T> 
operator()(T x, T y) {
 
  539    return x < y ? x : y;
 
 
  542  template <
typename T>
 
  543  std::enable_if_t<!std::is_integral_v<T>, T> 
operator()(T x, T y) {
 
  547    return x < y ? x : y;
 
 
 
  552  template <
typename T>
 
  554    constexpr float inf = std::numeric_limits<float>::infinity();
 
  557    return (minval == -inf || maxval == inf)
 
  559        : 
static_cast<decltype(x)
>(
 
  560              maxval + std::log1p(
fast_exp(minval - maxval)));
 
 
 
  565  template <
typename T>
 
 
  572  template <
typename T>
 
 
  579  template <
typename T>
 
  581    return std::pow(base, 
exp);
 
 
  584  template <
typename T>
 
 
  599  template <
typename T>
 
 
  606  template <
typename T>
 
 
  613  template <
typename T>
 
 
  620  template <
typename T>
 
  622    return condition ? x : y;
 
 
 
  627  template <
typename T>
 
 
  634  template <
typename T>
 
 
  641  template <
typename T>
 
 
  648  template <
typename T>
 
 
  655  template <
typename T>
 
 
 
array log1p(const array &a, StreamOrDevice s={})
Natural logarithm of one plus elements in the array: log(1 + a).
 
array expm1(const array &a, StreamOrDevice s={})
Computes the expm1 function of the elements of an array.
 
array exp(const array &a, StreamOrDevice s={})
Exponential of the elements of an array.
 
float fast_exp(float x)
Definition ops.h:19
 
float fast_erf(float a)
Definition ops.h:47
 
float fast_erfinv(float a)
Definition ops.h:78
 
T operator()(T x)
Definition ops.h:109
 
uint8_t operator()(uint8_t x)
Definition ops.h:112
 
uint64_t operator()(uint64_t x)
Definition ops.h:121
 
uint16_t operator()(uint16_t x)
Definition ops.h:115
 
bool operator()(bool x)
Definition ops.h:124
 
uint32_t operator()(uint32_t x)
Definition ops.h:118
 
T operator()(T x, T y)
Definition ops.h:433
 
T operator()(T x)
Definition ops.h:131
 
T operator()(T x)
Definition ops.h:138
 
T operator()(T x)
Definition ops.h:145
 
T operator()(T x)
Definition ops.h:152
 
T operator()(T y, T x)
Definition ops.h:166
 
T operator()(T x)
Definition ops.h:159
 
T operator()(T x)
Definition ops.h:173
 
T operator()(T x, T y)
Definition ops.h:628
 
T operator()(T x, T y)
Definition ops.h:635
 
T operator()(T x, T y)
Definition ops.h:642
 
uint8_t operator()(uint8_t x)
Definition ops.h:195
 
T operator()(T x)
Definition ops.h:180
 
uint32_t operator()(uint32_t x)
Definition ops.h:201
 
int8_t operator()(int8_t x)
Definition ops.h:183
 
int16_t operator()(int16_t x)
Definition ops.h:186
 
bool operator()(bool x)
Definition ops.h:207
 
uint16_t operator()(uint16_t x)
Definition ops.h:198
 
uint64_t operator()(uint64_t x)
Definition ops.h:204
 
int32_t operator()(int32_t x)
Definition ops.h:189
 
int64_t operator()(int64_t x)
Definition ops.h:192
 
complex64_t operator()(complex64_t x)
Definition ops.h:213
 
T operator()(T x)
Definition ops.h:220
 
T operator()(T x)
Definition ops.h:227
 
T operator()(T x, T y)
Definition ops.h:440
 
bool operator()(T x, T y)
Definition ops.h:481
 
T operator()(T x)
Definition ops.h:234
 
T operator()(T x)
Definition ops.h:241
 
T operator()(T x)
Definition ops.h:248
 
complex64_t operator()(complex64_t x)
Definition ops.h:252
 
T operator()(T x)
Definition ops.h:259
 
T operator()(T x)
Definition ops.h:266
 
uint32_t operator()(uint32_t x)
Definition ops.h:287
 
uint16_t operator()(uint16_t x)
Definition ops.h:284
 
uint8_t operator()(uint8_t x)
Definition ops.h:281
 
int32_t operator()(int32_t x)
Definition ops.h:275
 
int64_t operator()(int64_t x)
Definition ops.h:278
 
bool operator()(bool x)
Definition ops.h:293
 
int8_t operator()(int8_t x)
Definition ops.h:269
 
uint64_t operator()(uint64_t x)
Definition ops.h:290
 
int16_t operator()(int16_t x)
Definition ops.h:272
 
bool operator()(T x, T y)
Definition ops.h:502
 
bool operator()(T x, T y)
Definition ops.h:495
 
T operator()(T x, T y)
Definition ops.h:649
 
bool operator()(T x, T y)
Definition ops.h:516
 
bool operator()(T x, T y)
Definition ops.h:509
 
T operator()(T x)
Definition ops.h:314
 
T operator()(T x)
Definition ops.h:321
 
T operator()(T x)
Definition ops.h:307
 
T operator()(T x, T y)
Definition ops.h:553
 
T operator()(T x)
Definition ops.h:300
 
T operator()(T x, T y)
Definition ops.h:607
 
T operator()(T x)
Definition ops.h:328
 
T operator()(T x, T y)
Definition ops.h:614
 
std::enable_if_t< std::is_integral_v< T >, T > operator()(T x, T y)
Definition ops.h:523
 
std::enable_if_t<!std::is_integral_v< T >, T > operator()(T x, T y)
Definition ops.h:528
 
std::enable_if_t<!std::is_integral_v< T >, T > operator()(T x, T y)
Definition ops.h:543
 
std::enable_if_t< std::is_integral_v< T >, T > operator()(T x, T y)
Definition ops.h:538
 
T operator()(T x, T y)
Definition ops.h:566
 
bool operator()(T x, T y)
Definition ops.h:488
 
T operator()(T x)
Definition ops.h:335
 
bool operator()(T x, T y)
Definition ops.h:573
 
std::enable_if_t<!std::is_integral_v< T >, T > operator()(T base, T exp)
Definition ops.h:580
 
std::enable_if_t< std::is_integral_v< T >, T > operator()(T base, T exp)
Definition ops.h:585
 
std::enable_if_t<!std::is_integral_v< T >, T > operator()(T numerator, T denominator)
Definition ops.h:464
 
std::enable_if_t< std::is_integral_v< T > &!std::is_signed_v< T >, T > operator()(T numerator, T denominator)
Definition ops.h:447
 
std::enable_if_t< std::is_integral_v< T > &std::is_signed_v< T >, T > operator()(T numerator, T denominator)
Definition ops.h:454
 
complex64_t operator()(complex64_t numerator, complex64_t denominator)
Definition ops.h:474
 
T operator()(T x, T y)
Definition ops.h:656
 
T operator()(T x)
Definition ops.h:342
 
complex64_t operator()(complex64_t x)
Definition ops.h:346
 
T operator()(T x)
Definition ops.h:412
 
T operator()(bool condition, T x, T y)
Definition ops.h:621
 
T operator()(T x)
Definition ops.h:353
 
uint64_t operator()(uint64_t x)
Definition ops.h:373
 
T operator()(T x)
Definition ops.h:361
 
uint8_t operator()(uint8_t x)
Definition ops.h:364
 
uint16_t operator()(uint16_t x)
Definition ops.h:367
 
complex64_t operator()(complex64_t x)
Definition ops.h:377
 
uint32_t operator()(uint32_t x)
Definition ops.h:370
 
T operator()(T x)
Definition ops.h:384
 
T operator()(T x)
Definition ops.h:391
 
T operator()(T x)
Definition ops.h:405
 
T operator()(T x)
Definition ops.h:398
 
T operator()(T x, T y)
Definition ops.h:600
 
T operator()(T x)
Definition ops.h:419
 
T operator()(T x)
Definition ops.h:426
 
uint32_t u
Definition bf16.h:17
 
float f
Definition ops.h:16