Page 1 of 1

Is there any function of calculate fractional power in dsp_lib

Posted: Tue Oct 15, 2019 8:24 am
by link0513
Hi I want to calculate the integer to the fraction power about fixed point number, like (10^0.1), but I don't find any function about this in dsp_lip. Anyone know?

Re: Is there any function of calculate fractional power in dsp_lib

Posted: Sun Oct 20, 2019 4:21 pm
by ahenshaw
Would exp(log(10)*0.1) work for you?

Re: Is there any function of calculate fractional power in dsp_lib

Posted: Sun Oct 20, 2019 4:42 pm
by CousinItt
AFAIK the dsp_lib doesn't have a function to do this directly. You can use dsp_math_exp and dsp_math_log if the errors are low enough to suit you and speed and input range are OK, using the identity a^b = e^(b ln(a)).

Oops sorry ahenshaw - didn't see your reply.

Re: Is there any function of calculate fractional power in dsp_lib

Posted: Mon Oct 21, 2019 1:09 pm
by johned
ahenshaw and CousinItt are correct however I would caution against using floating point maths because the xcore is a fixed point architecture.
This means that floating point maths is calculated using a software library and hence is very slow.
I would recommend using QFormat for your real-time code.
lib_dsp supports QFormat by default.

Best regards,
John

Re: Is there any function of calculate fractional power in dsp_lib

Posted: Mon Oct 28, 2019 2:29 am
by link0513
Thanks very much for all