BayesF16.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #include "BayesF16.h"
  2. #include <stdio.h>
  3. #include "Error.h"
  4. #include "Test.h"
  5. void BayesF16::test_gaussian_naive_bayes_predict_f16()
  6. {
  7. int16_t p;
  8. p = arm_gaussian_naive_bayes_predict_f16(&bayes,
  9. inp,
  10. bufp,tempp);
  11. }
  12. void BayesF16::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 BayesF16::TEST_GAUSSIAN_NAIVE_BAYES_PREDICT_F16_1:
  20. {
  21. int nbp,nbi;
  22. input.reload(BayesF16::INPUTS2_F16_ID,mgr);
  23. params.reload(BayesF16::PARAMS2_F16_ID,mgr);
  24. dims.reload(BayesF16::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 float16_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(BayesF16::PREDICTS2_S16_ID,mgr);
  36. outputProbas.create(this->classNb,BayesF16::OUT_PROBA_F16_ID,mgr);
  37. temp.create(this->classNb,BayesF16::OUT_PROBA_F16_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 BayesF16::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  52. {
  53. (void)id;
  54. (void)mgr;
  55. this->nb++;
  56. }