Page 1 of 1

RSQRT on ESP32

Posted: Tue Dec 24, 2024 9:11 am
by alex000090
Dear all,

Could you help me, is there an RSQRT (single precision) hardware or software function in ESP-IDF? I can't find information about it.

Re: RSQRT on ESP32

Posted: Wed Dec 25, 2024 8:50 am
by nopnop2002
You can use these in esp-idf.

Code: Select all

#include <stdio.h>
#include <math.h>

void app_main()
{
    double dx = 2.0;
    double da = sqrt(dx);

    float fx = 2.0;
    float fa = sqrt(fx);
    fa = sqrtf(fx);

    long double ldx = 2.0;
    long double lda = sqrt(ldx);
    lda = sqrtl(ldx);
}

Re: RSQRT on ESP32

Posted: Wed Dec 25, 2024 11:22 am
by alex000090
Thanks for your answer!

I mean is there a hardware or software implementation of "Fast inverse square root" algorithm on ESP32?
https://en.wikipedia.org/wiki/Fast_inverse_square_root

Re: RSQRT on ESP32

Posted: Thu Dec 26, 2024 1:43 am
by MicroController
is there a hardware or software implementation of "Fast inverse square root" algorithm on ESP32?
https://en.wikipedia.org/wiki/Fast_inverse_square_root
What do you mean? - As soon as you copy the six lines of code into your application, there is a software implementation.

Another option is to take the assembler instruction sequences for reciprocal square root from the Xtensa Instruction Set Summary, which should be faster than using "1.0f/sqrtf(x)", i.e. a floating point sqrt PLUS a floating point division.

Re: RSQRT on ESP32

Posted: Thu Dec 26, 2024 8:14 am
by alex000090
You are absolutely right. I mean there is better software algorithm whish was incorporated into esp-idf maybe. As well as, if I'm correct, in the CPU may be hardware RSQRT command which is can be used and also incorporated into esp-idf.