|
|
@@ -211,7 +211,7 @@ void ALGO_InvertBitsN_Group(uint32_t* genBuf, uint32_t* srcBuf, uint8_t len)
|
|
|
}
|
|
|
/* End of Easy way to implement Invert ****************************************/
|
|
|
|
|
|
-float NumberSuitScop(float valueIn, float scopMin, float scopMax, float step)
|
|
|
+float ALGO_NumberSuitScop(float valueIn, float scopMin, float scopMax, float step)
|
|
|
{
|
|
|
uint16_t errCount = 0;
|
|
|
while((valueIn < scopMin || valueIn > scopMax) && (uint32_t)step != 0){
|
|
|
@@ -224,6 +224,36 @@ float NumberSuitScop(float valueIn, float scopMin, float scopMax, float step)
|
|
|
return valueIn;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+float ALGO_Sqrt_NewtonNumber(float x)
|
|
|
+{
|
|
|
+ float xhalf = 0.5f * x;
|
|
|
+ int i = *(int*)&x;
|
|
|
+
|
|
|
+ if(!x) return 0;
|
|
|
+
|
|
|
+ i = 0x5f375a86 - (i >> 1); // beautiful number
|
|
|
+ x = *(float*)&i;
|
|
|
+ x = x * (1.5f - xhalf * x * x); // Newton iteration
|
|
|
+ x = x * (1.5f - xhalf * x * x); // Newton iteration
|
|
|
+ x = x * (1.5f - xhalf * x * x); // Newton iteration
|
|
|
+ return (1 / x);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+float ALGO_GetRms(uint16_t currentValue, uint16_t currentNum, float sumValue, uint16_t wholeNum)
|
|
|
+{
|
|
|
+ float value = sumValue;
|
|
|
+ value += (currentValue * currentValue);
|
|
|
+ if(currentNum >= wholeNum){
|
|
|
+ value /= currentNum;
|
|
|
+ value = ALGO_Sqrt(value);
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
#ifdef __DEBUG_ALGO_AlgorithmBase_ATY
|
|
|
void ALGO_Swap_Test(void)
|
|
|
{
|