RSQRT on ESP32

alex000090
Posts: 9
Joined: Tue Dec 24, 2024 9:07 am

RSQRT on ESP32

Postby alex000090 » Tue Dec 24, 2024 9:11 am

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.

nopnop2002
Posts: 347
Joined: Thu Oct 03, 2019 10:52 pm
Contact:

Re: RSQRT on ESP32

Postby nopnop2002 » Wed Dec 25, 2024 8:50 am

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);
}

alex000090
Posts: 9
Joined: Tue Dec 24, 2024 9:07 am

Re: RSQRT on ESP32

Postby alex000090 » Wed Dec 25, 2024 11:22 am

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

MicroController
Posts: 2661
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: RSQRT on ESP32

Postby MicroController » Thu Dec 26, 2024 1:43 am

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.

alex000090
Posts: 9
Joined: Tue Dec 24, 2024 9:07 am

Re: RSQRT on ESP32

Postby alex000090 » Thu Dec 26, 2024 8:14 am

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.

Who is online

Users browsing this forum: Semrush [Bot], YisouSpider and 3 guests