Krita Source Code Documentation
Loading...
Searching...
No Matches
OptiDiv< _impl > Struct Template Reference

#include <KoStreamedMath.h>

Public Types

using float_v = xsimd::batch<float, _impl>
 

Static Public Member Functions

static ALWAYS_INLINE float divScalar (const float &divident, const float &divisor)
 
static ALWAYS_INLINE float_v divVector (const float_v &divident, const float_v &divisor)
 

Detailed Description

template<typename _impl>
struct OptiDiv< _impl >

Definition at line 120 of file KoStreamedMath.h.

Member Typedef Documentation

◆ float_v

template<typename _impl >
using OptiDiv< _impl >::float_v = xsimd::batch<float, _impl>

Definition at line 121 of file KoStreamedMath.h.

Member Function Documentation

◆ divScalar()

template<typename _impl >
static ALWAYS_INLINE float OptiDiv< _impl >::divScalar ( const float & divident,
const float & divisor )
inlinestatic

Definition at line 123 of file KoStreamedMath.h.

124 {
125#ifdef __SSE__
126 float result = NAN;
127
128 __m128 x = _mm_set_ss(divisor);
129 __m128 y = _mm_set_ss(divident);
130 x = _mm_rcp_ss(x);
131 x = _mm_mul_ss(x, y);
132
133 _mm_store_ss(&result, x);
134 return result;
135#elif defined __ARM_NEON
136 auto x = vdupq_n_f32(divisor);
137 auto y = vdupq_n_f32(divident);
138 x = vrecpeq_f32(x);
139 x = vmulq_f32(x, y);
140
141 return vgetq_lane_f32(x, 0);
142#else
143 return (1.f / divisor) * divident;
144#endif
145 }

◆ divVector()

template<typename _impl >
static ALWAYS_INLINE float_v OptiDiv< _impl >::divVector ( const float_v & divident,
const float_v & divisor )
inlinestatic

Definition at line 147 of file KoStreamedMath.h.

148 {
149 return divident * xsimd::reciprocal(divisor);
150 }

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