arnaucube
arnaucube/poulpyPublic Self-hosted repository
poulpy/poulpy-backend/src/cpu_spqlios/spqlios-arithmetic/test/testlib/vec_rnx_layout.h
poulpy-backend/src/cpu_spqlios/spqlios-arithmetic/test/testlib/vec_rnx_layout.hRaw
 1#ifndef SPQLIOS_EXT_VEC_RNX_LAYOUT_H
 2#define SPQLIOS_EXT_VEC_RNX_LAYOUT_H
 3
 4#include "../../spqlios/arithmetic/vec_rnx_arithmetic.h"
 5#include "fft64_dft.h"
 6#include "negacyclic_polynomial.h"
 7#include "reim4_elem.h"
 8#include "test_commons.h"
 9
10/** @brief a test memory layout for rnx i64 polynomials vectors */
11class rnx_vec_f64_layout {
12  uint64_t n;
13  uint64_t size;
14  uint64_t slice;
15  double* data_start;
16  uint8_t* region;
17
18 public:
19  // NO-COPY structure
20  rnx_vec_f64_layout(const rnx_vec_f64_layout&) = delete;
21  void operator=(const rnx_vec_f64_layout&) = delete;
22  rnx_vec_f64_layout(rnx_vec_f64_layout&&) = delete;
23  void operator=(rnx_vec_f64_layout&&) = delete;
24  /** @brief initialises a memory layout */
25  rnx_vec_f64_layout(uint64_t n, uint64_t size, uint64_t slice);
26  /** @brief destructor */
27  ~rnx_vec_f64_layout();
28
29  /** @brief get a copy of item index index (extended with zeros) */
30  rnx_f64 get_copy_zext(uint64_t index) const;
31  /** @brief get a copy of item index index (extended with zeros) */
32  rnx_f64 get_copy(uint64_t index) const;
33  /** @brief get a copy of item index index (extended with zeros) */
34  reim_fft64vec get_dft_copy_zext(uint64_t index) const;
35  /** @brief get a copy of item index index (extended with zeros) */
36  reim_fft64vec get_dft_copy(uint64_t index) const;
37
38  /** @brief get a copy of item index index (index<size) */
39  void set(uint64_t index, const rnx_f64& elem);
40  /** @brief fill with random values */
41  void fill_random(double log2bound = 0);
42  /** @brief raw pointer access */
43  double* data();
44  /** @brief raw pointer access (const version) */
45  const double* data() const;
46  /** @brief content hashcode */
47  thash content_hash() const;
48};
49
50/** @brief test layout for the VMP_PMAT */
51class fft64_rnx_vmp_pmat_layout {
52 public:
53  const uint64_t nn;
54  const uint64_t nrows;
55  const uint64_t ncols;
56  RNX_VMP_PMAT* const data;
57  fft64_rnx_vmp_pmat_layout(uint64_t n, uint64_t nrows, uint64_t ncols);
58  double* get_addr(uint64_t row, uint64_t col, uint64_t blk) const;
59  reim4_elem get(uint64_t row, uint64_t col, uint64_t blk) const;
60  thash content_hash() const;
61  reim4_elem get_zext(uint64_t row, uint64_t col, uint64_t blk) const;
62  reim_fft64vec get_zext(uint64_t row, uint64_t col) const;
63  void set(uint64_t row, uint64_t col, uint64_t blk, const reim4_elem& v) const;
64  void set(uint64_t row, uint64_t col, const reim_fft64vec& value);
65  /** @brief fill with random double values (unstructured) */
66  void fill_random(double log2bound);
67  ~fft64_rnx_vmp_pmat_layout();
68};
69
70/** @brief test layout for the SVP_PPOL */
71class fft64_rnx_svp_ppol_layout {
72 public:
73  const uint64_t nn;
74  RNX_SVP_PPOL* const data;
75  fft64_rnx_svp_ppol_layout(uint64_t n);
76  thash content_hash() const;
77  reim_fft64vec get_copy() const;
78  void set(const reim_fft64vec&);
79  /** @brief fill with random double values (unstructured) */
80  void fill_random(double log2bound);
81  /** @brief fill with random ffts of small int polynomials */
82  void fill_dft_random(uint64_t log2bound);
83  ~fft64_rnx_svp_ppol_layout();
84};
85#endif  // SPQLIOS_EXT_VEC_RNX_LAYOUT_H