Mathfunctions

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hi there,
I am developing a 3axis drive using XMC 1100. For that I need to calculate the sqrt and possibly other functions. Dave does not recognize "sqrt()". Is there a library for math functions and how can I use it whihin Dave?

thanks for your reply.
0 Likes
8 Replies
Not applicable
Hello,

do you include math.h in your source and the lib m in your link? I'm running math functions on the XMC 4500 and it's running fine.

BTW: Why do you use sqrt()? It's double and last long. Maybe you try the float version sqrtf() and include the implicit double warning -Wdouble-promotion
in your compiler switches to be aware that there is a cast to double which may eat up time.

Kind regards
Kurt
0 Likes
Not applicable
thanks a lot,

Your hint took me to the Dave Development internet site. I found a release note that indicates that this math app is not suitable for XMC1100. Anyway I will try and see how far I get.

kind regards,

Felix
0 Likes
Not applicable
Hi Felix,

maybe you download fdlibm or glibc as source code, extract the required modules and add these files as source to your project.
With this you have the option to use float or double representation and react proper to the type of arguments(float integer ecc.)

Kind regards
Kurt
0 Likes
Not applicable
You could always implement a sqrt() using the Newton-Raphson method. The only problem is, the Newton-Raphson method involves a divide. Perhaps an XMC1300 would be more appropriate as it provides divide capability. There are plenty of integer sqrt() options available.
0 Likes
Not applicable
Hi Kurt and smays,

I have now implemented the Newton method which is certainly better than the Heron method which I considered first. Thanks for your comment

Kurt, where can I find fdlibm or glibc? thanks

Felix
0 Likes
Not applicable

I have now implemented the Newton method

Cool!!! By the way, are you still working with the 1100 (XMC1100)? If so, do you have a feel for how long the divide takes?

Steve.
0 Likes
Not applicable
Hi Felix

fdlibm : http://www.netlib.org/fdlibm/
gclib: https://www.gnu.org/software/libc/

Kind regards
Kurt
0 Likes
Not applicable
thanks for the fdlibm and libc references.

I do not yet know yet, how long the devide will take, so I appreciated the hint with the Newton method.
Nevertheless, I can offload calculation and download readily processed data, so that workload can be removed from the XMC1100 if needed.

kind regards,

Felix
0 Likes