ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
dsps_sqrt.h File Reference
#include "dsp_err.h"
Include dependency graph for dsps_sqrt.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define dsps_sqrt_f32   dsps_sqrt_f32_ansi
#define dsps_sqrtf_f32   dsps_sqrtf_f32_ansi
#define dsps_inverted_sqrtf_f32   dsps_inverted_sqrtf_f32_ansi

Functions

esp_err_t dsps_sqrt_f32_ansi (const float *input, float *output, int len)
 square root approximation
float dsps_sqrtf_f32_ansi (const float data)
 square root approximation
float dsps_inverted_sqrtf_f32_ansi (float data)
 inverted square root approximation

Macro Definition Documentation

◆ dsps_inverted_sqrtf_f32

#define dsps_inverted_sqrtf_f32   dsps_inverted_sqrtf_f32_ansi

Definition at line 88 of file dsps_sqrt.h.

◆ dsps_sqrt_f32

#define dsps_sqrt_f32   dsps_sqrt_f32_ansi

Definition at line 86 of file dsps_sqrt.h.

◆ dsps_sqrtf_f32

#define dsps_sqrtf_f32   dsps_sqrtf_f32_ansi

Definition at line 87 of file dsps_sqrt.h.

Function Documentation

◆ dsps_inverted_sqrtf_f32_ansi()

float dsps_inverted_sqrtf_f32_ansi ( float data)

inverted square root approximation

The function takes inverted square root approximation x ~ 1/sqrt(y); The implementation use ANSI C and could be compiled and run on any platform

Parameters
[in]datainput value
Returns
  • inverted square root value

Definition at line 44 of file dsps_sqrt_f32_ansi.c.

45{
46 const float x2 = data * 0.5F;
47 const float threehalfs = 1.5F;
48
49 union {
50 float f;
51 uint32_t i;
52 } conv = {data}; // member 'f' set to value of 'data'.
53 conv.i = 0x5f3759df - ( conv.i >> 1 );
54 conv.f *= ( threehalfs - ( x2 * conv.f * conv.f ) );
55 return conv.f;
56}
static float data[128 *2]
Definition test_fft2r.c:34

References data.

◆ dsps_sqrt_f32_ansi()

esp_err_t dsps_sqrt_f32_ansi ( const float * input,
float * output,
int len )

square root approximation

The function takes square root approximation x[i] ~ sqrt(y[i]); i=[0..len) The implementation use ANSI C and could be compiled and run on any platform

Parameters
[in]inputinput array
outputoutput array
lenamount of operations for arrays
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

Definition at line 29 of file dsps_sqrt_f32_ansi.c.

30{
31 if (NULL == input) {
33 }
34 if (NULL == output) {
36 }
37
38 for (int i = 0 ; i < len ; i++) {
39 output[i] = dsps_sqrtf_f32_ansi(input[i]);
40 }
41 return ESP_OK;
42}
#define ESP_ERR_DSP_PARAM_OUTOFRANGE
float dsps_sqrtf_f32_ansi(float f)
square root approximation
#define ESP_OK
Definition esp_err.h:23

References dsps_sqrtf_f32_ansi(), ESP_ERR_DSP_PARAM_OUTOFRANGE, and ESP_OK.

Here is the call graph for this function:

◆ dsps_sqrtf_f32_ansi()

float dsps_sqrtf_f32_ansi ( const float data)
inline

square root approximation

The function takes square root approximation x ~ sqrt(y); The implementation use ANSI C and could be compiled and run on any platform

Parameters
[in]datainput value
Returns
  • square root value

Definition at line 19 of file dsps_sqrt_f32_ansi.c.

20{
21 int result;
22 int *f_ptr = (int *)&f;
23 result = 0x1fbb4000 + (*f_ptr >> 1);
24 const int *p = &result;
25 float *f_result = (float *)p;
26 return *f_result;
27}

Referenced by dsps_sqrt_f32_ansi().

Here is the caller graph for this function: