Krita Source Code Documentation
Loading...
Searching...
No Matches
VcExtraMath Class Reference

#include <vc_extra_math.h>

Static Public Member Functions

template<typename A >
static xsimd::batch< float, Aerf (const xsimd::batch< float, A > x)
 

Detailed Description

Definition at line 15 of file vc_extra_math.h.

Member Function Documentation

◆ erf()

template<typename A >
static xsimd::batch< float, A > VcExtraMath::erf ( const xsimd::batch< float, A > x)
inlinestatic

Our version of erf() is about 10% faster than the version in xsimd::erf(), because we require less precision. We don't need too much of precision to calculate 8-bit masks anyway.

Definition at line 21 of file vc_extra_math.h.

22 {
29 using float_v = xsimd::batch<float, A>;
30 using float_m = typename float_v::batch_bool_type;
31 float_v xa = xsimd::abs(x);
32 float_m precisionLimit = xa >= float_v(9.3f); // wrong result for any number beyond this
33 xa = xsimd::set_zero(xa, precisionLimit);
34 float_v sign(1.0f);
35 float_m invertMask = x < float_v(0.f);
36 sign = xsimd::select(invertMask, float_v(-1.f), sign);
37
38 // CONSTANTS
39 float a1 = 0.254829592f;
40 float a2 = -0.284496736f;
41 float a3 = 1.421413741f;
42 float a4 = -1.453152027f;
43 float a5 = 1.061405429f;
44 float p = 0.3275911f;
45
46 float_v t = 1.0f / (1.0f + p * xa);
47 float_v y = 1.0f - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * exp(-xa * xa);
48 y = xsimd::set_one(y, precisionLimit);
49 return sign * y;
50 }
const Params2D p
auto set_one(const batch< T, A > &src, const batch_bool< T, A > &mask) noexcept
auto set_zero(const batch< T, A > &src, const batch_bool< T, A > &mask) noexcept

References p, xsimd::set_one(), xsimd::set_zero(), and sign().


The documentation for this class was generated from the following file: