BayesF32.cpp 2.1 KB

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