infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 16 of 16

Thread: Math Cordic Square root API

  1. #11
    Beginner Beginner akshatra is on a distinguished road
    Join Date
    Feb 2017
    Posts
    28
    Points
    90
    Any one who can tell me how can I convert any number like 200, 1000 ... to Q15 or Q31 format?

  2. #12
    Advanced Advanced aurixuser is on a distinguished road
    Join Date
    Jan 2017
    Location
    China
    Posts
    167
    Points
    870
    Conversion
    Float to Q

    To convert a number from floating point to Qm.n format:

    Multiply the floating point number by 2n
    Round to the nearest integer

    Q to float

    To convert a number from Qm.n format to floating point:

    Convert the number to floating point as if it were an integer, in other words remove the binary point
    Multiply by 2?n

  3. #13

  4. #14
    Beginner Beginner akshatra is on a distinguished road
    Join Date
    Feb 2017
    Posts
    28
    Points
    90
    @aurixuser previously as per you

    Code:
    You don't understand Q Format.
    
    It could only represent [-1,1) range.
    
    You will need to normalize the input and output.
    Now if I try to change 200 to Q15
    Code:
    200 * 2^15 = 200 * 32768 = 6553600
    But this value is greater than 1. Moreover 200 is not a floating point number, so is it required to change it to Q format?

    Its a request can you please give me an example for just one value like 200, 1500 to find the square root using API defined in math.h

    So that not only me but others can also understand the concept.

  5. #15
    Advanced Advanced aurixuser is on a distinguished road
    Join Date
    Jan 2017
    Location
    China
    Posts
    167
    Points
    870
    For example.

    //First , normalization
    float v1_f = 200/32767.0;
    float v2_f = 32767/2147483647.0;

    //second, convert the normalized results into Q Format
    v1_q15 = float_to_q15(v1_f);
    v2_q31 = float_to_q31(v2_f);

    //Third, do the Q format math
    ......
    ....
    //Finally, convert the result of Q Format math into the final float result if you need, it is optional
    float result_1_f = q15_to_float(result_1_q15);
    float result_2_f = q31_to_float(result_2_q31);

  6. #16
    New Member New Member Daniel.Sanchez is on a distinguished road
    Join Date
    Aug 2018
    Location
    Brazil
    Posts
    6
    Points
    115
    It is incredible, how a beginner user couldn't receive any descent support in this forum. I am very dissapointed with the kind of answers from an advanced user.

+ Reply to Thread
Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.