ARM-software / CMSIS_5

CMSIS Version 5 Development Repository
http://arm-software.github.io/CMSIS_5/index.html
Apache License 2.0
1.33k stars 1.08k forks source link

CMSIS-DSP: Redundant expressions about arm_bayes_example #1001

Closed dangorogoro closed 4 years ago

dangorogoro commented 4 years ago

According to the function of arm_gaussian_naive_bayes_predict_f32, it puts each probability to the buffer and returns the index of the highest probability value.

But in the example code of arm_bayes_example_f32.c, it calculates the max value in the result buffer even though arm_gaussian_naive_bayes_predict_f32 returns it.

  arm_gaussian_naive_bayes_predict_f32(&S, in, result);

  arm_max_f32(result, NB_OF_CLASSES, &maxProba, &index);

I think this is a bit redundant. So, unless there is a clear reason to write it this way, wouldn't it be less confusing to write the following?

  index = arm_gaussian_naive_bayes_predict_f32(&S, in, result);

  maxProba = result[index];

I've written a pull request, so please take a look at that as well. #1002

Thank you.

christophe0606 commented 4 years ago

Hi @dangorogoro ,

You're totally right !

It is redundant. In the example I wanted to extract the probability in addition to the index. But it does not make sense to re-compute the max for this.

christophe0606 commented 4 years ago

I'll merge your pull request a bit later.