From f23f54efa9f9a43294996503ed8aafe377013bb2 Mon Sep 17 00:00:00 2001 From: Sylvain Laperche Date: Fri, 27 Jul 2018 14:01:48 +0200 Subject: [PATCH] rename the namespace to `quadiron` `quad` is a bit too "common" to be used as a good namespace. Using `quadiron` seems better to avoid eventual name clashes, and if it's too long users can still shorten it by themselves. --- benchmark/benchmark.cpp | 42 +++++----- benchmark/benchmark.h | 6 +- src/arith.h | 4 +- src/big_int.h | 4 +- src/core.cpp | 4 +- src/core.h | 4 +- src/exceptions.h | 4 +- src/fec_base.h | 4 +- src/fec_context.h | 4 +- src/fec_rs_fnt.h | 4 +- src/fec_rs_gf2n.h | 4 +- src/fec_rs_gf2n_fft.h | 4 +- src/fec_rs_gf2n_fft_add.h | 4 +- src/fec_rs_gfp_fft.h | 4 +- src/fec_rs_nf4.h | 4 +- src/fft_2.h | 4 +- src/fft_2n.h | 4 +- src/fft_add.h | 4 +- src/fft_base.h | 4 +- src/fft_ct.h | 4 +- src/fft_gt.h | 4 +- src/fft_large.h | 4 +- src/fft_naive.h | 4 +- src/fft_single.h | 4 +- src/gf_base.h | 4 +- src/gf_bin_ext.h | 4 +- src/gf_ext.h | 4 +- src/gf_nf4.cpp | 4 +- src/gf_nf4.h | 4 +- src/gf_prime.h | 4 +- src/gf_ring.cpp | 4 +- src/gf_ring.h | 6 +- src/misc.h | 4 +- src/polynomial.h | 4 +- src/property.cpp | 4 +- src/property.h | 12 +-- src/quadiron.h | 2 +- src/simd.h | 4 +- src/simd_128_u16.h | 4 +- src/simd_128_u32.h | 4 +- src/simd_256_u16.h | 4 +- src/simd_256_u32.h | 4 +- src/simd_nf4.h | 4 +- src/vec_buf_doubled.h | 4 +- src/vec_buf_zero_ext.h | 4 +- src/vec_buffers.h | 4 +- src/vec_cast.h | 4 +- src/vec_doubled.h | 4 +- src/vec_matrix.h | 4 +- src/vec_poly.h | 4 +- src/vec_slice.h | 4 +- src/vec_vector.cpp | 4 +- src/vec_vector.h | 4 +- src/vec_view.h | 4 +- src/vec_zero_ext.h | 4 +- test/arith_utest.cpp | 142 ++++++++++++++++---------------- test/buffers_utest.cpp | 68 +++++++-------- test/ec_driver.cpp | 56 ++++++------- test/fec_utest.cpp | 36 ++++---- test/fft_utest.cpp | 168 +++++++++++++++++++------------------- test/gf_utest.cpp | 74 ++++++++--------- test/main.cpp | 2 +- test/mat_utest.cpp | 8 +- test/poly_utest.cpp | 58 ++++++------- test/rs_utest.cpp | 14 ++-- test/vector_utest.cpp | 26 +++--- 66 files changed, 460 insertions(+), 460 deletions(-) diff --git a/benchmark/benchmark.cpp b/benchmark/benchmark.cpp index 31d283df..bb73f2ae 100644 --- a/benchmark/benchmark.cpp +++ b/benchmark/benchmark.cpp @@ -126,19 +126,19 @@ Benchmark::~Benchmark() if (d_chunks != nullptr) { for (int i = 0; i < k; i++) { - quad::aligned_deallocate(d_chunks->at(i)); + quadiron::aligned_deallocate(d_chunks->at(i)); } delete d_chunks; } if (c_chunks != nullptr) { for (int i = 0; i < n_c; i++) { - quad::aligned_deallocate(c_chunks->at(i)); + quadiron::aligned_deallocate(c_chunks->at(i)); } delete c_chunks; } if (r_chunks != nullptr) { for (int i = 0; i < k; i++) { - quad::aligned_deallocate(r_chunks->at(i)); + quadiron::aligned_deallocate(r_chunks->at(i)); } delete r_chunks; } @@ -154,33 +154,33 @@ int Benchmark::init() { switch (fec_type) { case EC_TYPE_RS_GF2N_V: - fec = new quad::fec::RsGf2n( - word_size, k, m, quad::fec::RsMatrixType::VANDERMONDE); + fec = new quadiron::fec::RsGf2n( + word_size, k, m, quadiron::fec::RsMatrixType::VANDERMONDE); break; case EC_TYPE_RS_GF2N_C: - fec = new quad::fec::RsGf2n( - word_size, k, m, quad::fec::RsMatrixType::CAUCHY); + fec = new quadiron::fec::RsGf2n( + word_size, k, m, quadiron::fec::RsMatrixType::CAUCHY); break; case EC_TYPE_RS_GF2N_FFT: - fec = new quad::fec::RsGf2nFft(word_size, k, m); + fec = new quadiron::fec::RsGf2nFft(word_size, k, m); break; case EC_TYPE_RS_GF2N_FFT_ADD: - fec = new quad::fec::RsGf2nFftAdd(word_size, k, m); + fec = new quadiron::fec::RsGf2nFftAdd(word_size, k, m); break; case EC_TYPE_RS_GFP_FFT: - fec = new quad::fec::RsGfpFft(word_size, k, m); + fec = new quadiron::fec::RsGfpFft(word_size, k, m); break; case EC_TYPE_RS_NF4: - fec = new quad::fec::RsNf4(word_size, k, m); + fec = new quadiron::fec::RsNf4(word_size, k, m); break; case EC_TYPE_RS_FNT: - fec = new quad::fec::RsFnt(word_size, k, m, pkt_size); + fec = new quadiron::fec::RsFnt(word_size, k, m, pkt_size); break; default: return ERR_FEC_TYPE_NOT_SUPPORTED; } - this->systematic_ec = (fec->type == quad::fec::FecType::SYSTEMATIC); + this->systematic_ec = (fec->type == quadiron::fec::FecType::SYSTEMATIC); if (this->systematic_ec) { this->n_c = this->m; } @@ -194,13 +194,13 @@ int Benchmark::init() r_chunks = new std::vector(k); for (i = 0; i < k; i++) { - d_chunks->at(i) = quad::aligned_allocate(chunk_size); + d_chunks->at(i) = quadiron::aligned_allocate(chunk_size); } for (i = 0; i < n_c; i++) { - c_chunks->at(i) = quad::aligned_allocate(chunk_size); + c_chunks->at(i) = quadiron::aligned_allocate(chunk_size); } for (i = 0; i < k; i++) { - r_chunks->at(i) = quad::aligned_allocate(chunk_size); + r_chunks->at(i) = quadiron::aligned_allocate(chunk_size); } // Allocate memory for iostreambufs @@ -228,7 +228,7 @@ int Benchmark::init() c_streams = new std::vector(n_c); a_streams = new std::vector(n); r_streams = new std::vector(k); - c_props = std::vector(n_c); + c_props = std::vector(n_c); for (i = 0; i < k; i++) { d_streams->at(i) = new std::istream(d_istreambufs->at(i)); @@ -297,7 +297,7 @@ int Benchmark::check_params() } } - size_t wordsize_limit = quad::arith::log2(n) + 1; + size_t wordsize_limit = quadiron::arith::log2(n) + 1; if (wordsize_limit > 8 * word_size) { return ERR_COMPT_CODE_LEN_T; } @@ -426,7 +426,7 @@ template void Benchmark::get_avail_chunks( std::vector* avail_d_chunks, std::vector* avail_c_chunks, - std::vector& avail_c_props) + std::vector& avail_c_props) { std::random_shuffle(c_chunks_id->begin(), c_chunks_id->end()); @@ -436,7 +436,7 @@ void Benchmark::get_avail_chunks( } for (i = 0; i < n_c; i++) { avail_c_chunks->at(i) = nullptr; - avail_c_props.at(i) = quad::Properties(); + avail_c_props.at(i) = quadiron::Properties(); } if (systematic_ec) { int avail_d_chunks_nb = 0; @@ -488,7 +488,7 @@ bool Benchmark::decode() { std::vector d_streams_shuffled(k, nullptr); std::vector c_streams_shuffled(n_c, nullptr); - std::vector c_props_shuffled(n_c); + std::vector c_props_shuffled(n_c); get_avail_chunks( &d_streams_shuffled, &c_streams_shuffled, c_props_shuffled); diff --git a/benchmark/benchmark.h b/benchmark/benchmark.h index 52647391..cd4ecdcb 100644 --- a/benchmark/benchmark.h +++ b/benchmark/benchmark.h @@ -289,7 +289,7 @@ class Benchmark { size_t chunk_size; uint32_t samples_nb; PRNG* prng = nullptr; - quad::fec::FecCode* fec = nullptr; + quadiron::fec::FecCode* fec = nullptr; Params_t* params = nullptr; bool systematic_ec = false; @@ -317,7 +317,7 @@ class Benchmark { // streams of repair chunks std::vector* r_streams = nullptr; // props vector - std::vector c_props; + std::vector c_props; int init(); int check_params(); @@ -333,7 +333,7 @@ class Benchmark { void get_avail_chunks( std::vector* avail_d_chunks, std::vector* avail_c_chunks, - std::vector& avail_c_props); + std::vector& avail_c_props); bool encode(); bool decode(); void show(Stats_t* stats); diff --git a/src/arith.h b/src/arith.h index 89e6d1c6..f64a9a53 100644 --- a/src/arith.h +++ b/src/arith.h @@ -39,7 +39,7 @@ #include "core.h" #include "exceptions.h" -namespace quad { +namespace quadiron { template using DoubleSizeVal = typename DoubleSize::T; @@ -812,6 +812,6 @@ void get_prime_factors_final( } } // namespace arith -} // namespace quad +} // namespace quadiron #endif diff --git a/src/big_int.h b/src/big_int.h index 6e5a7ec4..b5278d9b 100644 --- a/src/big_int.h +++ b/src/big_int.h @@ -40,7 +40,7 @@ std::ostream& operator<<(std::ostream& dest, __int128_t value); } // namespace std -namespace quad { +namespace quadiron { struct UInt256 { __uint128_t lo; @@ -123,6 +123,6 @@ struct Int256 { } }; -} // namespace quad +} // namespace quadiron #endif diff --git a/src/core.cpp b/src/core.cpp index b0331adb..d5867307 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -30,11 +30,11 @@ #include "build_info.h" #include "core.h" -namespace quad { +namespace quadiron { const char* get_version() { return VERSION; } -} // namespace quad +} // namespace quadiron diff --git a/src/core.h b/src/core.h index 27ecee85..ed185aa3 100644 --- a/src/core.h +++ b/src/core.h @@ -35,7 +35,7 @@ #include "big_int.h" -namespace quad { +namespace quadiron { template struct DoubleSize { @@ -160,6 +160,6 @@ inline void aligned_deallocate(T* data) #endif } -} // namespace quad +} // namespace quadiron #endif diff --git a/src/exceptions.h b/src/exceptions.h index db156a2f..f2ac7ac3 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -32,7 +32,7 @@ #include -namespace quad { +namespace quadiron { /** Base class for all the exceptions generated by QuadIron. */ class Exception : public std::runtime_error { @@ -71,6 +71,6 @@ class NoSolution : public Exception { explicit NoSolution(const char* reason) : Exception(reason) {} }; -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fec_base.h b/src/fec_base.h index 3732f185..6eec5cf2 100644 --- a/src/fec_base.h +++ b/src/fec_base.h @@ -49,7 +49,7 @@ #include "vec_slice.h" #include "vec_vector.h" -namespace quad { +namespace quadiron { /** Forward Error Correction code implementations. */ namespace fec { @@ -1142,6 +1142,6 @@ void FecCode::decode_apply( } } // namespace fec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fec_context.h b/src/fec_context.h index d4a3e28b..4fedda59 100644 --- a/src/fec_context.h +++ b/src/fec_context.h @@ -44,7 +44,7 @@ #include "vec_poly.h" #include "vec_zero_ext.h" -namespace quad { +namespace quadiron { namespace fec { @@ -290,6 +290,6 @@ class DecodeContext { }; } // namespace fec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fec_rs_fnt.h b/src/fec_rs_fnt.h index 80d1b5bf..6f6f767a 100644 --- a/src/fec_rs_fnt.h +++ b/src/fec_rs_fnt.h @@ -41,7 +41,7 @@ #include "vec_vector.h" #include "vec_zero_ext.h" -namespace quad { +namespace quadiron { namespace fec { /** Reed-Solomon (RS) erasure code based on Fermat Number Transform (FNT). @@ -198,6 +198,6 @@ class RsFnt : public FecCode { }; } // namespace fec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fec_rs_gf2n.h b/src/fec_rs_gf2n.h index c60475ab..0bf857d9 100644 --- a/src/fec_rs_gf2n.h +++ b/src/fec_rs_gf2n.h @@ -36,7 +36,7 @@ #include "vec_matrix.h" #include "vec_vector.h" -namespace quad { +namespace quadiron { namespace fec { enum class RsMatrixType { VANDERMONDE, CAUCHY }; @@ -154,6 +154,6 @@ class RsGf2n : public FecCode { }; } // namespace fec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fec_rs_gf2n_fft.h b/src/fec_rs_gf2n_fft.h index 3c10fa52..5f47cc16 100644 --- a/src/fec_rs_gf2n_fft.h +++ b/src/fec_rs_gf2n_fft.h @@ -38,7 +38,7 @@ #include "vec_vector.h" #include "vec_zero_ext.h" -namespace quad { +namespace quadiron { namespace fec { /** Reed-Solomon (RS) Erasure code over GF(2n)using FFT. */ @@ -151,6 +151,6 @@ class RsGf2nFft : public FecCode { }; } // namespace fec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fec_rs_gf2n_fft_add.h b/src/fec_rs_gf2n_fft_add.h index 7d917356..96a7a9f2 100644 --- a/src/fec_rs_gf2n_fft_add.h +++ b/src/fec_rs_gf2n_fft_add.h @@ -39,7 +39,7 @@ #include "vec_vector.h" #include "vec_zero_ext.h" -namespace quad { +namespace quadiron { namespace fec { /** Reed-Solomon (RS) Erasure code over GF(2n) using additive FFT. */ @@ -248,6 +248,6 @@ class RsGf2nFftAdd : public FecCode { }; } // namespace fec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fec_rs_gfp_fft.h b/src/fec_rs_gfp_fft.h index 09f99303..e3b2207f 100644 --- a/src/fec_rs_gfp_fft.h +++ b/src/fec_rs_gfp_fft.h @@ -41,7 +41,7 @@ #include "vec_vector.h" #include "vec_zero_ext.h" -namespace quad { +namespace quadiron { namespace fec { /** Reed-Solomon (RS) Erasure code over prime Galois Fields and FFT. @@ -233,6 +233,6 @@ class RsGfpFft : public FecCode { }; } // namespace fec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fec_rs_nf4.h b/src/fec_rs_nf4.h index 13f8c74f..3afb742b 100644 --- a/src/fec_rs_nf4.h +++ b/src/fec_rs_nf4.h @@ -41,7 +41,7 @@ #include "vec_vector.h" #include "vec_zero_ext.h" -namespace quad { +namespace quadiron { namespace fec { /** Reed-Solomon (RS) Erasure code over `n` GF(F4). */ @@ -254,6 +254,6 @@ class RsNf4 : public FecCode { }; } // namespace fec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fft_2.h b/src/fft_2.h index a38840d1..3d1ec962 100644 --- a/src/fft_2.h +++ b/src/fft_2.h @@ -36,7 +36,7 @@ #include "vec_buffers.h" #include "vec_vector.h" -namespace quad { +namespace quadiron { namespace fft { /** FFT implementation specialized for FFT size=2. @@ -121,6 +121,6 @@ void Size2::ifft(vec::Buffers* output, vec::Buffers* input) } } // namespace fft -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fft_2n.h b/src/fft_2n.h index 6efa8b59..733747bf 100644 --- a/src/fft_2n.h +++ b/src/fft_2n.h @@ -39,7 +39,7 @@ #include "vec_vector.h" #include "vec_zero_ext.h" -namespace quad { +namespace quadiron { namespace fft { /** Implementation of the radix-2 decimation-in-time (DIT) FFT @@ -354,6 +354,6 @@ void Radix2::ifft(vec::Buffers* output, vec::Buffers* input) } } // namespace fft -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fft_add.h b/src/fft_add.h index 16e30145..ca5ffc5f 100644 --- a/src/fft_add.h +++ b/src/fft_add.h @@ -37,7 +37,7 @@ #include "vec_slice.h" #include "vec_vector.h" -namespace quad { +namespace quadiron { namespace fft { /** Implementation of an additive FFT algorithm. @@ -672,6 +672,6 @@ void Additive::inv_taylor_expand( } } // namespace fft -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fft_base.h b/src/fft_base.h index f33d2d44..da761257 100644 --- a/src/fft_base.h +++ b/src/fft_base.h @@ -35,7 +35,7 @@ #include "vec_buffers.h" #include "vec_vector.h" -namespace quad { +namespace quadiron { /** Various Fast Fourier Transform (FFT) implementations. */ namespace fft { @@ -102,6 +102,6 @@ const gf::Field& FourierTransform::get_gf() } } // namespace fft -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fft_ct.h b/src/fft_ct.h index c42c3b94..579ee4a6 100644 --- a/src/fft_ct.h +++ b/src/fft_ct.h @@ -39,7 +39,7 @@ #include "vec_vector.h" #include "vec_view.h" -namespace quad { +namespace quadiron { namespace fft { /** FFT implementation using the Cooley–Tukey algorithm @@ -281,6 +281,6 @@ void CooleyTukey::ifft(vec::Vector* output, vec::Vector* input) } } // namespace fft -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fft_gt.h b/src/fft_gt.h index a02e0afb..9719bd58 100644 --- a/src/fft_gt.h +++ b/src/fft_gt.h @@ -41,7 +41,7 @@ #include "vec_vector.h" #include "vec_view.h" -namespace quad { +namespace quadiron { namespace fft { /** FFT implementation using the Good-Thomas algorithm. @@ -288,6 +288,6 @@ void GoodThomas::ifft(vec::Vector* output, vec::Vector* input) } } // namespace fft -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fft_large.h b/src/fft_large.h index f482e238..e1d4ba98 100644 --- a/src/fft_large.h +++ b/src/fft_large.h @@ -37,7 +37,7 @@ #include "vec_matrix.h" #include "vec_vector.h" -namespace quad { +namespace quadiron { namespace fft { /** FFT implementation specialized for large FFT size. @@ -258,6 +258,6 @@ void Large::ifft(vec::Vector* output, vec::Vector* input) } } // namespace fft -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fft_naive.h b/src/fft_naive.h index b48da347..3ae45dee 100644 --- a/src/fft_naive.h +++ b/src/fft_naive.h @@ -36,7 +36,7 @@ #include "vec_matrix.h" #include "vec_vector.h" -namespace quad { +namespace quadiron { namespace fft { /** Naïve implementation of the Discrete Fourier Transform (DFT). @@ -135,6 +135,6 @@ void Naive::ifft(vec::Vector* output, vec::Vector* input) } } // namespace fft -} // namespace quad +} // namespace quadiron #endif diff --git a/src/fft_single.h b/src/fft_single.h index 7096936d..29b25d25 100644 --- a/src/fft_single.h +++ b/src/fft_single.h @@ -36,7 +36,7 @@ #include "vec_buffers.h" #include "vec_vector.h" -namespace quad { +namespace quadiron { namespace fft { /** FFT specialization for when all but the first element are zeros. @@ -113,6 +113,6 @@ void Single::ifft(vec::Buffers* output, vec::Buffers* input) } } // namespace fft -} // namespace quad +} // namespace quadiron #endif diff --git a/src/gf_base.h b/src/gf_base.h index fc990b68..3726f098 100644 --- a/src/gf_base.h +++ b/src/gf_base.h @@ -35,7 +35,7 @@ #include "core.h" #include "gf_ring.h" -namespace quad { +namespace quadiron { /** Galois Fields handling. */ namespace gf { @@ -105,6 +105,6 @@ T Field::get_inv_n_mod_p(int n) const } } // namespace gf -} // namespace quad +} // namespace quadiron #endif diff --git a/src/gf_bin_ext.h b/src/gf_bin_ext.h index c43fe1da..1234609f 100644 --- a/src/gf_bin_ext.h +++ b/src/gf_bin_ext.h @@ -36,7 +36,7 @@ #include "exceptions.h" #include "gf_base.h" -namespace quad { +namespace quadiron { namespace gf { /** An extension Galois Field extended from GF(2) @@ -638,6 +638,6 @@ void BinExtension::add_doubled(int n, T* x, T* y) const } } } // namespace gf -} // namespace quad +} // namespace quadiron #endif diff --git a/src/gf_ext.h b/src/gf_ext.h index 6906ba76..8020c73c 100644 --- a/src/gf_ext.h +++ b/src/gf_ext.h @@ -34,7 +34,7 @@ #include "arith.h" #include "gf_base.h" -namespace quad { +namespace quadiron { template class Polynomial; @@ -316,6 +316,6 @@ T Extension::weak_rand(void) const } } // namespace gf -} // namespace quad +} // namespace quadiron #endif diff --git a/src/gf_nf4.cpp b/src/gf_nf4.cpp index b9e7f03b..8b1e8a7b 100644 --- a/src/gf_nf4.cpp +++ b/src/gf_nf4.cpp @@ -34,7 +34,7 @@ #include "simd.h" -namespace quad { +namespace quadiron { namespace gf { template <> @@ -107,6 +107,6 @@ __uint128_t NF4<__uint128_t>::pack(__uint128_t a, uint32_t flag) const } } // namespace gf -} // namespace quad +} // namespace quadiron #endif // #ifdef QUADIRON_USE_SIMD diff --git a/src/gf_nf4.h b/src/gf_nf4.h index 49832e6a..f220795b 100644 --- a/src/gf_nf4.h +++ b/src/gf_nf4.h @@ -40,7 +40,7 @@ #define MASK16 0xFFFF #define MASK32 0xFFFFFFFF -namespace quad { +namespace quadiron { namespace gf { /** A group of `n` elements of GF(F4=65537). @@ -548,6 +548,6 @@ void NF4<__uint128_t>::add_doubled(int n, __uint128_t* x, __uint128_t* y) const; #endif // #ifdef QUADIRON_USE_SIMD } // namespace gf -} // namespace quad +} // namespace quadiron #endif diff --git a/src/gf_prime.h b/src/gf_prime.h index 5a776d8e..85f94c72 100644 --- a/src/gf_prime.h +++ b/src/gf_prime.h @@ -33,7 +33,7 @@ #include "gf_base.h" -namespace quad { +namespace quadiron { namespace gf { /** A Galois Field whose order is a prime number. */ @@ -65,6 +65,6 @@ T Prime::inv_exp(T a) } } // namespace gf -} // namespace quad +} // namespace quadiron #endif diff --git a/src/gf_ring.cpp b/src/gf_ring.cpp index 16e06b3c..8eb27bc8 100644 --- a/src/gf_ring.cpp +++ b/src/gf_ring.cpp @@ -33,7 +33,7 @@ #ifdef QUADIRON_USE_SIMD #include "simd.h" -namespace quad { +namespace quadiron { namespace gf { template <> @@ -185,6 +185,6 @@ void RingModN::hadamard_mul_doubled( // } } // namespace gf -} // namespace quad +} // namespace quadiron #endif // #ifdef QUADIRON_USE_SIMD diff --git a/src/gf_ring.h b/src/gf_ring.h index 1115918e..731661b9 100644 --- a/src/gf_ring.h +++ b/src/gf_ring.h @@ -43,7 +43,7 @@ #include "exceptions.h" #include "vec_buffers.h" -namespace quad { +namespace quadiron { namespace vec { @@ -345,7 +345,7 @@ T RingModN::exp_quick(T base, T exponent) const * @param base * @param exponent * - * @throw quad::NoSolution if no solution exists. + * @throw quadiron::NoSolution if no solution exists. * * return */ @@ -982,6 +982,6 @@ void RingModN::add_doubled(int n, uint32_t* x, uint32_t* y) const; #endif // #ifdef QUADIRON_USE_SIMD } // namespace gf -} // namespace quad +} // namespace quadiron #endif diff --git a/src/misc.h b/src/misc.h index 544fac0c..2a9db3f1 100644 --- a/src/misc.h +++ b/src/misc.h @@ -31,7 +31,7 @@ #ifndef __QUAD_MISC_H__ #define __QUAD_MISC_H__ -namespace quad { +namespace quadiron { #if defined(__i386__) static __inline__ unsigned long long rdtsc(void) @@ -49,6 +49,6 @@ static __inline__ unsigned long long rdtsc(void) } #endif -} // namespace quad +} // namespace quadiron #endif diff --git a/src/polynomial.h b/src/polynomial.h index 52ebbeb7..86b7c042 100644 --- a/src/polynomial.h +++ b/src/polynomial.h @@ -38,7 +38,7 @@ #include "core.h" #include "gf_base.h" -namespace quad { +namespace quadiron { namespace vec { @@ -612,6 +612,6 @@ void Polynomial::dump() std::cout << "\n"; } -} // namespace quad +} // namespace quadiron #endif diff --git a/src/property.cpp b/src/property.cpp index 525c1d47..b807fbec 100644 --- a/src/property.cpp +++ b/src/property.cpp @@ -32,7 +32,7 @@ #include "property.h" -namespace quad { +namespace quadiron { ValueLocation::ValueLocation(const std::string& str) { @@ -87,4 +87,4 @@ std::ostream& operator<<(std::ostream& os, const Properties& props) return os; } -} // namespace quad +} // namespace quadiron diff --git a/src/property.h b/src/property.h index 9dc5f9d4..2f941bbf 100644 --- a/src/property.h +++ b/src/property.h @@ -38,7 +38,7 @@ #include -namespace quad { +namespace quadiron { /** The location of a value in a buffer. */ struct ValueLocation { @@ -78,13 +78,13 @@ struct ValueLocation { } }; -} // namespace quad +} // namespace quadiron namespace std { template <> -struct hash { - std::size_t operator()(const quad::ValueLocation& k) const +struct hash { + std::size_t operator()(const quadiron::ValueLocation& k) const { return std::hash()(k.offset) + std::hash()(k.fragment_id); @@ -93,7 +93,7 @@ struct hash { } // namespace std -namespace quad { +namespace quadiron { /** Ancillary data attached to values. * @@ -130,6 +130,6 @@ class Properties { friend std::ostream& operator<<(std::ostream& os, const Properties& props); }; -} // namespace quad +} // namespace quadiron #endif diff --git a/src/quadiron.h b/src/quadiron.h index 952fb711..223f40c7 100644 --- a/src/quadiron.h +++ b/src/quadiron.h @@ -31,7 +31,7 @@ #ifndef __QUAD_QUADIRON_H__ #define __QUAD_QUADIRON_H__ -/** @namespace quad +/** @namespace quadiron * * The root namespace of the QuadIron library. */ diff --git a/src/simd.h b/src/simd.h index a901b942..56a2637d 100644 --- a/src/simd.h +++ b/src/simd.h @@ -42,7 +42,7 @@ typedef uint32_t aint32 __attribute__((aligned(ALIGN_SIZE))); typedef uint64_t aint64 __attribute__((aligned(ALIGN_SIZE))); typedef __uint128_t aint128 __attribute__((aligned(ALIGN_SIZE))); -namespace quad { +namespace quadiron { /** The namespace simd contains functions for GF-NF4 that are accelerated by * using SIMD operations over 128bits * @@ -53,7 +53,7 @@ namespace simd { // Vectorized operations are implemented in appropriated headers simd*.h } // namespace simd -} // namespace quad +} // namespace quadiron #ifdef QUADIRON_USE_SSE4 #include "simd_128.h" diff --git a/src/simd_128_u16.h b/src/simd_128_u16.h index 377b9938..eb33a565 100644 --- a/src/simd_128_u16.h +++ b/src/simd_128_u16.h @@ -33,7 +33,7 @@ #include -namespace quad { +namespace quadiron { namespace simd { /* ==================== Essential Operations =================== */ @@ -269,6 +269,6 @@ mul_two_bufs(aint16* src, aint16* dest, size_t len, aint16 card = F3) } } // namespace simd -} // namespace quad +} // namespace quadiron #endif diff --git a/src/simd_128_u32.h b/src/simd_128_u32.h index 74bff9a8..5f317fe5 100644 --- a/src/simd_128_u32.h +++ b/src/simd_128_u32.h @@ -33,7 +33,7 @@ #include -namespace quad { +namespace quadiron { namespace simd { /* ==================== Essential Operations =================== */ @@ -394,6 +394,6 @@ inline void hadamard_mul_doubled(int n, aint128* _x, aint128* _y) } } // namespace simd -} // namespace quad +} // namespace quadiron #endif diff --git a/src/simd_256_u16.h b/src/simd_256_u16.h index dc95f57e..aa6ec0f1 100644 --- a/src/simd_256_u16.h +++ b/src/simd_256_u16.h @@ -33,7 +33,7 @@ #include -namespace quad { +namespace quadiron { namespace simd { /** Perform a%card where a is a addition of two numbers whose elements are @@ -266,6 +266,6 @@ mul_two_bufs(aint16* src, aint16* dest, size_t len, aint16 card = F3) } } // namespace simd -} // namespace quad +} // namespace quadiron #endif diff --git a/src/simd_256_u32.h b/src/simd_256_u32.h index c7e109a6..a888e2c8 100644 --- a/src/simd_256_u32.h +++ b/src/simd_256_u32.h @@ -33,7 +33,7 @@ #include -namespace quad { +namespace quadiron { namespace simd { /* ==================== Essential Operations =================== */ @@ -450,6 +450,6 @@ inline void hadamard_mul_doubled(int n, aint128* _x, aint128* _y) } } // namespace simd -} // namespace quad +} // namespace quadiron #endif diff --git a/src/simd_nf4.h b/src/simd_nf4.h index debfb065..1d4e1f4d 100644 --- a/src/simd_nf4.h +++ b/src/simd_nf4.h @@ -33,7 +33,7 @@ #include -namespace quad { +namespace quadiron { namespace simd { #ifdef QUADIRON_USE_AVX2 @@ -143,6 +143,6 @@ inline aint128 pack(aint128 a, aint32 flag) } } // namespace simd -} // namespace quad +} // namespace quadiron #endif diff --git a/src/vec_buf_doubled.h b/src/vec_buf_doubled.h index e5bd3ad5..7a00989a 100644 --- a/src/vec_buf_doubled.h +++ b/src/vec_buf_doubled.h @@ -33,7 +33,7 @@ #include "vec_buffers.h" -namespace quad { +namespace quadiron { namespace vec { /** A vector of `n` buffers virtually extented to `2n`. @@ -93,6 +93,6 @@ T* BuffersDoubled::get(int i) } } // namespace vec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/vec_buf_zero_ext.h b/src/vec_buf_zero_ext.h index 25d0b436..a7ee7c23 100644 --- a/src/vec_buf_zero_ext.h +++ b/src/vec_buf_zero_ext.h @@ -36,7 +36,7 @@ #include "vec_buffers.h" -namespace quad { +namespace quadiron { namespace vec { /** A vector of `n` buffers virtually extented with a `zero_chunk`. @@ -105,6 +105,6 @@ BuffersZeroExtended::~BuffersZeroExtended() } } // namespace vec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/vec_buffers.h b/src/vec_buffers.h index 3013c7cb..8b3f8b66 100644 --- a/src/vec_buffers.h +++ b/src/vec_buffers.h @@ -39,7 +39,7 @@ #include "core.h" -namespace quad { +namespace quadiron { namespace vec { /// Available cases of allocating memory @@ -403,6 +403,6 @@ void Buffers::dump(void) } } // namespace vec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/vec_cast.h b/src/vec_cast.h index 71b46a4e..05a8b971 100644 --- a/src/vec_cast.h +++ b/src/vec_cast.h @@ -40,7 +40,7 @@ #include "vec_vector.h" -namespace quad { +namespace quadiron { namespace vec { @@ -167,6 +167,6 @@ std::vector* cast_mem_of_vecp(vec::Buffers* s) } } // namespace vec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/vec_doubled.h b/src/vec_doubled.h index 34679e44..e4e36da2 100644 --- a/src/vec_doubled.h +++ b/src/vec_doubled.h @@ -33,7 +33,7 @@ #include "vec_vector.h" -namespace quad { +namespace quadiron { namespace vec { /** A vector of size `n` virtually extented to `2n`. @@ -90,6 +90,6 @@ T Doubled::get(int i) const } } // namespace vec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/vec_matrix.h b/src/vec_matrix.h index b75dc6bd..53d70c40 100644 --- a/src/vec_matrix.h +++ b/src/vec_matrix.h @@ -36,7 +36,7 @@ #include "gf_ring.h" #include "vec_vector.h" -namespace quad { +namespace quadiron { namespace vec { /** A 2D matrix @@ -455,6 +455,6 @@ void Matrix::dump(void) } } // namespace vec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/vec_poly.h b/src/vec_poly.h index b3c8d921..52dc2b5b 100644 --- a/src/vec_poly.h +++ b/src/vec_poly.h @@ -35,7 +35,7 @@ #include "gf_nf4.h" #include "vec_vector.h" -namespace quad { +namespace quadiron { namespace vec { /** A vector of size \f$n\f$ represents a polynomial \f$P(X)\f$ of degree @@ -253,6 +253,6 @@ void Poly::dump() } } // namespace vec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/vec_slice.h b/src/vec_slice.h index 5270876b..f658583b 100644 --- a/src/vec_slice.h +++ b/src/vec_slice.h @@ -33,7 +33,7 @@ #include "vec_vector.h" -namespace quad { +namespace quadiron { namespace vec { /** A slice of an existing vector. @@ -122,6 +122,6 @@ int Slice::get_offset() } } // namespace vec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/vec_vector.cpp b/src/vec_vector.cpp index 8a54ffce..f43c1a68 100644 --- a/src/vec_vector.cpp +++ b/src/vec_vector.cpp @@ -29,7 +29,7 @@ */ #include "vec_vector.h" -namespace quad { +namespace quadiron { namespace vec { void _vec_hadamard_mul_257(int n, uint32_t* x, uint32_t* y) @@ -241,4 +241,4 @@ void Vector::add(Doubled* v) } } // namespace vec -} // namespace quad +} // namespace quadiron diff --git a/src/vec_vector.h b/src/vec_vector.h index cc45e3a6..48928ab4 100644 --- a/src/vec_vector.h +++ b/src/vec_vector.h @@ -43,7 +43,7 @@ #include "vec_cast.h" #include "vec_doubled.h" -namespace quad { +namespace quadiron { template class Polynomial; @@ -417,6 +417,6 @@ void Vector::hadamard_mul(Doubled* v); #endif } // namespace vec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/vec_view.h b/src/vec_view.h index 75dcfd72..efce9893 100644 --- a/src/vec_view.h +++ b/src/vec_view.h @@ -33,7 +33,7 @@ #include "vec_vector.h" -namespace quad { +namespace quadiron { namespace vec { /** A view of an existing vector. @@ -130,6 +130,6 @@ void View::set(int i, T val) } } // namespace vec -} // namespace quad +} // namespace quadiron #endif diff --git a/src/vec_zero_ext.h b/src/vec_zero_ext.h index 6f1e50f0..c945c334 100644 --- a/src/vec_zero_ext.h +++ b/src/vec_zero_ext.h @@ -33,7 +33,7 @@ #include "vec_vector.h" -namespace quad { +namespace quadiron { namespace vec { /** A vector of size `n` virtually extented with zeros. @@ -85,6 +85,6 @@ T ZeroExtended::get(int i) const } } // namespace vec -} // namespace quad +} // namespace quadiron #endif diff --git a/test/arith_utest.cpp b/test/arith_utest.cpp index cb508804..37b6e0a5 100644 --- a/test/arith_utest.cpp +++ b/test/arith_utest.cpp @@ -55,12 +55,12 @@ class ArithUtest { void test_basic_ops() { std::cout << "test_basic_ops\n"; - assert(quad::arith::sqrt(2025) == 45); - assert(quad::arith::is_prime(2)); - assert(quad::arith::is_prime(3)); - assert(quad::arith::is_prime(13)); - assert(!quad::arith::is_prime(4)); - assert(!quad::arith::is_prime(15)); + assert(quadiron::arith::sqrt(2025) == 45); + assert(quadiron::arith::is_prime(2)); + assert(quadiron::arith::is_prime(3)); + assert(quadiron::arith::is_prime(13)); + assert(!quadiron::arith::is_prime(4)); + assert(!quadiron::arith::is_prime(15)); } void test_reciprocal() @@ -68,17 +68,17 @@ class ArithUtest { std::cout << "test_reciprocal\n"; int i; - T sub_max = quad::arith::sqrt(max); + T sub_max = quadiron::arith::sqrt(max); std::uniform_int_distribution dis(1, sub_max - 1); for (i = 0; i < 1000; i++) { T x, y, z; - x = dis(quad::prng()); + x = dis(quadiron::prng()); // std::cout << "x=" << x << "\n"; - y = quad::arith::exp(x, 2); + y = quadiron::arith::exp(x, 2); // std::cout << "exp(x)=" << y << "\n"; - z = quad::arith::sqrt(y); + z = quadiron::arith::sqrt(y); // std::cout << "z=" << z << "\n"; assert(z == x); } @@ -102,33 +102,33 @@ class ArithUtest { n[0] = 107; a[1] = 2; n[1] = 74; - omega = quad::arith::chinese_remainder(2, a, n); + omega = quadiron::arith::chinese_remainder(2, a, n); assert(omega == 5996); a[0] = 6; n[0] = 7; a[1] = 4; n[1] = 8; - omega = quad::arith::chinese_remainder(2, a, n); + omega = quadiron::arith::chinese_remainder(2, a, n); assert(omega == 20); a[0] = 3; n[0] = 4; a[1] = 0; n[1] = 6; - omega = quad::arith::chinese_remainder(2, a, n); + omega = quadiron::arith::chinese_remainder(2, a, n); // no solution XXX detect it } void test_jacobi() { std::cout << "test_jacobi\n"; - assert(quad::arith::jacobi(1001, 9907) == -1); - assert(quad::arith::jacobi(19, 45) == 1); - assert(quad::arith::jacobi(8, 21) == -1); - assert(quad::arith::jacobi(5, 21) == 1); - assert(quad::arith::jacobi(47, 221) == -1); - assert(quad::arith::jacobi(2, 221) == -1); + assert(quadiron::arith::jacobi(1001, 9907) == -1); + assert(quadiron::arith::jacobi(19, 45) == 1); + assert(quadiron::arith::jacobi(8, 21) == -1); + assert(quadiron::arith::jacobi(5, 21) == 1); + assert(quadiron::arith::jacobi(47, 221) == -1); + assert(quadiron::arith::jacobi(2, 221) == -1); } /** @@ -146,7 +146,7 @@ class ArithUtest { int b = 10; // base int p = 14; // we could multiply integers of 2^p digits - // T max_digits = quad::arith::exp(2, p); + // T max_digits = quadiron::arith::exp(2, p); // std::cerr << "p=" << p << " max_digits=" << max_digits << "\n"; // T l = p + 1; @@ -157,30 +157,30 @@ class ArithUtest { // a 2^n-th principal root of unity in GF_p T a1 = 2; T a2 = 5; - T p1 = a1 * quad::arith::exp(2, 15) + 1; - T p2 = a2 * quad::arith::exp(2, 15) + 1; + T p1 = a1 * quadiron::arith::exp(2, 15) + 1; + T p2 = a2 * quadiron::arith::exp(2, 15) + 1; // std::cerr << "p1=" << p1 << " p2=" << p2 << "\n"; - assert(quad::arith::is_prime(p1)); - assert(quad::arith::is_prime(p2)); + assert(quadiron::arith::is_prime(p1)); + assert(quadiron::arith::is_prime(p2)); // ensure their product is bounded (b-1)^2*2^(n-1) < m T m = p1 * p2; // check overflow assert(m / p1 == p2); // std::cerr << " m=" << m << "\n"; - assert(quad::arith::exp((b - 1), 2) * quad::arith::exp(p, 2) < m); + assert(quadiron::arith::exp((b - 1), 2) * quadiron::arith::exp(p, 2) < m); // find x so it is not a quadratic residue in GF_p1 and GF_p2 - assert(quad::arith::jacobi(3, p1) == quad::arith::jacobi(p1, 3)); - assert(quad::arith::jacobi(p1, 3) == quad::arith::jacobi(2, 3)); - assert(quad::arith::jacobi(3, p2) == quad::arith::jacobi(p2, 3)); - assert(quad::arith::jacobi(p2, 3) == quad::arith::jacobi(2, 3)); - assert(quad::arith::jacobi(2, 3) == -1); + assert(quadiron::arith::jacobi(3, p1) == quadiron::arith::jacobi(p1, 3)); + assert(quadiron::arith::jacobi(p1, 3) == quadiron::arith::jacobi(2, 3)); + assert(quadiron::arith::jacobi(3, p2) == quadiron::arith::jacobi(p2, 3)); + assert(quadiron::arith::jacobi(p2, 3) == quadiron::arith::jacobi(2, 3)); + assert(quadiron::arith::jacobi(2, 3) == -1); // which means x=3 is not a quadratic residue in GF_p1 and GF_p2 // therefore we can compute 2^n-th roots of unity in GF_p1 and GF_p2 - T w1 = quad::arith::exp(3, a1); - T w2 = quad::arith::exp(3, a2); + T w1 = quadiron::arith::exp(3, a1); + T w2 = quadiron::arith::exp(3, a2); // std::cerr << "w1=" << w1 << " w2=" << w2 << "\n"; assert(w1 == 9); assert(w2 == 243); @@ -192,7 +192,7 @@ class ArithUtest { _n[0] = p1; _a[1] = w2; _n[1] = p2; - T w = quad::arith::chinese_remainder(2, _a, _n); + T w = quadiron::arith::chinese_remainder(2, _a, _n); // std::cerr << " w=" << w << "\n"; assert(w == 25559439); } @@ -200,14 +200,14 @@ class ArithUtest { void test_ext_gcd() { std::cout << "test_ext_gcd\n"; - quad::SignedDoubleSizeVal bezout[2]; + quadiron::SignedDoubleSizeVal bezout[2]; // not explicitely related to GF(97) - assert(2 == quad::arith::extended_gcd(240, 46, nullptr, nullptr)); - assert(6 == quad::arith::extended_gcd(54, 24, nullptr, nullptr)); - assert(15 == quad::arith::extended_gcd(210, 45, nullptr, nullptr)); + assert(2 == quadiron::arith::extended_gcd(240, 46, nullptr, nullptr)); + assert(6 == quadiron::arith::extended_gcd(54, 24, nullptr, nullptr)); + assert(15 == quadiron::arith::extended_gcd(210, 45, nullptr, nullptr)); // - assert(1 == quad::arith::extended_gcd(97, 20, bezout, nullptr)); + assert(1 == quadiron::arith::extended_gcd(97, 20, bezout, nullptr)); assert(bezout[0] == -7 && bezout[1] == 34); } @@ -217,11 +217,11 @@ class ArithUtest { typename std::vector::size_type j; - assert(quad::arith::is_prime(primes->at(0))); + assert(quadiron::arith::is_prime(primes->at(0))); for (j = 1; j != primes->size(); ++j) { // std::cout << j << ": " << primes->at(j) << "\n"; - assert(quad::arith::is_prime(primes->at(j))); + assert(quadiron::arith::is_prime(primes->at(j))); if (distinct) assert(primes->at(j - 1) != primes->at(j)); } @@ -238,7 +238,7 @@ class ArithUtest { typename std::vector::size_type j; T y = 1; for (j = 0; j != primes->size(); ++j) { - y *= quad::arith::exp(primes->at(j), exponent->at(j)); + y *= quadiron::arith::exp(primes->at(j), exponent->at(j)); } assert(y == nb); } @@ -250,10 +250,10 @@ class ArithUtest { int i; for (i = 0; i < 1000; i++) { - const T x = uniform_dist_max(quad::prng()); + const T x = uniform_dist_max(quadiron::prng()); std::vector primes; - quad::arith::factor_distinct_prime(x, &primes); + quadiron::arith::factor_distinct_prime(x, &primes); check_all_primes(&primes, true); } } @@ -267,9 +267,9 @@ class ArithUtest { std::vector exponent; for (i = 0; i < 1000; i++) { - const T x = uniform_dist_max(quad::prng()); + const T x = uniform_dist_max(quadiron::prng()); - quad::arith::factor_prime(x, &primes, &exponent); + quadiron::arith::factor_prime(x, &primes, &exponent); check_all_primes(&primes, true); check_primes_exponent(x, &primes, &exponent); primes.clear(); @@ -279,7 +279,7 @@ class ArithUtest { void check_divisors(T nb, std::vector* divisors, bool proper) { - if (proper && quad::arith::is_prime(nb)) + if (proper && quadiron::arith::is_prime(nb)) assert(divisors->size() == 0); else assert(divisors->size() > 0); @@ -289,7 +289,7 @@ class ArithUtest { // std::cout << i << ": " << divisors->at(i) << "\n"; assert(nb % divisors->at(i) == 0); if (proper) - assert(quad::arith::is_prime(nb / divisors->at(i))); + assert(quadiron::arith::is_prime(nb / divisors->at(i))); } } @@ -300,9 +300,9 @@ class ArithUtest { int i; std::vector divisors; for (i = 0; i < 1000; i++) { - const T x = uniform_dist_max(quad::prng()); + const T x = uniform_dist_max(quadiron::prng()); - quad::arith::get_proper_divisors(x, &divisors); + quadiron::arith::get_proper_divisors(x, &divisors); check_divisors(x, &divisors, true); divisors.clear(); } @@ -315,11 +315,11 @@ class ArithUtest { int i; std::vector divisors; for (i = 0; i < 1000; i++) { - const T x = uniform_dist_max(quad::prng()); + const T x = uniform_dist_max(quadiron::prng()); std::vector factors; - quad::arith::factor_distinct_prime(x, &factors); - quad::arith::get_proper_divisors(x, &factors, &divisors); + quadiron::arith::factor_distinct_prime(x, &factors); + quadiron::arith::get_proper_divisors(x, &factors, &divisors); check_divisors(x, &divisors, true); divisors.clear(); } @@ -332,9 +332,9 @@ class ArithUtest { int i; std::vector divisors; for (i = 0; i < 1000; i++) { - const T x = uniform_dist_max(quad::prng()); + const T x = uniform_dist_max(quadiron::prng()); - quad::arith::get_all_divisors(x, &divisors); + quadiron::arith::get_all_divisors(x, &divisors); check_divisors(x, &divisors, false); divisors.clear(); } @@ -346,10 +346,10 @@ class ArithUtest { int i; for (i = 0; i < 1000; i++) { - const T order = uniform_dist_max(quad::prng()); + const T order = uniform_dist_max(quadiron::prng()); std::uniform_int_distribution dis(1, order - 1); - const T n = dis(quad::prng()); - const T len = quad::arith::get_code_len(order, n); + const T n = dis(quadiron::prng()); + const T len = quadiron::arith::get_code_len(order, n); assert(order % len == 0); assert(len >= n); @@ -362,10 +362,10 @@ class ArithUtest { int i; for (i = 0; i < 1000; i++) { - const T order = uniform_dist_max(quad::prng()); + const T order = uniform_dist_max(quadiron::prng()); std::uniform_int_distribution dis(1, order - 1); - const T n = dis(quad::prng()); - const T len = quad::arith::get_code_len_high_compo(order, n); + const T n = dis(quadiron::prng()); + const T len = quadiron::arith::get_code_len_high_compo(order, n); assert(order % len == 0); assert(len >= n); @@ -378,13 +378,13 @@ class ArithUtest { int i; for (i = 0; i < 1000; i++) { - const T order = uniform_dist_max(quad::prng()); + const T order = uniform_dist_max(quadiron::prng()); std::uniform_int_distribution dis(1, order - 1); - const T n = dis(quad::prng()); + const T n = dis(quadiron::prng()); std::vector factors; - quad::arith::get_prime_factors(order, &factors); - const T len = quad::arith::get_code_len_high_compo(&factors, n); + quadiron::arith::get_prime_factors(order, &factors); + const T len = quadiron::arith::get_code_len_high_compo(&factors, n); // std::cout << "len=" << len << "\n"; assert(order % len == 0); assert(len >= n); @@ -400,7 +400,7 @@ class ArithUtest { // std::cout << i << ": " << divisors->at(i) << "\n"; assert(nb % divisors->at(i) == 0); if (!coprime) - assert(quad::arith::is_prime(divisors->at(i))); + assert(quadiron::arith::is_prime(divisors->at(i))); else { for (j = i + 1; j != divisors->size(); ++j) { assert(divisors->at(i) != divisors->at(j)); @@ -416,9 +416,9 @@ class ArithUtest { std::vector divisors; int i; for (i = 0; i < 1000; i++) { - const T n = uniform_dist_max(quad::prng()); + const T n = uniform_dist_max(quadiron::prng()); - quad::arith::get_coprime_factors(n, &divisors); + quadiron::arith::get_coprime_factors(n, &divisors); check_prime_divisors(n, &divisors, true); divisors.clear(); } @@ -431,9 +431,9 @@ class ArithUtest { std::vector divisors; int i; for (i = 0; i < 1000; i++) { - const T n = uniform_dist_max(quad::prng()); + const T n = uniform_dist_max(quadiron::prng()); - quad::arith::get_prime_factors(n, &divisors); + quadiron::arith::get_prime_factors(n, &divisors); check_prime_divisors(n, &divisors, false); divisors.clear(); } @@ -443,7 +443,7 @@ class ArithUtest { { std::cout << "arith_utest with sizeof(T)=" << sizeof(T) << "\n"; - quad::prng().seed(time(0)); + quadiron::prng().seed(time(0)); test_basic_ops(); test_reciprocal(); @@ -465,7 +465,7 @@ class ArithUtest { { std::cout << "arith_utest_no256\n"; - quad::prng().seed(time(0)); + quadiron::prng().seed(time(0)); test_basic_ops(); test_reciprocal(); diff --git a/test/buffers_utest.cpp b/test/buffers_utest.cpp index b749008e..4b656937 100644 --- a/test/buffers_utest.cpp +++ b/test/buffers_utest.cpp @@ -35,13 +35,13 @@ template class BuffersUtest { private: std::mt19937 prng; - quad::gf::Prime* gfp; + quadiron::gf::Prime* gfp; T max_val; public: BuffersUtest() { - this->gfp = new quad::gf::Prime(65537); + this->gfp = new quadiron::gf::Prime(65537); this->max_val = 65537; } ~BuffersUtest() @@ -49,14 +49,14 @@ class BuffersUtest { delete this->gfp; } - quad::vec::Buffers* gen_buffers_rand_data(int n, int size, int _max = 0) + quadiron::vec::Buffers* gen_buffers_rand_data(int n, int size, int _max = 0) { const int max = (_max == 0) ? max_val : _max; std::uniform_int_distribution dis(0, max - 1); - quad::vec::Buffers* vec = new quad::vec::Buffers(n, size); + quadiron::vec::Buffers* vec = new quadiron::vec::Buffers(n, size); for (int i = 0; i < n; i++) { - T* buf = quad::aligned_allocate(size); + T* buf = quadiron::aligned_allocate(size); for (int j = 0; j < size; j++) { buf[j] = dis(prng); } @@ -77,11 +77,11 @@ class BuffersUtest { int size = 32; int i, j; - quad::vec::Buffers* vec1 = gen_buffers_rand_data(n, size); + quadiron::vec::Buffers* vec1 = gen_buffers_rand_data(n, size); std::vector* mem1 = vec1->get_mem(); // vec1->dump(); - quad::vec::Buffers vec2(vec1, begin, end); + quadiron::vec::Buffers vec2(vec1, begin, end); std::vector* mem2 = vec2.get_mem(); assert(vec2.get_n() == end - begin); assert(vec2.get_size() == vec1->get_size()); @@ -96,7 +96,7 @@ class BuffersUtest { for (int i = 0; i < end - begin; i++) { mem3[i] = mem1->at(i + begin); } - quad::vec::Buffers vec3(end - begin, size, &mem3); + quadiron::vec::Buffers vec3(end - begin, size, &mem3); // vec3.dump(); assert(vec2.eq(&vec3)); @@ -113,28 +113,28 @@ class BuffersUtest { int i, j; int half = n / 2; - std::unique_ptr> vec1 = - std::unique_ptr>( + std::unique_ptr> vec1 = + std::unique_ptr>( gen_buffers_rand_data(n, size)); - quad::vec::Buffers vec2(n, size); + quadiron::vec::Buffers vec2(n, size); vec2.copy(vec1.get()); std::vector* even_mem = new std::vector(half, nullptr); std::vector* odd_mem = new std::vector(half, nullptr); - std::unique_ptr> i_even = - std::unique_ptr>( - new quad::vec::Buffers(half, size, even_mem)); - std::unique_ptr> i_odd = - std::unique_ptr>( - new quad::vec::Buffers(half, size, odd_mem)); + std::unique_ptr> i_even = + std::unique_ptr>( + new quadiron::vec::Buffers(half, size, even_mem)); + std::unique_ptr> i_odd = + std::unique_ptr>( + new quadiron::vec::Buffers(half, size, odd_mem)); vec1->separate_even_odd(i_even.get(), i_odd.get()); // vec1->dump(); vec1->separate_even_odd(); // vec1->dump(); - quad::vec::Buffers _i_even(vec1.get(), 0, half); - quad::vec::Buffers _i_odd(vec1.get(), half, n); + quadiron::vec::Buffers _i_even(vec1.get(), 0, half); + quadiron::vec::Buffers _i_odd(vec1.get(), half, n); assert(i_even->eq(&_i_even)); assert(i_odd->eq(&_i_odd)); @@ -169,20 +169,20 @@ class BuffersUtest { int n1 = 4; int n2 = 10; - quad::vec::Buffers* vec = gen_buffers_rand_data(n, size); - quad::vec::Buffers vec1(vec, n1); - quad::vec::Buffers vec2(vec, n2); + quadiron::vec::Buffers* vec = gen_buffers_rand_data(n, size); + quadiron::vec::Buffers vec1(vec, n1); + quadiron::vec::Buffers vec2(vec, n2); - quad::vec::Buffers _vec1(vec, 0, n1); - quad::vec::Buffers* _vec2 = - new quad::vec::BuffersZeroExtended(vec, n2); + quadiron::vec::Buffers _vec1(vec, 0, n1); + quadiron::vec::Buffers* _vec2 = + new quadiron::vec::BuffersZeroExtended(vec, n2); assert(vec1.eq(&_vec1)); assert(vec2.eq(_vec2)); delete vec; - quad::vec::Buffers vec3(&vec2, n1); + quadiron::vec::Buffers vec3(&vec2, n1); assert(vec3.eq(&vec1)); delete _vec2; @@ -194,8 +194,8 @@ class BuffersUtest { int i; int word_size; - for (i = 0; i <= quad::arith::log2(sizeof(T)); i++) { - word_size = quad::arith::exp2(i); + for (i = 0; i <= quadiron::arith::log2(sizeof(T)); i++) { + word_size = quadiron::arith::exp2(i); pack_unpack(word_size); } } @@ -211,12 +211,12 @@ class BuffersUtest { T symb; T max = ((T)1 << word_size) + 1; - quad::vec::Buffers* words = gen_buffers_rand_data(n, size, max); + quadiron::vec::Buffers* words = gen_buffers_rand_data(n, size, max); std::vector* mem_T = words->get_mem(); // std::cout << "words:"; words->dump(); // pack manually from T to uint8_t - quad::vec::Buffers vec_char(n, bytes_size); + quadiron::vec::Buffers vec_char(n, bytes_size); std::vector* mem_char = vec_char.get_mem(); for (i = 0; i < n; i++) { t = 0; @@ -238,9 +238,9 @@ class BuffersUtest { * pack bufs of type uint8_t to bufs of type T */ // tmp vectors to store results - quad::vec::Buffers vec_T_tmp(n, size); + quadiron::vec::Buffers vec_T_tmp(n, size); std::vector* mem_T_tmp = vec_T_tmp.get_mem(); - quad::vec::pack(mem_char, mem_T_tmp, n, size, word_size); + quadiron::vec::pack(mem_char, mem_T_tmp, n, size, word_size); // std::cout << "vec_char:"; vec_char.dump(); // std::cout << "vec_T_tmp:"; vec_T_tmp.dump(); // check @@ -250,9 +250,9 @@ class BuffersUtest { * unpack bufs of type T to bufs of type uint8_t */ // tmp vectors to store results - quad::vec::Buffers vec_char_tmp(n, bytes_size); + quadiron::vec::Buffers vec_char_tmp(n, bytes_size); std::vector* mem_char_tmp = vec_char_tmp.get_mem(); - quad::vec::unpack( + quadiron::vec::unpack( mem_T_tmp, mem_char_tmp, n, size, word_size); // std::cout << "vec_T_tmp:"; vec_T_tmp.dump(); // std::cout << "vec_char_tmp:"; vec_char_tmp.dump(); diff --git a/test/ec_driver.cpp b/test/ec_driver.cpp index 0133c681..e889b288 100644 --- a/test/ec_driver.cpp +++ b/test/ec_driver.cpp @@ -68,14 +68,14 @@ char* xstrdup(const char* str) */ template void create_coding_files( - quad::fec::FecCode* fec, + quadiron::fec::FecCode* fec, bool operation_on_packet = false) { char filename[1024]; std::vector d_files(fec->n_data, nullptr); std::vector c_files(fec->n_outputs, nullptr); std::vector c_props_files(fec->n_outputs, nullptr); - std::vector c_props(fec->n_outputs); + std::vector c_props(fec->n_outputs); for (unsigned i = 0; i < fec->n_data; i++) { snprintf(filename, sizeof(filename), "%s.d%d", prefix, i); @@ -123,13 +123,13 @@ void create_coding_files( * */ template -bool repair_data_files(quad::fec::FecCode* fec) +bool repair_data_files(quadiron::fec::FecCode* fec) { char filename[1024]; std::vector d_files(fec->n_data, nullptr); std::vector c_files(fec->n_outputs, nullptr); std::vector c_props_files(fec->n_outputs, nullptr); - std::vector c_props(fec->n_outputs); + std::vector c_props(fec->n_outputs); std::vector r_files(fec->n_data, nullptr); // re-read data @@ -203,7 +203,7 @@ bool repair_data_files(quad::fec::FecCode* fec) } template -void print_stats(quad::fec::FecCode* fec) +void print_stats(quadiron::fec::FecCode* fec) { std::cerr << "enc," << (fec->n_encode_ops != 0 @@ -218,13 +218,13 @@ void print_stats(quad::fec::FecCode* fec) } template -void print_fec_type(quad::fec::FecCode* fec) +void print_fec_type(quadiron::fec::FecCode* fec) { switch (fec->type) { - case quad::fec::FecType::SYSTEMATIC: + case quadiron::fec::FecType::SYSTEMATIC: std::cout << "SYSTEMATIC\n"; break; - case quad::fec::FecType::NON_SYSTEMATIC: + case quadiron::fec::FecType::NON_SYSTEMATIC: std::cout << "NON_SYSTEMATIC\n"; break; default: @@ -238,18 +238,18 @@ void run_fec_rs_gf2n( int word_size, int n_data, int n_parities, - quad::fec::RsMatrixType mflag, + quadiron::fec::RsMatrixType mflag, int rflag) { - quad::fec::RsGf2n* fec; - typename quad::fec::RsMatrixType gf2nrs_type; + quadiron::fec::RsGf2n* fec; + typename quadiron::fec::RsMatrixType gf2nrs_type; ; - if (mflag == quad::fec::RsMatrixType::VANDERMONDE) { - gf2nrs_type = quad::fec::RsMatrixType::VANDERMONDE; + if (mflag == quadiron::fec::RsMatrixType::VANDERMONDE) { + gf2nrs_type = quadiron::fec::RsMatrixType::VANDERMONDE; } else { - gf2nrs_type = quad::fec::RsMatrixType::CAUCHY; + gf2nrs_type = quadiron::fec::RsMatrixType::CAUCHY; } - fec = new quad::fec::RsGf2n(word_size, n_data, n_parities, gf2nrs_type); + fec = new quadiron::fec::RsGf2n(word_size, n_data, n_parities, gf2nrs_type); if (tflag) { print_fec_type(fec); @@ -268,8 +268,8 @@ void run_fec_rs_gf2n( template void run_fec_rs_gf2n_fft(int word_size, int n_data, int n_parities, int rflag) { - quad::fec::RsGf2nFft* fec; - fec = new quad::fec::RsGf2nFft(word_size, n_data, n_parities); + quadiron::fec::RsGf2nFft* fec; + fec = new quadiron::fec::RsGf2nFft(word_size, n_data, n_parities); if (tflag) { print_fec_type(fec); @@ -292,8 +292,8 @@ void run_fec_rs_gf2n_fft_add( int n_parities, int rflag) { - quad::fec::RsGf2nFftAdd* fec; - fec = new quad::fec::RsGf2nFftAdd(word_size, n_data, n_parities); + quadiron::fec::RsGf2nFftAdd* fec; + fec = new quadiron::fec::RsGf2nFftAdd(word_size, n_data, n_parities); if (tflag) { print_fec_type(fec); @@ -318,8 +318,8 @@ void run_fec_rs_gfp_fft( { assert(sizeof(T) > word_size); - quad::fec::RsGfpFft* fec; - fec = new quad::fec::RsGfpFft(word_size, n_data, n_parities); + quadiron::fec::RsGfpFft* fec; + fec = new quadiron::fec::RsGfpFft(word_size, n_data, n_parities); if (tflag) { print_fec_type(fec); @@ -338,9 +338,9 @@ void run_fec_rs_gfp_fft( template void run_fec_rs_fnt(int word_size, int n_data, int n_parities, int rflag) { - quad::fec::RsFnt* fec; + quadiron::fec::RsFnt* fec; size_t pkt_size = 1024; - fec = new quad::fec::RsFnt(word_size, n_data, n_parities, pkt_size); + fec = new quadiron::fec::RsFnt(word_size, n_data, n_parities, pkt_size); if (tflag) { print_fec_type(fec); @@ -359,8 +359,8 @@ void run_fec_rs_fnt(int word_size, int n_data, int n_parities, int rflag) template void run_fec_rs_nf4(int word_size, int n_data, int n_parities, int rflag) { - quad::fec::RsNf4* fec; - fec = new quad::fec::RsNf4(word_size, n_data, n_parities); + quadiron::fec::RsNf4* fec; + fec = new quadiron::fec::RsNf4(word_size, n_data, n_parities); if (tflag) { print_fec_type(fec); @@ -405,7 +405,7 @@ int main(int argc, char** argv) int rflag = 0; int uflag = 0; ec_type eflag = EC_TYPE_UNDEF; - quad::fec::RsMatrixType mflag = quad::fec::RsMatrixType::VANDERMONDE; + quadiron::fec::RsMatrixType mflag = quadiron::fec::RsMatrixType::VANDERMONDE; unsigned word_size = 0; n_data = n_parities = -1; @@ -414,10 +414,10 @@ int main(int argc, char** argv) case 'e': if (!strcmp(optarg, "rs-gf2n-v")) { eflag = EC_TYPE_RS_GF2N; - mflag = quad::fec::RsMatrixType::VANDERMONDE; + mflag = quadiron::fec::RsMatrixType::VANDERMONDE; } else if (!strcmp(optarg, "rs-gf2n-c")) { eflag = EC_TYPE_RS_GF2N; - mflag = quad::fec::RsMatrixType::CAUCHY; + mflag = quadiron::fec::RsMatrixType::CAUCHY; } else if (!strcmp(optarg, "rs-gf2n-fft")) { eflag = EC_TYPE_RS_GF2N_FFT; } else if (!strcmp(optarg, "rs-gf2n-fft-add")) { diff --git a/test/fec_utest.cpp b/test/fec_utest.cpp index f61a1adb..57cdd9a0 100644 --- a/test/fec_utest.cpp +++ b/test/fec_utest.cpp @@ -38,7 +38,7 @@ class FECUtest { unsigned n_data = 3; unsigned n_parities = 3; - quad::fec::RsFnt fec(2, n_data, n_parities); + quadiron::fec::RsFnt fec(2, n_data, n_parities); run_test(&fec, fec.n, n_data, n_data + n_parities, true); } @@ -48,11 +48,11 @@ class FECUtest { unsigned n_data = 3; unsigned n_parities = 3; - for (int i = 1; i < quad::arith::log2(sizeof(T)); i++) { + for (int i = 1; i < quadiron::arith::log2(sizeof(T)); i++) { unsigned word_size = 1 << i; std::cout << "Test fec::RsNgff4 with word_size=" << word_size << '\n'; - quad::fec::RsNf4 fec(word_size, n_data, n_parities); + quadiron::fec::RsNf4 fec(word_size, n_data, n_parities); run_test(&fec, fec.n, n_data, n_data + n_parities, true); } } @@ -71,7 +71,7 @@ class FECUtest { unsigned n_data = 3; unsigned n_parities = 3; - quad::fec::RsGf2nFft fec(wordsize, n_data, n_parities); + quadiron::fec::RsGf2nFft fec(wordsize, n_data, n_parities); run_test(&fec, fec.n, n_data, n_data + n_parities); } @@ -90,7 +90,7 @@ class FECUtest { unsigned n_data = 3; unsigned n_parities = 3; - quad::fec::RsGf2nFftAdd fec(wordsize, n_data, n_parities); + quadiron::fec::RsGf2nFftAdd fec(wordsize, n_data, n_parities); run_test(&fec, fec.n, n_data, n_data + n_parities); } @@ -109,33 +109,33 @@ class FECUtest { unsigned n_data = 3; unsigned n_parities = 3; - quad::fec::RsGfpFft fec(word_size, n_data, n_parities); + quadiron::fec::RsGfpFft fec(word_size, n_data, n_parities); run_test(&fec, fec.n, n_data, n_data + n_parities, true); } void run_test( - quad::fec::FecCode* fec, + quadiron::fec::FecCode* fec, int n, int n_data, int code_len, bool props_flag = false) { - const quad::gf::Field* gf = &(fec->get_gf()); - - quad::vec::Vector v(*gf, n_data); - quad::vec::Vector _v(*gf, n); - quad::vec::Vector _v2(*gf, n_data); - quad::vec::Vector f(*gf, n_data); - quad::vec::Vector v2(*gf, n_data); - quad::vec::Vector v_p(*gf, n_data); + const quadiron::gf::Field* gf = &(fec->get_gf()); + + quadiron::vec::Vector v(*gf, n_data); + quadiron::vec::Vector _v(*gf, n); + quadiron::vec::Vector _v2(*gf, n_data); + quadiron::vec::Vector f(*gf, n_data); + quadiron::vec::Vector v2(*gf, n_data); + quadiron::vec::Vector v_p(*gf, n_data); std::vector ids; for (int i = 0; i < code_len; i++) ids.push_back(i); - std::vector props(code_len); + std::vector props(code_len); for (int j = 0; j < 1000; j++) { if (props_flag) { for (int i = 0; i < code_len; i++) - props[i] = quad::Properties(); + props[i] = quadiron::Properties(); } for (int i = 0; i < n_data; i++) v.set(i, gf->weak_rand()); @@ -149,7 +149,7 @@ class FECUtest { f.set(i, ids.at(i)); _v2.set(i, _v.get(ids.at(i))); } - std::unique_ptr> context = + std::unique_ptr> context = fec->init_context_dec(f); fec->decode(*context, &v2, props, 0, &_v2); // std::cout << "v2:"; v2.dump(); diff --git a/test/fft_utest.cpp b/test/fft_utest.cpp index 53a461f4..c44e4fb1 100644 --- a/test/fft_utest.cpp +++ b/test/fft_utest.cpp @@ -32,16 +32,16 @@ template class FFTUtest { public: - void test_gcd1(const quad::gf::Field& gf) + void test_gcd1(const quadiron::gf::Field& gf) { - quad::SignedDoubleSizeVal bezout[2]; + quadiron::SignedDoubleSizeVal bezout[2]; assert(gf.inv(20) == 34); // int i; for (i = 0; i < 100; i++) { T x = gf.weak_rand(); - assert(1 == quad::arith::extended_gcd(97, x, bezout, nullptr)); + assert(1 == quadiron::arith::extended_gcd(97, x, bezout, nullptr)); // std::cerr << bezout[0] << "*" << 97 << " " << bezout[1] << "*"; // stdd:cerr << x << "=1\n"; T y = gf.inv(x); @@ -56,7 +56,7 @@ class FFTUtest { { std::cout << "test_gcd\n"; - quad::gf::Prime gf(97); + quadiron::gf::Prime gf(97); test_gcd1(gf); } @@ -64,17 +64,17 @@ class FFTUtest { { std::cout << "test_quadratic_residues\n"; - quad::gf::Prime gf32(32); + quadiron::gf::Prime gf32(32); int i; for (i = 0; i < 32; i++) { assert(gf32.is_quadratic_residue(gf32.exp(i, 2))); } - quad::gf::Prime gf7(7); + quadiron::gf::Prime gf7(7); assert(gf7.is_quadratic_residue(2)); assert(!gf7.is_quadratic_residue(5)); - quad::gf::Prime gf8(8); + quadiron::gf::Prime gf8(8); assert(gf8.is_quadratic_residue(1)); assert(!gf8.is_quadratic_residue(3)); } @@ -86,11 +86,11 @@ class FFTUtest { * * @return */ - quad::vec::Vector* - _convert_string2vec(quad::gf::Field* gf, int n, char num[]) + quadiron::vec::Vector* + _convert_string2vec(quadiron::gf::Field* gf, int n, char num[]) { int i; - quad::vec::Vector* vec = new quad::vec::Vector(gf, n); + quadiron::vec::Vector* vec = new quadiron::vec::Vector(gf, n); int len = strlen(num); for (i = 0; i < len; i++) { @@ -108,14 +108,14 @@ class FFTUtest { unsigned n; unsigned r; T q = 65537; - quad::gf::Prime gf(q); + quadiron::gf::Prime gf(q); unsigned R = gf.get_primitive_root(); unsigned n_data = 3; unsigned n_parities = 3; std::cout << "Test fft::Naive\n"; - assert(quad::arith::jacobi(R, q) == -1); + assert(quadiron::arith::jacobi(R, q) == -1); // with this encoder we cannot exactly satisfy users request, we need to // pad n = minimal divisor of (q-1) that is at least (n_parities + @@ -128,11 +128,11 @@ class FFTUtest { // std::cerr << "n=" << n << "\n"; // std::cerr << "r=" << r << "\n"; - quad::fft::Naive fft(gf, n, r); + quadiron::fft::Naive fft(gf, n, r); - quad::vec::Vector v(gf, fft.get_n()); - quad::vec::Vector _v(gf, fft.get_n()); - quad::vec::Vector v2(gf, fft.get_n()); + quadiron::vec::Vector v(gf, fft.get_n()); + quadiron::vec::Vector _v(gf, fft.get_n()); + quadiron::vec::Vector v2(gf, fft.get_n()); for (int j = 0; j < 100000; j++) { v.zero_fill(); for (unsigned i = 0; i < n_data; i++) @@ -157,14 +157,14 @@ class FFTUtest { { unsigned n; unsigned q = 65537; - quad::gf::Prime gf(q); + quadiron::gf::Prime gf(q); unsigned R = gf.get_primitive_root(); unsigned n_data = 3; unsigned n_parities = 3; std::cout << "Test fft::Radix2 vec\n"; - assert(quad::arith::jacobi(R, q) == -1); + assert(quadiron::arith::jacobi(R, q) == -1); // with this encoder we cannot exactly satisfy users request, we need to // pad n = minimal divisor of (q-1) that is at least (n_parities + @@ -173,11 +173,11 @@ class FFTUtest { // std::cerr << "n=" << n << "\n"; - quad::fft::Radix2 fft(gf, n); + quadiron::fft::Radix2 fft(gf, n); - quad::vec::Vector v(gf, fft.get_n()); - quad::vec::Vector _v(gf, fft.get_n()); - quad::vec::Vector v2(gf, fft.get_n()); + quadiron::vec::Vector v(gf, fft.get_n()); + quadiron::vec::Vector _v(gf, fft.get_n()); + quadiron::vec::Vector v2(gf, fft.get_n()); for (int j = 0; j < 100000; j++) { v.zero_fill(); for (unsigned i = 0; i < n_data; i++) @@ -195,7 +195,7 @@ class FFTUtest { { unsigned n; unsigned q = 65537; - quad::gf::Prime gf(q); + quadiron::gf::Prime gf(q); unsigned R = gf.get_primitive_root(); unsigned n_data = 3; unsigned n_parities = 3; @@ -203,7 +203,7 @@ class FFTUtest { std::cout << "Test fft::Radix2 vecp\n"; - assert(quad::arith::jacobi(R, q) == -1); + assert(quadiron::arith::jacobi(R, q) == -1); // with this encoder we cannot exactly satisfy users request, we need to // pad n = minimal divisor of (q-1) that is at least (n_parities + @@ -212,14 +212,14 @@ class FFTUtest { // std::cerr << "n=" << n << "\n"; - quad::fft::Radix2 fft(gf, n); + quadiron::fft::Radix2 fft(gf, n); int vec_n = fft.get_n(); - quad::vec::Buffers v(n_data, size); - quad::vec::Buffers v2(vec_n, size); - quad::vec::Buffers _v2(vec_n, size); - quad::vec::BuffersZeroExtended _v(&v, vec_n); + quadiron::vec::Buffers v(n_data, size); + quadiron::vec::Buffers v2(vec_n, size); + quadiron::vec::Buffers _v2(vec_n, size); + quadiron::vec::BuffersZeroExtended _v(&v, vec_n); for (int j = 0; j < 100000; j++) { for (unsigned i = 0; i < n_data; i++) { T* mem = v.get(i); @@ -239,7 +239,7 @@ class FFTUtest { void test_fft_gt() { T n; - quad::gf::BinExtension gf(4); + quadiron::gf::BinExtension gf(4); T n_data = 3; T n_parities = 3; @@ -252,11 +252,11 @@ class FFTUtest { // std::cerr << "n=" << n << "\n"; - quad::fft::GoodThomas fft(gf, n); + quadiron::fft::GoodThomas fft(gf, n); - quad::vec::Vector v(gf, fft.get_n()); - quad::vec::Vector _v(gf, fft.get_n()); - quad::vec::Vector v2(gf, fft.get_n()); + quadiron::vec::Vector v(gf, fft.get_n()); + quadiron::vec::Vector _v(gf, fft.get_n()); + quadiron::vec::Vector v2(gf, fft.get_n()); for (int j = 0; j < 10000; j++) { v.zero_fill(); for (T i = 0; i < n_data; i++) @@ -274,7 +274,7 @@ class FFTUtest { { T n; T q = 65537; - quad::gf::Prime gf(q); + quadiron::gf::Prime gf(q); T n_data = 3; T n_parities = 3; @@ -287,11 +287,11 @@ class FFTUtest { // std::cerr << "n=" << n << "\n"; - quad::fft::CooleyTukey fft(gf, n); + quadiron::fft::CooleyTukey fft(gf, n); - quad::vec::Vector v(gf, fft.get_n()); - quad::vec::Vector _v(gf, fft.get_n()); - quad::vec::Vector v2(gf, fft.get_n()); + quadiron::vec::Vector v(gf, fft.get_n()); + quadiron::vec::Vector _v(gf, fft.get_n()); + quadiron::vec::Vector v2(gf, fft.get_n()); for (int j = 0; j < 10000; j++) { v.zero_fill(); for (T i = 0; i < n_data; i++) @@ -311,7 +311,7 @@ class FFTUtest { T n_data = 3; T n_parities = 3; for (size_t gf_n = 4; gf_n <= 128 && gf_n <= 8 * sizeof(T); gf_n *= 2) { - quad::gf::BinExtension gf(gf_n); + quadiron::gf::BinExtension gf(gf_n); std::cout << "Test fft::CooleyTukey on GF(2n)=" << gf_n << "\n"; @@ -322,9 +322,9 @@ class FFTUtest { // std::cerr << "n=" << n << "\n"; - quad::fft::CooleyTukey fft(gf, n); + quadiron::fft::CooleyTukey fft(gf, n); - quad::vec::Vector v(gf, fft.get_n()), _v(gf, fft.get_n()), + quadiron::vec::Vector v(gf, fft.get_n()), _v(gf, fft.get_n()), v2(gf, fft.get_n()); for (int j = 0; j < 10000; j++) { v.zero_fill(); @@ -341,20 +341,20 @@ class FFTUtest { } void - run_taylor_expand(const quad::gf::Field& gf, quad::fft::Additive* fft) + run_taylor_expand(const quadiron::gf::Field& gf, quadiron::fft::Additive* fft) { int t = 2 + gf.weak_rand() % (fft->get_n() - 2); int n = t + 1 + gf.weak_rand() % (fft->get_n() - t); - quad::vec::Vector v1(gf, n); + quadiron::vec::Vector v1(gf, n); int m = n / t; while (m * t < n) m++; - quad::vec::Vector v2(gf, t * m); + quadiron::vec::Vector v2(gf, t * m); for (int i = 0; i < n; i++) v1.set(i, gf.weak_rand()); // v1.dump(); fft->taylor_expand(&v2, &v1, n, t); - quad::vec::Vector _v1(gf, n); + quadiron::vec::Vector _v1(gf, n); fft->inv_taylor_expand(&_v1, &v2, t); // _v1.dump(); assert(_v1.eq(&v1)); @@ -362,8 +362,8 @@ class FFTUtest { // taylor expansion on (x^t - x) void test_taylor_expand( - const quad::gf::Field& gf, - quad::fft::Additive* fft) + const quadiron::gf::Field& gf, + quadiron::fft::Additive* fft) { std::cout << "test_taylor_expand\n"; for (int i = 0; i < 1000; i++) @@ -371,17 +371,17 @@ class FFTUtest { } void run_taylor_expand_t2( - const quad::gf::Field& gf, - quad::fft::Additive* fft) + const quadiron::gf::Field& gf, + quadiron::fft::Additive* fft) { int n = fft->get_n(); - quad::vec::Vector v1(gf, n); + quadiron::vec::Vector v1(gf, n); for (int i = 0; i < n; i++) v1.set(i, gf.weak_rand()); // v1.dump(); fft->taylor_expand_t2(&v1, n, true); // v1.dump(); - quad::vec::Vector _v1(gf, n); + quadiron::vec::Vector _v1(gf, n); fft->inv_taylor_expand_t2(&_v1); // _v1.dump(); assert(_v1.eq(&v1)); @@ -389,8 +389,8 @@ class FFTUtest { // taylor expansion on (x^2 - x) void test_taylor_expand_t2( - const quad::gf::Field& gf, - quad::fft::Additive* fft) + const quadiron::gf::Field& gf, + quadiron::fft::Additive* fft) { std::cout << "test_taylor_expand_t2\n"; for (int i = 0; i < 1000; i++) @@ -398,14 +398,14 @@ class FFTUtest { } void test_fftadd_codec( - const quad::gf::Field& gf, - quad::fft::Additive* fft, + const quadiron::gf::Field& gf, + quadiron::fft::Additive* fft, int n_data) { std::cout << "test_fftadd_codec\n"; - quad::vec::Vector v(gf, fft->get_n()); - quad::vec::Vector _v(gf, fft->get_n()); - quad::vec::Vector v2(gf, fft->get_n()); + quadiron::vec::Vector v(gf, fft->get_n()); + quadiron::vec::Vector _v(gf, fft->get_n()); + quadiron::vec::Vector v2(gf, fft->get_n()); for (int j = 0; j < 10000; j++) { v.zero_fill(); for (int i = 0; i < n_data; i++) @@ -425,14 +425,14 @@ class FFTUtest { int n_data = 3; int n_parities = 3; for (size_t gf_n = 4; gf_n <= 128 && gf_n <= 8 * sizeof(T); gf_n *= 2) { - quad::gf::BinExtension gf(gf_n); + quadiron::gf::BinExtension gf(gf_n); std::cout << "test_fftadd_with_n=" << gf_n << "\n"; // n is power of 2 and at least n_data + n_parities - n = quad::arith::get_smallest_power_of_2(n_data + n_parities); - m = quad::arith::log2(n); + n = quadiron::arith::get_smallest_power_of_2(n_data + n_parities); + m = quadiron::arith::log2(n); // std::cerr << "n=" << n << "\n"; - quad::fft::Additive fft(gf, m); + quadiron::fft::Additive fft(gf, m); test_taylor_expand(gf, &fft); test_taylor_expand_t2(gf, &fft); @@ -442,7 +442,7 @@ class FFTUtest { void test_fft_2_gfp() { - quad::gf::Prime gf(3); + quadiron::gf::Prime gf(3); T n_data = 1; std::cout << "Test fft::Size2 GF(p)\n"; @@ -453,11 +453,11 @@ class FFTUtest { // std::cerr << "n=" << n << "\n"; - quad::fft::Size2 fft(gf); + quadiron::fft::Size2 fft(gf); - quad::vec::Vector v(gf, fft.get_n()); - quad::vec::Vector _v(gf, fft.get_n()); - quad::vec::Vector v2(gf, fft.get_n()); + quadiron::vec::Vector v(gf, fft.get_n()); + quadiron::vec::Vector _v(gf, fft.get_n()); + quadiron::vec::Vector v2(gf, fft.get_n()); for (int j = 0; j < 100000; j++) { v.zero_fill(); for (T i = 0; i < n_data; i++) @@ -473,16 +473,16 @@ class FFTUtest { void test_fft_single_gfp() { - quad::gf::Prime gf(39); + quadiron::gf::Prime gf(39); std::cout << "Test fft::Single on GF(p)\n"; int n = 16; - quad::fft::Single fft(gf, n); + quadiron::fft::Single fft(gf, n); - quad::vec::Vector v(gf, fft.get_n()); - quad::vec::Vector _v(gf, fft.get_n()); - quad::vec::Vector v2(gf, fft.get_n()); + quadiron::vec::Vector v(gf, fft.get_n()); + quadiron::vec::Vector _v(gf, fft.get_n()); + quadiron::vec::Vector v2(gf, fft.get_n()); for (int j = 0; j < 100000; j++) { v.zero_fill(); v.set(0, gf.weak_rand()); @@ -500,14 +500,14 @@ class FFTUtest { unsigned n; unsigned r; unsigned q = 65537; - quad::gf::Prime gf(q); + quadiron::gf::Prime gf(q); unsigned R = gf.get_primitive_root(); unsigned n_data = 3; unsigned n_parities = 3; std::cout << "Test fft::Size2\n"; - assert(quad::arith::jacobi(R, q) == -1); + assert(quadiron::arith::jacobi(R, q) == -1); // with this encoder we cannot exactly satisfy users request, we need to // pad n = minimal divisor of (q-1) that is at least (n_parities + @@ -519,11 +519,11 @@ class FFTUtest { // std::cerr << "r=" << r << "\n"; - quad::fft::Naive fft(gf, n, r); + quadiron::fft::Naive fft(gf, n, r); - quad::vec::Vector v(gf, fft.get_n()); - quad::vec::Vector _v(gf, fft.get_n()); - quad::vec::Vector v2(gf, fft.get_n()); + quadiron::vec::Vector v(gf, fft.get_n()); + quadiron::vec::Vector _v(gf, fft.get_n()); + quadiron::vec::Vector v2(gf, fft.get_n()); v.zero_fill(); for (T i = 0; i < n_data; i++) v.set(i, gf.weak_rand()); @@ -555,7 +555,7 @@ class FFTUtest { void test_fft_gf2n_with_n(int n) { T r; - quad::gf::BinExtension gf(n); + quadiron::gf::BinExtension gf(n); T R = gf.get_primitive_root(); T n_data = 3; T n_parities = 3; @@ -574,11 +574,11 @@ class FFTUtest { // std::cerr << "n=" << n << "\n"; // std::cerr << "r=" << r << "\n"; - quad::fft::Naive fft(gf, n, r); + quadiron::fft::Naive fft(gf, n, r); - quad::vec::Vector v(gf, fft.get_n()); - quad::vec::Vector _v(gf, fft.get_n()); - quad::vec::Vector v2(gf, fft.get_n()); + quadiron::vec::Vector v(gf, fft.get_n()); + quadiron::vec::Vector _v(gf, fft.get_n()); + quadiron::vec::Vector v2(gf, fft.get_n()); for (T i = 0; i < 100000; i++) { v.zero_fill(); for (T i = 0; i < n_data; i++) diff --git a/test/gf_utest.cpp b/test/gf_utest.cpp index ac1d5f9f..35a3f89a 100644 --- a/test/gf_utest.cpp +++ b/test/gf_utest.cpp @@ -36,9 +36,9 @@ class GFUtest { { std::cout << "simple tests\n"; - quad::gf::Extension gf256( + quadiron::gf::Extension gf256( 2, 8); // dumb way to declare a binary field but for sake of testing - quad::Polynomial _x(gf256.get_sub_field()); + quadiron::Polynomial _x(gf256.get_sub_field()); _x.set(6, 1); _x.set(4, 1); _x.set(1, 1); @@ -55,8 +55,8 @@ class GFUtest { assert(_x.get(1) == 1); assert(_x.get(0) == 0); - quad::gf::Extension gf27(3, 3); - quad::Polynomial _y(gf27.get_sub_field()); + quadiron::gf::Extension gf27(3, 3); + quadiron::Polynomial _y(gf27.get_sub_field()); _y.set(2, 1); _y.set(0, 1); T y = gf27.inv(_y.to_num()); @@ -67,7 +67,7 @@ class GFUtest { assert(_y.get(0) == 0); } - void test_negation(quad::gf::Field* gf) + void test_negation(quadiron::gf::Field* gf) { int i; @@ -84,7 +84,7 @@ class GFUtest { } } - void test_negation_gf_nf4(quad::gf::NF4* gf) + void test_negation_gf_nf4(quadiron::gf::NF4* gf) { int i; @@ -101,7 +101,7 @@ class GFUtest { } } - void test_reciprocal(quad::gf::Field* gf) + void test_reciprocal(quadiron::gf::Field* gf) { int i; int n_found = 0; @@ -112,7 +112,7 @@ class GFUtest { x = gf->weak_rand(); try { y = gf->inv(x); - } catch (const quad::Exception& e) { + } catch (const quadiron::Exception& e) { continue; } assert(gf->mul(x, y) == 1); @@ -121,7 +121,7 @@ class GFUtest { assert(n_found > 0); } - void test_reciprocal_gf_nf4(quad::gf::NF4* gf) + void test_reciprocal_gf_nf4(quadiron::gf::NF4* gf) { int i; int n_found = 0; @@ -132,7 +132,7 @@ class GFUtest { x = gf->weak_rand_tuple(); try { y = gf->inv(x); - } catch (const quad::Exception& e) { + } catch (const quadiron::Exception& e) { continue; } assert(gf->mul(x, y) == gf->get_unit()); @@ -141,7 +141,7 @@ class GFUtest { assert(n_found > 0); } - void test_log(quad::gf::Field* gf) + void test_log(quadiron::gf::Field* gf) { int i; int n_found = 0; @@ -170,13 +170,13 @@ class GFUtest { assert(n_found > 0); } - void test_pack_unpack(quad::gf::NF4* gf) + void test_pack_unpack(quadiron::gf::NF4* gf) { int i; for (i = 0; i < 100; i++) { T x, y; - quad::GroupedValues z; + quadiron::GroupedValues z; // std::cout << "i=" << i << "\n"; @@ -190,14 +190,14 @@ class GFUtest { } } - void test_find_primitive_root(quad::gf::Field* gf) + void test_find_primitive_root(quadiron::gf::Field* gf) { gf->find_primitive_root(); // std::cout << "root " << gf->root << std::endl; assert(gf->check_primitive_root(gf->get_root())); } - void test_get_order(quad::gf::Field* gf) + void test_get_order(quadiron::gf::Field* gf) { int i; T x; @@ -213,7 +213,7 @@ class GFUtest { } } - void test_get_nth_root(quad::gf::Field* gf) + void test_get_nth_root(quadiron::gf::Field* gf) { int i; T x; @@ -232,7 +232,7 @@ class GFUtest { { std::cout << "test_negation_gf5\n"; - quad::gf::Prime gf5(5); + quadiron::gf::Prime gf5(5); test_negation(&gf5); } @@ -240,7 +240,7 @@ class GFUtest { { std::cout << "test_reciprocal_gf5\n"; - quad::gf::Prime gf5(5); + quadiron::gf::Prime gf5(5); test_reciprocal(&gf5); } @@ -248,7 +248,7 @@ class GFUtest { { std::cout << "test_log_gf5\n"; - quad::gf::Prime gf5(5); + quadiron::gf::Prime gf5(5); test_log(&gf5); } @@ -256,7 +256,7 @@ class GFUtest { { std::cout << "test_prime_root_gf5\n"; - quad::gf::Prime gf5(5); + quadiron::gf::Prime gf5(5); test_find_primitive_root(&gf5); test_get_order(&gf5); test_get_nth_root(&gf5); @@ -266,7 +266,7 @@ class GFUtest { { std::cout << "test_negation_gf9\n"; - quad::gf::Extension gf9(3, 2); + quadiron::gf::Extension gf9(3, 2); test_negation(&gf9); } @@ -274,7 +274,7 @@ class GFUtest { { std::cout << "test_reciprocal_gf9\n"; - quad::gf::Extension gf9(3, 2); + quadiron::gf::Extension gf9(3, 2); test_reciprocal(&gf9); } @@ -282,7 +282,7 @@ class GFUtest { { std::cout << "test_log_gf9\n"; - quad::gf::Extension gf9(3, 2); + quadiron::gf::Extension gf9(3, 2); test_log(&gf9); } @@ -290,7 +290,7 @@ class GFUtest { { std::cout << "test_prime_root_gf9\n"; - quad::gf::Extension gf9(3, 2); + quadiron::gf::Extension gf9(3, 2); test_find_primitive_root(&gf9); test_get_order(&gf9); test_get_nth_root(&gf9); @@ -300,7 +300,7 @@ class GFUtest { { std::cout << "test_negation_gf256\n"; - quad::gf::BinExtension gf256(8); + quadiron::gf::BinExtension gf256(8); test_negation(&gf256); } @@ -308,7 +308,7 @@ class GFUtest { { std::cout << "test_reciprocal_gf256\n"; - quad::gf::BinExtension gf256(8); + quadiron::gf::BinExtension gf256(8); test_reciprocal(&gf256); } @@ -316,7 +316,7 @@ class GFUtest { { std::cout << "test_log_gf256\n"; - quad::gf::BinExtension gf256(8); + quadiron::gf::BinExtension gf256(8); test_log(&gf256); } @@ -324,7 +324,7 @@ class GFUtest { { std::cout << "test_prime_root_gf256\n"; - quad::gf::BinExtension gf256(8); + quadiron::gf::BinExtension gf256(8); test_find_primitive_root(&gf256); test_get_order(&gf256); test_get_nth_root(&gf256); @@ -334,7 +334,7 @@ class GFUtest { { std::cout << "test_negation_gf(2^" << n << ")\n"; - quad::gf::BinExtension gf2n(n); + quadiron::gf::BinExtension gf2n(n); test_negation(&gf2n); } @@ -342,7 +342,7 @@ class GFUtest { { std::cout << "test_reciprocal_gf(2^" << n << ")\n"; - quad::gf::BinExtension gf2n(n); + quadiron::gf::BinExtension gf2n(n); test_reciprocal(&gf2n); } @@ -350,7 +350,7 @@ class GFUtest { { std::cout << "test_log_gf(2^" << n << ")\n"; - quad::gf::BinExtension gf2n(n); + quadiron::gf::BinExtension gf2n(n); test_log(&gf2n); } @@ -358,7 +358,7 @@ class GFUtest { { std::cout << "test_prime_root_gf(2^" << n << ")\n"; - quad::gf::BinExtension gf2n(n); + quadiron::gf::BinExtension gf2n(n); test_find_primitive_root(&gf2n); test_get_order(&gf2n); test_get_nth_root(&gf2n); @@ -368,9 +368,9 @@ class GFUtest { { std::cout << "gf_utest_gf_nf4_with_n=" << n << "\n"; - quad::prng().seed(time(0)); + quadiron::prng().seed(time(0)); - quad::gf::NF4 gf(n); + quadiron::gf::NF4 gf(n); test_negation_gf_nf4(&gf); test_reciprocal_gf_nf4(&gf); @@ -391,7 +391,7 @@ class GFUtest { { std::cout << "gf_utest\n"; - quad::prng().seed(time(0)); + quadiron::prng().seed(time(0)); simple_tests(); test_negation_gf5(); @@ -414,7 +414,7 @@ class GFUtest { { std::cout << "gf_utest 2^" << n << "\n"; - quad::prng().seed(time(0)); + quadiron::prng().seed(time(0)); test_negation_gf2_bign(n); test_reciprocal_gf2_bign(n); @@ -427,7 +427,7 @@ class GFUtest { { std::cout << "gf_utest_nogf2n\n"; - quad::prng().seed(time(0)); + quadiron::prng().seed(time(0)); test_negation_gf5(); test_reciprocal_gf5(); diff --git a/test/main.cpp b/test/main.cpp index 9f25e584..4bca9c2d 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -57,7 +57,7 @@ int main(int argc, char** argv) { struct test* p; - quad::prng().seed(0); + quadiron::prng().seed(0); if (2 == argc) { std::stringstream ss(argv[1]); diff --git a/test/mat_utest.cpp b/test/mat_utest.cpp index 6a794e7b..e355bb20 100644 --- a/test/mat_utest.cpp +++ b/test/mat_utest.cpp @@ -33,8 +33,8 @@ void mat_utest1() { std::cout << "mat_utest1\n"; - quad::gf::Prime gf11(11); - quad::vec::Matrix mat(gf11, 3, 3); + quadiron::gf::Prime gf11(11); + quadiron::vec::Matrix mat(gf11, 3, 3); mat.set(0, 0, 2); mat.set(0, 1, 1); @@ -63,8 +63,8 @@ void mat_utest2() { std::cout << "mat_utest2\n"; - quad::gf::Prime gf29(29); - quad::vec::Matrix mat(gf29, 3, 3); + quadiron::gf::Prime gf29(29); + quadiron::vec::Matrix mat(gf29, 3, 3); mat.set(0, 0, 22); mat.set(0, 1, 27); diff --git a/test/poly_utest.cpp b/test/poly_utest.cpp index 8175a03e..8ec1b4e1 100644 --- a/test/poly_utest.cpp +++ b/test/poly_utest.cpp @@ -31,9 +31,9 @@ void poly_utest1() { - quad::gf::Prime gfp(1000); + quadiron::gf::Prime gfp(1000); - quad::Polynomial p0(gfp); + quadiron::Polynomial p0(gfp); assert(0 == p0.degree()); } @@ -44,17 +44,17 @@ void poly_utest2() { std::cout << "poly_utest2\n"; - quad::gf::Prime gfp(11); - quad::Polynomial p1(gfp); + quadiron::gf::Prime gfp(11); + quadiron::Polynomial p1(gfp); p1.set(5, 1); p1.set(3, 3); p1.set(0, 4); // p1.dump(); - quad::Polynomial p2(gfp); + quadiron::Polynomial p2(gfp); p2.set(6, 6); p2.set(3, 4); // p2.dump(); - quad::Polynomial p3(gfp); + quadiron::Polynomial p3(gfp); p3.copy(&p2); p3.add(&p1); // p3.dump(); @@ -69,17 +69,17 @@ void poly_utest3() { std::cout << "poly_utest3\n"; - quad::gf::Prime gfp(11); - quad::Polynomial p1(gfp); + quadiron::gf::Prime gfp(11); + quadiron::Polynomial p1(gfp); p1.set(5, 1); p1.set(3, 3); p1.set(0, 4); // p1.dump(); - quad::Polynomial p2(gfp); + quadiron::Polynomial p2(gfp); p2.set(6, 6); p2.set(3, 4); // p2.dump(); - quad::Polynomial p3(gfp); + quadiron::Polynomial p3(gfp); p1._sub(&p3, &p1, &p2); assert(p3.degree() == 6); assert(p3.get(6) == 5); @@ -92,17 +92,17 @@ void poly_utest4() { std::cout << "poly_utest4\n"; - quad::gf::Prime gfp(11); - quad::Polynomial p1(gfp); + quadiron::gf::Prime gfp(11); + quadiron::Polynomial p1(gfp); p1.set(5, 1); p1.set(3, 3); p1.set(0, 4); // p1.dump(); - quad::Polynomial p2(gfp); + quadiron::Polynomial p2(gfp); p2.set(6, 6); p2.set(3, 4); // p2.dump(); - quad::Polynomial p3(gfp); + quadiron::Polynomial p3(gfp); p1._mul(&p3, &p1, &p2); assert(p3.degree() == 11); assert(p3.get(11) == 6); @@ -115,20 +115,20 @@ void poly_utest4() void poly_utest5() { std::cout << "poly_utest5\n"; - quad::gf::Prime gfp(11); - quad::Polynomial p1(gfp); + quadiron::gf::Prime gfp(11); + quadiron::Polynomial p1(gfp); p1.set(6, 3); p1.set(4, 7); p1.set(3, 4); p1.set(0, 5); // p1.dump(); - quad::Polynomial p2(gfp); + quadiron::Polynomial p2(gfp); p2.set(4, 1); p2.set(3, 3); p2.set(0, 4); // p2.dump(); - quad::Polynomial p3(gfp); - quad::Polynomial p4(gfp); + quadiron::Polynomial p3(gfp); + quadiron::Polynomial p4(gfp); p1._div(&p3, &p4, &p1, &p2); // p3.dump(); // p4.dump(); @@ -146,12 +146,12 @@ void poly_utest5() void poly_utest6() { std::cout << "poly_utest6\n"; - quad::gf::Prime gfp(11); - quad::Polynomial p1(gfp); + quadiron::gf::Prime gfp(11); + quadiron::Polynomial p1(gfp); p1.set(4, 4); p1.set(1, 1); p1.set(0, 8); - quad::Polynomial p2(gfp); + quadiron::Polynomial p2(gfp); p2.copy(&p1); p2.derivative(); assert(p2.degree() == 3); @@ -162,8 +162,8 @@ void poly_utest6() void poly_utest7() { std::cout << "poly_utest7\n"; - quad::gf::Prime gfp(11); - quad::Polynomial p1(gfp); + quadiron::gf::Prime gfp(11); + quadiron::Polynomial p1(gfp); p1.set(4, 4); p1.set(1, 1); p1.set(0, 8); @@ -174,17 +174,17 @@ void poly_utest7() void poly_utest8() { std::cout << "poly_utest8\n"; - quad::gf::Prime gfp(3); - quad::Polynomial p1(gfp); + quadiron::gf::Prime gfp(3); + quadiron::Polynomial p1(gfp); p1.set(4, 1); // p1.dump(); - quad::Polynomial p2(gfp); + quadiron::Polynomial p2(gfp); p2.set(3, 1); p2.set(2, 2); p2.set(0, 1); // p2.dump(); - quad::Polynomial p3(gfp); - quad::Polynomial p4(gfp); + quadiron::Polynomial p3(gfp); + quadiron::Polynomial p4(gfp); p1._div(&p3, &p4, &p1, &p2); // p3.dump(); // p4.dump(); diff --git a/test/rs_utest.cpp b/test/rs_utest.cpp index 321673d4..60daeed0 100644 --- a/test/rs_utest.cpp +++ b/test/rs_utest.cpp @@ -36,8 +36,8 @@ void rs_utest1() { std::cout << "rs_utest1\n"; - quad::gf::BinExtension gf16(4); - quad::vec::Matrix mat(gf16, 3, 3); + quadiron::gf::BinExtension gf16(4); + quadiron::vec::Matrix mat(gf16, 3, 3); mat.vandermonde_suitable_for_ec(); // mat.dump(); @@ -64,10 +64,10 @@ void rs_utest2() { std::cout << "rs_utest2\n"; - quad::gf::BinExtension gf8(3); - quad::vec::Matrix mat(gf8, 5, 3); - quad::vec::Vector vec(gf8, 3); - quad::vec::Vector output(gf8, 5); + quadiron::gf::BinExtension gf8(3); + quadiron::vec::Matrix mat(gf8, 5, 3); + quadiron::vec::Vector vec(gf8, 3); + quadiron::vec::Vector output(gf8, 5); mat.set(0, 0, 1); mat.set(0, 1, 1); @@ -102,7 +102,7 @@ void rs_utest3() { std::cout << "rs_utest3\n"; - quad::gf::BinExtension gf256(8); + quadiron::gf::BinExtension gf256(8); assert(gf256.mul(3, 7) == 9); assert(gf256.mul(13, 10) == 114); diff --git a/test/vector_utest.cpp b/test/vector_utest.cpp index 7617b14a..8dff4c9b 100644 --- a/test/vector_utest.cpp +++ b/test/vector_utest.cpp @@ -36,10 +36,10 @@ class VectorUtest { { std::cout << "vector_utest1\n"; - quad::gf::Prime gfp(65537); - quad::vec::Vector vec1(gfp, 16); - quad::vec::Vector vec2(gfp, 8); - quad::vec::Doubled v2vec2(&vec2); + quadiron::gf::Prime gfp(65537); + quadiron::vec::Vector vec1(gfp, 16); + quadiron::vec::Vector vec2(gfp, 8); + quadiron::vec::Doubled v2vec2(&vec2); vec1.set(0, 1); vec1.set(1, 64); @@ -91,10 +91,10 @@ class VectorUtest { { std::cout << "vector_utest2\n"; - quad::gf::Prime gfp(65537); - quad::vec::Vector vec1(gfp, 8); - quad::vec::Vector vec2(gfp, 4); - quad::vec::Doubled v2vec2(&vec2); + quadiron::gf::Prime gfp(65537); + quadiron::vec::Vector vec1(gfp, 8); + quadiron::vec::Vector vec2(gfp, 4); + quadiron::vec::Doubled v2vec2(&vec2); vec1.set(0, 5459); vec1.set(1, 11947); @@ -126,9 +126,9 @@ class VectorUtest { { std::cout << "vector_utest3\n"; - quad::gf::Prime gfp(65537); + quadiron::gf::Prime gfp(65537); int len = 20; - quad::vec::Vector base_vec(gfp, len); + quadiron::vec::Vector base_vec(gfp, len); for (int i = 0; i < len; i++) base_vec.set(i, gfp.weak_rand()); int len1 = 7; @@ -139,11 +139,11 @@ class VectorUtest { if (offset2 + len2 > len1) len3 = len1 - offset2; // vmvec1 = base_vec[offset1, .., offset1 + len1 - 1] - quad::vec::Slice vmvec1(&base_vec, len1, offset1); + quadiron::vec::Slice vmvec1(&base_vec, len1, offset1); // vmvec2 = vmvec1[offset2, .., min(offset2 + len2 - 1, len1 - 1)] - quad::vec::Slice vmvec2(&vmvec1, len2, offset2); + quadiron::vec::Slice vmvec2(&vmvec1, len2, offset2); // vmvec3 = base_vec[offset1 + offset2, .., offset1 + len1 - 1] - quad::vec::Slice vmvec3(&base_vec, len3, offset1 + offset2); + quadiron::vec::Slice vmvec3(&base_vec, len3, offset1 + offset2); assert(vmvec3.eq(&vmvec2)); }