Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

261 rinda
14 KiB

  1. #ifndef _P_MATRIX_OP_H_
  2. #define _P_MATRIX_OP_H_
  3. /// @file parallel_matrix_op.h
  4. /// @brief Librarys for operations of batched matrixes.
  5. ///
  6. ///
  7. //////////////// Section: triangle matrix <-> rectangle matrix ///////////////////////////////////
  8. ///
  9. /// @brief Calculate the corresponding index in an array for an upper-triangle(UT) matrix.
  10. ///
  11. /// @param[in] i_row - the i-th row in an upper-triangle matrix.
  12. /// @param[in] j_col - the j-th column in an upper-triangle matrix.
  13. /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix.
  14. /// @return the corresponding index in an array storage.
  15. ///
  16. unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim);
  17. ///
  18. /// @brief Upper trianglize a rectangle matrix to the corresponding upper-trangle matrix.
  19. ///
  20. /// @param[out] btriC - the batched upper-trianglized matrix C.
  21. /// @param[in] bA - a batched retangle matrix A.
  22. /// @param[in] bwidth - the width of the batched matrix A, i.e., A is a Awidth x Awidth matrix.
  23. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  24. ///
  25. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch);
  26. //////////////////// Section: matrix multiplications ///////////////////////////////
  27. ///
  28. /// @brief bC += btriA * B , in GF(16)
  29. ///
  30. /// @param[out] bC - the batched matrix C.
  31. /// @param[in] btriA - a batched UT matrix A.
  32. /// @param[in] B - a column-major matrix B.
  33. /// @param[in] Bheight - the height of B.
  34. /// @param[in] size_Bcolvec - the size of the column vector in B.
  35. /// @param[in] Bwidth - the width of B.
  36. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  37. ///
  38. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
  39. const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);
  40. ///
  41. /// @brief bC += btriA * B , in GF(256)
  42. ///
  43. /// @param[out] bC - the batched matrix C.
  44. /// @param[in] btriA - a batched UT matrix A.
  45. /// @param[in] B - a column-major matrix B.
  46. /// @param[in] Bheight - the height of B.
  47. /// @param[in] size_Bcolvec - the size of the column vector in B.
  48. /// @param[in] Bwidth - the width of B.
  49. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  50. ///
  51. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA,
  52. const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);
  53. ///
  54. /// @brief bC += btriA^Tr * B , in GF(16)
  55. ///
  56. /// @param[out] bC - the batched matrix C.
  57. /// @param[in] btriA - a batched UT matrix A. A will be transposed while multiplying.
  58. /// @param[in] B - a column-major matrix B.
  59. /// @param[in] Bheight - the height of B.
  60. /// @param[in] size_Bcolvec - the size of the column vector in B.
  61. /// @param[in] Bwidth - the width of B.
  62. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  63. ///
  64. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA,
  65. const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);
  66. ///
  67. /// @brief bC += btriA^Tr * B , in GF(256)
  68. ///
  69. /// @param[out] bC - the batched matrix C.
  70. /// @param[in] btriA - a batched UT matrix A, which will be transposed while multiplying.
  71. /// @param[in] B - a column-major matrix B.
  72. /// @param[in] Bheight - the height of B.
  73. /// @param[in] size_Bcolvec - the size of the column vector in B.
  74. /// @param[in] Bwidth - the width of B.
  75. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  76. ///
  77. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA,
  78. const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);
  79. ///
  80. /// @brief bC += (btriA + btriA^Tr) *B , in GF(16)
  81. ///
  82. /// @param[out] bC - the batched matrix C.
  83. /// @param[in] btriA - a batched UT matrix A. The operand for multiplication is (btriA + btriA^Tr).
  84. /// @param[in] B - a column-major matrix B.
  85. /// @param[in] Bheight - the height of B.
  86. /// @param[in] size_Bcolvec - the size of the column vector in B.
  87. /// @param[in] Bwidth - the width of B.
  88. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  89. ///
  90. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA,
  91. const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);
  92. ///
  93. /// @brief bC += (btriA + btriA^Tr) *B , in GF(256)
  94. ///
  95. /// @param[out] bC - the batched matrix C.
  96. /// @param[in] btriA - a batched UT matrix A. The operand for multiplication is (btriA + btriA^Tr).
  97. /// @param[in] B - a column-major matrix B.
  98. /// @param[in] Bheight - the height of B.
  99. /// @param[in] size_Bcolvec - the size of the column vector in B.
  100. /// @param[in] Bwidth - the width of B.
  101. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  102. ///
  103. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA,
  104. const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);
  105. ///
  106. /// @brief bC += A^Tr * bB , in GF(16)
  107. ///
  108. /// @param[out] bC - the batched matrix C.
  109. /// @param[in] A_to_tr - a column-major matrix A. The operand for multiplication is A^Tr.
  110. /// @param[in] Aheight - the height of A.
  111. /// @param[in] size_Acolvec - the size of a column vector in A.
  112. /// @param[in] Awidth - the width of A.
  113. /// @param[in] bB - a batched matrix B.
  114. /// @param[in] Bwidth - the width of B.
  115. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  116. ///
  117. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf16(unsigned char *bC,
  118. const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth,
  119. const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch);
  120. ///
  121. /// @brief bC += A^Tr * bB , in GF(256)
  122. ///
  123. /// @param[out] bC - the batched matrix C.
  124. /// @param[in] A_to_tr - a column-major matrix A. The operand for multiplication is A^Tr.
  125. /// @param[in] Aheight - the height of A.
  126. /// @param[in] size_Acolvec - the size of a column vector in A.
  127. /// @param[in] Awidth - the width of A.
  128. /// @param[in] bB - a batched matrix B.
  129. /// @param[in] Bwidth - the width of B.
  130. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  131. ///
  132. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf256(unsigned char *bC,
  133. const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth,
  134. const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch);
  135. ///
  136. /// @brief bC += bA^Tr * B , in GF(16)
  137. ///
  138. /// @param[out] bC - the batched matrix C.
  139. /// @param[in] bA_to_tr - a batched matrix A. The operand for multiplication is (bA^Tr).
  140. /// @param[in] Awidth_befor_tr - the width of A.
  141. /// @param[in] B - a column-major matrix B.
  142. /// @param[in] Bheight - the height of B.
  143. /// @param[in] size_Bcolvec - the size of the column vector in B.
  144. /// @param[in] Bwidth - the width of B.
  145. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  146. ///
  147. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
  148. const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);
  149. ///
  150. /// @brief bC += bA^Tr * B , in GF(256)
  151. ///
  152. /// @param[out] bC - the batched matrix C.
  153. /// @param[in] bA_to_tr - a batched matrix A. The operand for multiplication is (bA^Tr).
  154. /// @param[in] Awidth_befor_tr - the width of A.
  155. /// @param[in] B - a column-major matrix B.
  156. /// @param[in] Bheight - the height of B.
  157. /// @param[in] size_Bcolvec - the size of the column vector in B.
  158. /// @param[in] Bwidth - the width of B.
  159. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  160. ///
  161. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr,
  162. const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);
  163. ///
  164. /// @brief bC += bA * B , in GF(16)
  165. ///
  166. /// @param[out] bC - the batched matrix C.
  167. /// @param[in] bA - a batched matrix A.
  168. /// @param[in] Aheigh - the height of A.
  169. /// @param[in] B - a column-major matrix B.
  170. /// @param[in] Bheight - the height of B.
  171. /// @param[in] size_Bcolvec - the size of the column vector in B.
  172. /// @param[in] Bwidth - the width of B.
  173. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  174. ///
  175. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
  176. const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);
  177. ///
  178. /// @brief bC += bA * B , in GF(256)
  179. ///
  180. /// @param[out] bC - the batched matrix C.
  181. /// @param[in] bA - a batched matrix A.
  182. /// @param[in] Aheigh - the height of A.
  183. /// @param[in] B - a column-major matrix B.
  184. /// @param[in] Bheight - the height of B.
  185. /// @param[in] size_Bcolvec - the size of the column vector in B.
  186. /// @param[in] Bwidth - the width of B.
  187. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  188. ///
  189. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight,
  190. const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch);
  191. //////////////////// Section: "quadratric" matrix evaluation ///////////////////////////////
  192. ///
  193. /// @brief y = x^Tr * trimat * x , in GF(16)
  194. ///
  195. /// @param[out] y - the returned batched element y.
  196. /// @param[in] trimat - a batched matrix.
  197. /// @param[in] x - an input vector x.
  198. /// @param[in] dim - the dimension of matrix trimat (and x).
  199. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  200. ///
  201. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch);
  202. ///
  203. /// @brief y = x^Tr * trimat * x , in GF(256)
  204. ///
  205. /// @param[out] y - the returned batched element y.
  206. /// @param[in] trimat - a batched matrix.
  207. /// @param[in] x - an input vector x.
  208. /// @param[in] dim - the dimension of matrix trimat (and x).
  209. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  210. ///
  211. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch);
  212. ///
  213. /// @brief z = y^Tr * mat * x , in GF(16)
  214. ///
  215. /// @param[out] z - the returned batched element z.
  216. /// @param[in] y - an input vector y.
  217. /// @param[in] dim_y - the length of y.
  218. /// @param[in] mat - a batched matrix.
  219. /// @param[in] x - an input vector x.
  220. /// @param[in] dim_x - the length of x.
  221. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  222. ///
  223. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y,
  224. const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch);
  225. ///
  226. /// @brief z = y^Tr * mat * x , in GF(256)
  227. ///
  228. /// @param[out] z - the returned batched element z.
  229. /// @param[in] y - an input vector y.
  230. /// @param[in] dim_y - the length of y.
  231. /// @param[in] mat - a batched matrix.
  232. /// @param[in] x - an input vector x.
  233. /// @param[in] dim_x - the length of x.
  234. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix.
  235. ///
  236. void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y,
  237. const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch);
  238. #endif // _P_MATRIX_OP_H_