MCPcopy Create free account
hub / github.com/FastLED/FastLED / FL_TEST_FILE

Function FL_TEST_FILE

tests/fl/math/fixed_point.cpp:110–5230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108#include "fl/stl/static_assert.h"
109
110FL_TEST_FILE(FL_FILEPATH) {
111
112using namespace fl;
113
114namespace { // Anonymous namespace for fixed_point tests
115
116// Scalar/raw type matching raw() return type.
117template <typename T>
118using raw_t = decltype(T().raw());
119
120// Compile-time check that T::raw() is constexpr.
121template <typename T>
122constexpr bool constexpr_raw_check(float f) {
123 return T(f).raw(), true;
124}
125
126// ============================================================================
127// Type-Specific Accuracy Bounds (Template Specializations)
128// ============================================================================
129// Measured accuracy values × 1.2 safety margin for regression detection.
130// Measured from sweep tests across function input ranges.
131
132template<typename T> struct accuracy_bounds;
133
134template<> struct accuracy_bounds<s4x12> {
135 // Measured: sin=0.000472 cos=~0.000472 atan=0.001075 sqrt=0.001367
136 // asin=0.004179 acos=0.00417447 rsqrt=0.0369682
137 // pow(x,0.5)=0.000929 pow(x,2.0)=0.004456 pow(x,3.0)=7.99876
138 // smooth=0.001047
139 static constexpr float sin_max = 0.0006f; // measured: 0.000472
140 static constexpr float cos_max = 0.0006f; // measured: ~0.000472
141 static constexpr float atan_max = 0.0013f; // measured: 0.001075
142 static constexpr float atan2_max = 0.0013f; // measured: ~0.001075
143 static constexpr float asin_max = 0.0051f; // measured: 0.004179
144 static constexpr float acos_max = 0.0051f; // measured: 0.00417447
145 static constexpr float sqrt_max = 0.0017f; // measured: 0.001367
146 static constexpr float rsqrt_max = 0.045f; // measured: 0.0369682
147 static constexpr float pow_x_0_5_max = 0.0012f; // measured: 0.000929
148 static constexpr float pow_x_0_6_max = 0.002f; // estimated
149 static constexpr float pow_x_2_0_max = 0.0054f; // measured: 0.004456
150 static constexpr float pow_x_3_0_max = 9.6f; // measured: 7.99876
151 static constexpr float smoothstep_max = 0.0013f; // measured: 0.001047
152};
153
154template<> struct accuracy_bounds<s8x8> {
155 // Measured: sin=0.007704 atan=0.013903 sqrt=0.014063
156 // asin=0.0542276 acos=0.0547113 rsqrt=1.63281
157 // pow(x,0.5)=0.020217 pow(x,0.6)=0.0465422 pow(x,2.0)=0.299292
158 // pow(x,3.0)=2.06516 smooth=0.017023
159 static constexpr float sin_max = 0.01f; // measured: 0.007704
160 static constexpr float cos_max = 0.01f; // measured: ~0.007704
161 static constexpr float atan_max = 0.017f; // measured: 0.013903
162 static constexpr float atan2_max = 0.017f; // measured: ~0.013903
163 static constexpr float asin_max = 0.066f; // measured: 0.0542276
164 static constexpr float acos_max = 0.066f; // measured: 0.0547113
165 static constexpr float sqrt_max = 0.017f; // measured: 0.014063
166 static constexpr float rsqrt_max = 2.0f; // measured: 1.63281
167 static constexpr float pow_x_0_5_max = 0.025f; // measured: 0.020217

Callers

nothing calls this directly

Calls 15

TEnum · 0.85
floorFunction · 0.85
s8x8Class · 0.85
clampFunction · 0.85
sqrtFunction · 0.85
u16x16Function · 0.85
printfFunction · 0.85
measure_sinFunction · 0.85
print_rowFunction · 0.85
measure_cosFunction · 0.85
measure_atanFunction · 0.85
measure_atan2Function · 0.85

Tested by

no test coverage detected