cancel
Showing results for 
Search instead for 
Did you mean: 

How to use "arm_math.h" to quickly calculate logarithmic with STM32F429IGT6 (using Keil uVision5) ?

ZeroOne
Associate III

I try to use "arm_math.h", but I can't find any function about logarithmic operation in "arm_math.h". Is there none logarithmic in this, or am I not found? 0693W00000WJXITQA5.jpg

9 REPLIES 9
ZeroOne
Associate III

Do I have to use the traditional "math.h" to calculate the logarithm ? I'm worried that "math.h" will count slowly.:sad_but_relieved_face:

AScha.3
Chief III

who knows...did you test real speed ?

+

https://arm-software.github.io/CMSIS_5/DSP/html/group__vlog.html

If you feel a post has answered your question, please click "Accept as Solution".

No,I haven't tested it. It would definitely be slower in theory, because FPU will only optimize float-type variables, whereas traditional logarithmic algorithm are based on "double".

+

Super thanks! I think that's what I'm looking for!:smiling_face_with_heart_eyes:

ZeroOne
Associate III

I feel like I've found the logarithmic operation function:backhand_index_pointing_down:?But.....how to use?What does the third parameter(blockSize) mean:astonished_face: ?

void arm_vlog_f16(const float16_t * pSrc,float16_t * pDst,uint32_t blockSize )0693W00000WJYPVQA5.jpg

AScha.3
Chief III

use: search, read, learn - how to load/include cmsis lib.

vector - seem is to convert an array in -> out , as needed for fft output

If you feel a post has answered your question, please click "Accept as Solution".
Piranha
Chief II

> traditional logarithmic algorithm are based on "double"

Have you looked at C documentation, which is newer than 23 years old?

https://en.cppreference.com/w/c/numeric/math/log

> What does the third parameter(blockSize) mean:astonished_face: ?

Vector means an array. DSP is not some magic, which can turn everything magically faster. The speed is mainly gained by using a SIMD style instructions and parallel calculation. For a calculation of a single number the vectored functions will probably be slower than the appropriate standard C functions.

Thank you so much:* ! What you said was very thorough and clear:thumbs_up:. I didn't find out that "Vector" means "array" before, which led to a misunderstanding.:face_with_medical_mask:

Yes, I just tested it, and "vector" does mean "array"! After understanding this, "blockSize" is very clear---number of samples in each array:face_with_tears_of_joy:

Piranha
Chief II

So to sum up how to use a (single) float numbers... Use the standard C functions with "f" suffix like logf() and add "f" suffix to constants like 1.618f. Also I would recommend compiling with -Wdouble-promotion for GCC and, if available, a similar option for other compilers.