Hi
Does anyone know how many cycles it should take to compute square roots of 16-int integers? What might be the canonical approach if fractionals are not required?
Thanks
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.
Hi
Does anyone know how many cycles it should take to compute square roots of 16-int integers? What might be the canonical approach if fractionals are not required?
Thanks
Hi Will,
Here are two previous E2E posts that talk about the topic extensively. Let me know if you have any further questions.
Execution times: sqrt() and other library functions
MSP430: Fast Integer Sqrt() Routine
Best regards,
Caleb Overbay
Hi Will,
Here is some more information I was able to find that I think is closer to what you're looking for:
You may want to take advantage of our IQMath library. On page 92 of the MSP430 IQMathLib User's Guide it shows that the _QNsqrt() function takes ~95 CPU cycles with N being the specific IQ type (e.g. _Q12sqrt() for N=12).
This library deals with fractionals but there are a few "hidden" library functions that deal with integers (e.g. _Q0 and _IQ0 types). You can extern the following function and use it as an integer sqrt() function, there are also integer divide and string formatting functions which I’ll include the definitions for as well. The reasoning behind not defining these in the header file is that there are only a few of them implemented, the majority of the functions do not have _Q0 or _IQ0 variants so I we wanted the functions to be consistent in available types.
Function Prototype |
Description |
extern int16_t _Q0sqrt(int16_t a); |
16-bit integer square root |
extern int16_t _Q0div(int16_t a, int16_t b); |
16-bit integer divide |
extern int16_t _Q0toa(char *string, const char *format, int16_t qNInput); |
16-bit integer string formatting |
extern int32_t _IQ0sqrt(int32_t a); |
32-bit integer square root |
extern int32_t _IQ0div(int32_t a, int32_t b); |
32-bit integer divide |
extern int16_t _IQ0toa(char *string, const char *format, int32_t iqNInput); |
32-bit integer string formatting |
Best regards,
Caleb Overbay
**Attention** This is a public forum