89 const float_t x_interpolate) {
92 if (fabsf(x1 - x2) >= FLT_EPSILON) {
94 slope = (y2 - y1) / (x2 - x1);
102 float_t y_interpolate = y1 + (slope * (x_interpolate - x1));
104 return y_interpolate;
112 const uint32_t alternating2PatternStartFF = 0xFF00FF00u;
113 const uint32_t alternating2PatternStart00 = 0x00FF00FFu;
114 const uint32_t intermediate = ((val <<
UTIL_SHIFT_ONE_BYTE) & alternating2PatternStartFF) |
120 const uint64_t alternating2PatternStartFF = 0xFF00FF00FF00FF00uLL;
121 const uint64_t alternating2PatternStart00 = 0x00FF00FF00FF00FFuLL;
122 const uint64_t alternating4PatternStartFFFF = 0xFFFF0000FFFF0000uLL;
123 const uint64_t alternating4PatternStart0000 = 0x0000FFFF0000FFFFuLL;
133 return fminf(value1, value2);
137 uint8_t minimumValue = value1;
138 if (minimumValue > value2) {
139 minimumValue = value2;
145 uint16_t minimumValue = value1;
146 if (minimumValue > value2) {
147 minimumValue = value2;
153 int32_t absoluteValue = INT32_MAX;
154 if (value != INT32_MIN) {
155 absoluteValue = labs(value);
157 return absoluteValue;
161 int64_t absoluteValue = INT64_MAX;
162 if (value != INT64_MIN) {
163 absoluteValue = llabs(value);
165 return absoluteValue;
171 #ifdef UNITY_UNIT_TEST
Assert macro implementation.
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
int32_t MATH_AbsInt32_t(const int32_t value)
Returns the absolute value of passed int32_t value.
float_t MATH_MinimumOfTwoFloats(const float_t value1, const float_t value2)
Returns the minimum of the passed float values.
uint16_t MATH_SwapBytesUint16_t(const uint16_t val)
Swap bytes of uint16_t value.
int64_t MATH_AbsInt64_t(const int64_t value)
Returns the absolute value of passed int64_t value.
uint16_t MATH_MinimumOfTwoUint16_t(const uint16_t value1, const uint16_t value2)
Returns the minimum of the passed uint16_t values.
uint32_t MATH_SwapBytesUint32_t(const uint32_t val)
Swap bytes of uint32_t value.
void MATH_StartupSelfTest(void)
: self test for math functions that can be called at startup
float_t MATH_LinearInterpolation(const float_t x1, const float_t y1, const float_t x2, const float_t y2, const float_t x_interpolate)
Linear inter-/extrapolates a third point according to two given points.
uint8_t MATH_MinimumOfTwoUint8_t(const uint8_t value1, const uint8_t value2)
Returns the minimum of the passed uint8_t values.
uint64_t MATH_SwapBytesUint64_t(const uint64_t val)
Swap bytes of uint64_t value.
math library for often used math functions
#define UTIL_SHIFT_FOUR_BYTES
#define UTIL_SHIFT_TWO_BYTES
#define UTIL_SHIFT_ONE_BYTE