UnaryF64.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. #include "UnaryF64.h"
  2. #include "Error.h"
  3. /* Upper bound of maximum matrix dimension used by Python */
  4. #define MAXMATRIXDIM 40
  5. /*
  6. Offset in input test pattern for matrix of dimension d * d.
  7. Must be coherent with Python script Matrix.py
  8. */
  9. static int cholesky_offset(int d)
  10. {
  11. int offset=14;
  12. switch (d)
  13. {
  14. case 4:
  15. offset = 14;
  16. break;
  17. case 8:
  18. offset = 79;
  19. break;
  20. case 9:
  21. offset = 143;
  22. break;
  23. case 15:
  24. offset = 224;
  25. break;
  26. case 16:
  27. offset = 449;
  28. break;
  29. default:
  30. offset = 14;
  31. break;
  32. }
  33. return(offset);
  34. }
  35. void UnaryF64::test_mat_inverse_f64()
  36. {
  37. arm_mat_inverse_f64(&this->in1,&this->out);
  38. }
  39. void UnaryF64::test_mat_cholesky_dpo_f64()
  40. {
  41. arm_mat_cholesky_f64(&this->in1,&this->out);
  42. }
  43. void UnaryF64::test_solve_upper_triangular_f64()
  44. {
  45. arm_mat_solve_upper_triangular_f64(&this->in1,&this->in2,&this->out);
  46. }
  47. void UnaryF64::test_solve_lower_triangular_f64()
  48. {
  49. arm_mat_solve_lower_triangular_f64(&this->in1,&this->in2,&this->out);
  50. }
  51. void UnaryF64::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
  52. {
  53. std::vector<Testing::param_t>::iterator it = params.begin();
  54. this->nbr = *it++;
  55. this->nbc = *it;
  56. switch(id)
  57. {
  58. case TEST_MAT_INVERSE_F64_1:
  59. input1.reload(UnaryF64::INPUTA_F64_ID,mgr,this->nbr*this->nbc);
  60. output.create(this->nbr*this->nbc,UnaryF64::OUT_F64_ID,mgr);
  61. this->in1.numRows = this->nbr;
  62. this->in1.numCols = this->nbc;
  63. this->in1.pData = input1.ptr();
  64. this->out.numRows = this->nbr;
  65. this->out.numCols = this->nbc;
  66. this->out.pData = output.ptr();
  67. break;
  68. case TEST_MAT_CHOLESKY_DPO_F64_2:
  69. {
  70. int offset=14;
  71. float64_t *p;
  72. float64_t *aPtr;
  73. input1.reload(UnaryF64::INPUTSCHOLESKY1_DPO_F64_ID,mgr);
  74. output.create(this->nbc * this->nbr,UnaryF64::OUT_F64_ID,mgr);
  75. a.create(this->nbr*this->nbc,UnaryF64::TMPA_F64_ID,mgr);
  76. /* Offsets must be coherent with the sizes used in python script
  77. Matrix.py for pattern generation */
  78. offset=cholesky_offset(this->nbr);
  79. p = input1.ptr();
  80. aPtr = a.ptr();
  81. memcpy(aPtr,p + offset,sizeof(float64_t)*this->nbr*this->nbr);
  82. this->out.numRows = this->nbr;
  83. this->out.numCols = this->nbc;
  84. this->out.pData = output.ptr();
  85. this->in1.numRows = this->nbr;
  86. this->in1.numCols = this->nbc;
  87. this->in1.pData = aPtr;
  88. }
  89. break;
  90. case TEST_SOLVE_UPPER_TRIANGULAR_F64_3:
  91. {
  92. int offset=14;
  93. float64_t *p;
  94. float64_t *aPtr;
  95. float64_t *bPtr;
  96. input1.reload(UnaryF64::INPUT_UT_DPO_F64_ID,mgr);
  97. input2.reload(UnaryF64::INPUT_RNDA_DPO_F64_ID,mgr);
  98. output.create(this->nbc * this->nbr,UnaryF64::OUT_F64_ID,mgr);
  99. a.create(this->nbr*this->nbc,UnaryF64::TMPA_F64_ID,mgr);
  100. b.create(this->nbr*this->nbc,UnaryF64::TMPB_F64_ID,mgr);
  101. /* Offsets must be coherent with the sizes used in python script
  102. Matrix.py for pattern generation */
  103. offset=cholesky_offset(this->nbr);
  104. p = input1.ptr();
  105. aPtr = a.ptr();
  106. memcpy(aPtr,&p[offset],sizeof(float64_t)*this->nbr*this->nbr);
  107. p = input2.ptr();
  108. bPtr = b.ptr();
  109. memcpy(bPtr,&p[offset],sizeof(float64_t)*this->nbr*this->nbr);
  110. this->out.numRows = this->nbr;
  111. this->out.numCols = this->nbc;
  112. this->out.pData = output.ptr();
  113. this->in1.numRows = this->nbr;
  114. this->in1.numCols = this->nbc;
  115. this->in1.pData = aPtr;
  116. this->in2.numRows = this->nbr;
  117. this->in2.numCols = this->nbc;
  118. this->in2.pData = bPtr;
  119. }
  120. break;
  121. case TEST_SOLVE_LOWER_TRIANGULAR_F64_4:
  122. {
  123. int offset=14;
  124. float64_t *p;
  125. float64_t *aPtr;
  126. float64_t *bPtr;
  127. input1.reload(UnaryF64::INPUT_LT_DPO_F64_ID,mgr);
  128. input2.reload(UnaryF64::INPUT_RNDA_DPO_F64_ID,mgr);
  129. output.create(this->nbc * this->nbr,UnaryF64::OUT_F64_ID,mgr);
  130. a.create(this->nbr*this->nbc,UnaryF64::TMPA_F64_ID,mgr);
  131. b.create(this->nbr*this->nbc,UnaryF64::TMPB_F64_ID,mgr);
  132. /* Offsets must be coherent with the sizes used in python script
  133. Matrix.py for pattern generation */
  134. offset=cholesky_offset(this->nbr);
  135. p = input1.ptr();
  136. aPtr = a.ptr();
  137. memcpy(aPtr,&p[offset],sizeof(float64_t)*this->nbr*this->nbr);
  138. p = input2.ptr();
  139. bPtr = b.ptr();
  140. memcpy(bPtr,&p[offset],sizeof(float64_t)*this->nbr*this->nbr);
  141. this->out.numRows = this->nbr;
  142. this->out.numCols = this->nbc;
  143. this->out.pData = output.ptr();
  144. this->in1.numRows = this->nbr;
  145. this->in1.numCols = this->nbc;
  146. this->in1.pData = aPtr;
  147. this->in2.numRows = this->nbr;
  148. this->in2.numCols = this->nbc;
  149. this->in2.pData = bPtr;
  150. }
  151. break;
  152. }
  153. }
  154. void UnaryF64::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  155. {
  156. }