Lib math : undefined reference to `log10'


#1

Hi all,

I try to use the C log10 function in a custom AxoObject but I have this error message : undefined reference to `log10'
What is the best way to get a base-10 logarithm ?

Jérôme


#2

I recommend avoiding double precision floating point, the math library call 'd be log10f, but not sure if that's linked in. If it is not (can't test right now), you can get around by using the e-base logarithm since
log(x) = ln(x)/ln(10)
where log(x) is the 10-base logarithm (log10 in c++) and ln(x) is the natural (e-base) logarithm (log(x) in c++)
logf(x) (the single precision e-base logarithm in c++) is linked in, and dividing by ln(10) can be replaced with a multiplication by 0.43429448f


#3

Thanks Johannes.
I confirm, log10f is not linked too.
I'll try your solution and I give you a feedback, coming soon.


#4

My object works fine with your solution (sorry for the newbie question, expressing base 10 logarithm with natural logarithm is a common math formula...).
Perhaps another newbie question, I try to convert a floating-point numbers algorithm to fixed-point numbers. I have a root mean square value (computed on a 128 samples window) and should have this value expressed in decibel. For this I apply this formula : 10*log10f(val). Is there a fast way to compute base 10 logarithm with fixed-point numbers ?


#5

check "math/log" for a fixed point log2 approximation


#6

Thanks ! I thought that "Float_t" was a real float type in "math/log" object. Sorry for the noise.