This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

question about _rsqrsp() and _rsqrdp() function

Hi Dears,

    while want to use the sqrt() function as C, I get the _rsqrsp() and _rsqrdp() in SPRU187 document, but when try this function, I get below result with code as:

int m;
float ff;
double dd;
for (m=1;m<100;m++){
ff=(float)m;
dd=(double)m;
dprintf("%d sp:%f-%f dp:%f %f\n",m,ff,_rsqrsp(ff),dd,_rsqrdp(dd));
}

    Seems the result is not properly set, and have to use the reciprocal value, could any one help to confirm?

regards,

David

1 sp:1.000000-1.000000 dp:1.000000 1.000000
2 sp:2.000000-0.707031 dp:2.000000 0.707031
3 sp:3.000000-0.578125 dp:3.000000 0.578125
4 sp:4.000000-0.500000 dp:4.000000 0.500000
5 sp:5.000000-0.447266 dp:5.000000 0.447266
6 sp:6.000000-0.408203 dp:6.000000 0.408203
7 sp:7.000000-0.377930 dp:7.000000 0.377930
8 sp:8.000000-0.353516 dp:8.000000 0.353516
9 sp:9.000000-0.333008 dp:9.000000 0.333008
10 sp:10.000000-0.316406 dp:10.000000 0.316406
11 sp:11.000000-0.301758 dp:11.000000 0.301758
12 sp:12.000000-0.289063 dp:12.000000 0.289063
13 sp:13.000000-0.277344 dp:13.000000 0.277344
14 sp:14.000000-0.267578 dp:14.000000 0.267578
15 sp:15.000000-0.257813 dp:15.000000 0.257813
16 sp:16.000000-0.250000 dp:16.000000 0.250000
17 sp:17.000000-0.242676 dp:17.000000 0.242676
18 sp:18.000000-0.235840 dp:18.000000 0.235840
19 sp:19.000000-0.229492 dp:19.000000 0.229492
20 sp:20.000000-0.223633 dp:20.000000 0.223633
21 sp:21.000000-0.218262 dp:21.000000 0.218262
22 sp:22.000000-0.213379 dp:22.000000 0.213379
23 sp:23.000000-0.208496 dp:23.000000 0.208496
24 sp:24.000000-0.204102 dp:24.000000 0.204102
25 sp:25.000000-0.200195 dp:25.000000 0.200195
26 sp:26.000000-0.196289 dp:26.000000 0.196289
27 sp:27.000000-0.192383 dp:27.000000 0.192383
28 sp:28.000000-0.188965 dp:28.000000 0.188965
29 sp:29.000000-0.185547 dp:29.000000 0.185547
30 sp:30.000000-0.182617 dp:30.000000 0.182617
31 sp:31.000000-0.179688 dp:31.000000 0.179688
32 sp:32.000000-0.176758 dp:32.000000 0.176758
33 sp:33.000000-0.174316 dp:33.000000 0.174316
34 sp:34.000000-0.171387 dp:34.000000 0.171387
35 sp:35.000000-0.168945 dp:35.000000 0.168945
36 sp:36.000000-0.166504 dp:36.000000 0.166504

  • David,

    Which value do you think is set wrong. Other than the '-' minus sign in front of one of the values, these are all correct.

    Before using any intrinsic, you will need to look in the C Compiler User's Guide for the definition of these intrinsics. The Compiler UG also shows the instruction that is used for the intrinsics, so you can look at the complete definition in the CPU & Instruction Set Reference Guide where all the assembly instructions are described in detail.

    All intrinsics are tools for accessing these special assembly instructions that are not routinely used by the C Compiler.

    There is not an assembly instruction for performing the square root function directly, but you may be able to use these two intrinsics if their definitions fit what you need.

    Please let us know if you are unable to find this information in the C Compiler UG.

    Regards,
    RandyP

  • Hi David,

    Adding to the above thread, you shall see the equivalent Assembly instruction for rsqrdp & rsqrsp & its appropriate description in

    Table 7-7. TMS320C6700, C6700+, C6740, and C6600 C/C++ Compiler Intrinsics which is in Page No 218. Please see the below link for more info.

    http://www.ti.com/lit/ug/spru187u/spru187u.pdf

    double _rsqrdp (double src)  RSQRDP -  Computes the approximate 64-bit double square root reciprocal

    float _rsqrsp (float src)  RSQRSP - Computes the approximate 32-bit float square root reciprocal


    Thanks & regards,

    Sivaraj K

    ------------------------------------------------------------------------------------------------
    Please click the
    Verify Answer button on this post if it answers your question.
    ------------------------------------------------------------------------------------------------
  • Randy,

        This line is good enough to clear my doubt as I want to know how to use _rsqrsp() to ge same as sqrt() in C. 

    “There is not an assembly instruction for performing the square root function directly, but you may be able to use these two intrinsics if their definitions fit what you need.”

       All the other words are nonsensical words , we come here for solve problems, not for been educated basic things.


    regards,

    David