BayesF32.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #include "BayesF32.h"
  2. #include <stdio.h>
  3. #include "Error.h"
  4. #include "Test.h"
  5. void BayesF32::test_gaussian_naive_bayes_predict_f32()
  6. {
  7. int16_t p;
  8. p = arm_gaussian_naive_bayes_predict_f32(&bayes,
  9. inp,
  10. bufp,tempp);
  11. }
  12. void BayesF32::setUp(Testing::testID_t id,std::vector<Testing::param_t>& paramsArgs,Client::PatternMgr *mgr)
  13. {
  14. std::vector<Testing::param_t>::iterator it = paramsArgs.begin();
  15. this->vecDim = *it++;
  16. this->classNb = *it++;
  17. switch(id)
  18. {
  19. case BayesF32::TEST_GAUSSIAN_NAIVE_BAYES_PREDICT_F32_1:
  20. {
  21. int nbp,nbi;
  22. input.reload(BayesF32::INPUTS2_F32_ID,mgr);
  23. params.reload(BayesF32::PARAMS2_F32_ID,mgr);
  24. dims.reload(BayesF32::DIMS2_S16_ID,mgr);
  25. int16_t *dimsp=dims.ptr();
  26. nbi = dimsp[2*this->nb];
  27. nbp = dimsp[2*this->nb + 1];
  28. const float32_t *paramsp = params.ptr() + nbp;
  29. this->theta=paramsp ;
  30. this->sigma=paramsp + (this->classNb * this->vecDim);
  31. this->classPrior=paramsp + 2*(this->classNb * this->vecDim);
  32. this->epsilon=paramsp[this->classNb + 2*(this->classNb * this->vecDim)];
  33. //printf("%f %f %f\n",this->theta[0],this->sigma[0],this->classPrior[0]);
  34. // Reference patterns are not loaded when we are in dump mode
  35. predicts.reload(BayesF32::PREDICTS2_S16_ID,mgr);
  36. outputProbas.create(this->classNb,BayesF32::OUT_PROBA_F32_ID,mgr);
  37. temp.create(this->classNb,BayesF32::OUT_PROBA_F32_ID,mgr);
  38. bayes.vectorDimension=this->vecDim;
  39. bayes.numberOfClasses=this->classNb;
  40. bayes.theta=this->theta;
  41. bayes.sigma=this->sigma;
  42. bayes.classPriors=this->classPrior;
  43. bayes.epsilon=this->epsilon;
  44. this->inp = input.ptr() + nbi;
  45. this->bufp = outputProbas.ptr();
  46. this->tempp = temp.ptr();
  47. }
  48. break;
  49. }
  50. }
  51. void BayesF32::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  52. {
  53. (void)id;
  54. this->nb++;
  55. }