|
| 1 | +#ifndef SPQLIOS_Q120_ARITHMETIC_H |
| 2 | +#define SPQLIOS_Q120_ARITHMETIC_H |
| 3 | + |
| 4 | +#include <stdint.h> |
| 5 | + |
| 6 | +#include "../commons.h" |
| 7 | +#include "q120_common.h" |
| 8 | + |
| 9 | +typedef struct _q120_mat1col_product_baa_precomp q120_mat1col_product_baa_precomp; |
| 10 | +typedef struct _q120_mat1col_product_bbb_precomp q120_mat1col_product_bbb_precomp; |
| 11 | +typedef struct _q120_mat1col_product_bbc_precomp q120_mat1col_product_bbc_precomp; |
| 12 | + |
| 13 | +EXPORT q120_mat1col_product_baa_precomp* q120_new_vec_mat1col_product_baa_precomp(); |
| 14 | +EXPORT void q120_delete_vec_mat1col_product_baa_precomp(q120_mat1col_product_baa_precomp*); |
| 15 | +EXPORT q120_mat1col_product_bbb_precomp* q120_new_vec_mat1col_product_bbb_precomp(); |
| 16 | +EXPORT void q120_delete_vec_mat1col_product_bbb_precomp(q120_mat1col_product_bbb_precomp*); |
| 17 | +EXPORT q120_mat1col_product_bbc_precomp* q120_new_vec_mat1col_product_bbc_precomp(); |
| 18 | +EXPORT void q120_delete_vec_mat1col_product_bbc_precomp(q120_mat1col_product_bbc_precomp*); |
| 19 | + |
| 20 | +// ell < 10000 |
| 21 | +EXPORT void q120_vec_mat1col_product_baa_ref(q120_mat1col_product_baa_precomp*, const uint64_t ell, q120b* const res, |
| 22 | + const q120a* const x, const q120a* const y); |
| 23 | +EXPORT void q120_vec_mat1col_product_bbb_ref(q120_mat1col_product_bbb_precomp*, const uint64_t ell, q120b* const res, |
| 24 | + const q120b* const x, const q120b* const y); |
| 25 | +EXPORT void q120_vec_mat1col_product_bbc_ref(q120_mat1col_product_bbc_precomp*, const uint64_t ell, q120b* const res, |
| 26 | + const q120b* const x, const q120c* const y); |
| 27 | + |
| 28 | +EXPORT void q120_vec_mat1col_product_baa_avx2(q120_mat1col_product_baa_precomp*, const uint64_t ell, q120b* const res, |
| 29 | + const q120a* const x, const q120a* const y); |
| 30 | +EXPORT void q120_vec_mat1col_product_bbb_avx2(q120_mat1col_product_bbb_precomp*, const uint64_t ell, q120b* const res, |
| 31 | + const q120b* const x, const q120b* const y); |
| 32 | +EXPORT void q120_vec_mat1col_product_bbc_avx2(q120_mat1col_product_bbc_precomp*, const uint64_t ell, q120b* const res, |
| 33 | + const q120b* const x, const q120c* const y); |
| 34 | + |
| 35 | +EXPORT void q120x2_vec_mat1col_product_bbc_ref(q120_mat1col_product_bbc_precomp* precomp, const uint64_t ell, |
| 36 | + q120b* const res, const q120b* const x, const q120c* const y); |
| 37 | +EXPORT void q120x2_vec_mat1col_product_bbc_avx2(q120_mat1col_product_bbc_precomp* precomp, const uint64_t ell, |
| 38 | + q120b* const res, const q120b* const x, const q120c* const y); |
| 39 | +EXPORT void q120x2_vec_mat2cols_product_bbc_ref(q120_mat1col_product_bbc_precomp* precomp, const uint64_t ell, |
| 40 | + q120b* const res, const q120b* const x, const q120c* const y); |
| 41 | +EXPORT void q120x2_vec_mat2cols_product_bbc_avx2(q120_mat1col_product_bbc_precomp* precomp, const uint64_t ell, |
| 42 | + q120b* const res, const q120b* const x, const q120c* const y); |
| 43 | + |
| 44 | +/** |
| 45 | + * @brief extract 1 q120x2 block from one q120 ntt vectors |
| 46 | + * @param nn the size of each vector |
| 47 | + * @param blk the block id to extract (<nn/2) |
| 48 | + * @param dst the output: nrows q120x2's dst[i] = src[i](blk) |
| 49 | + * @param src the input: nrows q120 ntt vecs's |
| 50 | + */ |
| 51 | +EXPORT void q120x2_extract_1blk_from_q120b_ref(uint64_t nn, uint64_t blk, |
| 52 | + q120x2b* const dst, // 8 doubles |
| 53 | + const q120b* const src // a reim vector |
| 54 | +); |
| 55 | +EXPORT void q120x2_extract_1blk_from_q120c_ref(uint64_t nn, uint64_t blk, |
| 56 | + q120x2c* const dst, // 8 doubles |
| 57 | + const q120c* const src // a reim vector |
| 58 | +); |
| 59 | +EXPORT void q120x2_extract_1blk_from_q120b_avx(uint64_t nn, uint64_t blk, |
| 60 | + q120x2b* const dst, // 8 doubles |
| 61 | + const q120b* const src // a reim vector |
| 62 | +); |
| 63 | +EXPORT void q120x2_extract_1blk_from_q120c_avx(uint64_t nn, uint64_t blk, |
| 64 | + q120x2c* const dst, // 8 doubles |
| 65 | + const q120c* const src // a reim vector |
| 66 | +); |
| 67 | + |
| 68 | +/** |
| 69 | + * @brief extract 1 reim4 block from nrows reim vectors of m complexes |
| 70 | + * @param nn the size of each q120 |
| 71 | + * @param nrows the number of q120 (ntt) vectors |
| 72 | + * @param blk the block id to extract (<m/4) |
| 73 | + * @param dst the output: nrows q120x2's dst[i] = src[i](blk) |
| 74 | + * @param src the input: nrows q120 ntt vectors |
| 75 | + */ |
| 76 | +EXPORT void q120x2_extract_1blk_from_contiguous_q120b_ref( |
| 77 | + uint64_t nn, uint64_t nrows, uint64_t blk, |
| 78 | + q120x2b* const dst, // nrows * 2 q120 |
| 79 | + const q120b* const src // a contiguous array of nrows q120b vectors |
| 80 | +); |
| 81 | +EXPORT void q120x2_extract_1blk_from_contiguous_q120b_avx( |
| 82 | + uint64_t nn, uint64_t nrows, uint64_t blk, |
| 83 | + q120x2b* const dst, // nrows * 2 q120 |
| 84 | + const q120b* const src // a contiguous array of nrows q120b vectors |
| 85 | +); |
| 86 | + |
| 87 | +/** |
| 88 | + * @brief saves 1 single q120x2 block in a q120 vectors of size nn |
| 89 | + * @param nn the size of the output q120 |
| 90 | + * @param blk the block id to save (<nn/2) |
| 91 | + * @param dest the output q120b vector: dst(blk) = src |
| 92 | + * @param src the input q120x2b |
| 93 | + */ |
| 94 | +EXPORT void q120x2b_save_1blk_to_q120b_ref(uint64_t nn, uint64_t blk, |
| 95 | + q120b* dest, // 1 reim vector of length m |
| 96 | + const q120x2b* src // 8 doubles |
| 97 | +); |
| 98 | +EXPORT void q120x2b_save_1blk_to_q120b_avx(uint64_t nn, uint64_t blk, |
| 99 | + q120b* dest, // 1 reim vector of length m |
| 100 | + const q120x2b* src // 8 doubles |
| 101 | +); |
| 102 | + |
| 103 | +EXPORT void q120_add_bbb_simple(uint64_t nn, q120b* const res, const q120b* const x, const q120b* const y); |
| 104 | + |
| 105 | +EXPORT void q120_add_ccc_simple(uint64_t nn, q120c* const res, const q120c* const x, const q120c* const y); |
| 106 | + |
| 107 | +EXPORT void q120_c_from_b_simple(uint64_t nn, q120c* const res, const q120b* const x); |
| 108 | + |
| 109 | +EXPORT void q120_b_from_znx64_simple(uint64_t nn, q120b* const res, const int64_t* const x); |
| 110 | + |
| 111 | +EXPORT void q120_c_from_znx64_simple(uint64_t nn, q120c* const res, const int64_t* const x); |
| 112 | + |
| 113 | +EXPORT void q120_b_to_znx128_simple(uint64_t nn, __int128_t* const res, const q120b* const x); |
| 114 | + |
| 115 | +#endif // SPQLIOS_Q120_ARITHMETIC_H |
0 commit comments