Skip to content

Commit

Permalink
Merge pull request #223 from slaperche-scality/fix/fix_format
Browse files Browse the repository at this point in the history
fix code layout
  • Loading branch information
slaperche-scality authored Jul 27, 2018
2 parents 774f134 + c9219a2 commit 922eaf6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
29 changes: 21 additions & 8 deletions test/arith_utest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,23 @@ class ArithUtest {
// check overflow
assert(m / p1 == p2);
// std::cerr << " m=" << m << "\n";
assert(quadiron::arith::exp<T>((b - 1), 2) * quadiron::arith::exp<T>(p, 2) < m);
assert(
quadiron::arith::exp<T>((b - 1), 2) * quadiron::arith::exp<T>(p, 2)
< m);

// find x so it is not a quadratic residue in GF_p1 and GF_p2
assert(quadiron::arith::jacobi<T>(3, p1) == quadiron::arith::jacobi<T>(p1, 3));
assert(quadiron::arith::jacobi<T>(p1, 3) == quadiron::arith::jacobi<T>(2, 3));
assert(quadiron::arith::jacobi<T>(3, p2) == quadiron::arith::jacobi<T>(p2, 3));
assert(quadiron::arith::jacobi<T>(p2, 3) == quadiron::arith::jacobi<T>(2, 3));
assert(
quadiron::arith::jacobi<T>(3, p1)
== quadiron::arith::jacobi<T>(p1, 3));
assert(
quadiron::arith::jacobi<T>(p1, 3)
== quadiron::arith::jacobi<T>(2, 3));
assert(
quadiron::arith::jacobi<T>(3, p2)
== quadiron::arith::jacobi<T>(p2, 3));
assert(
quadiron::arith::jacobi<T>(p2, 3)
== quadiron::arith::jacobi<T>(2, 3));
assert(quadiron::arith::jacobi<T>(2, 3) == -1);
// which means x=3 is not a quadratic residue in GF_p1 and GF_p2

Expand Down Expand Up @@ -203,9 +213,11 @@ class ArithUtest {
quadiron::SignedDoubleSizeVal<T> bezout[2];

// not explicitely related to GF(97)
assert(2 == quadiron::arith::extended_gcd<T>(240, 46, nullptr, nullptr));
assert(
2 == quadiron::arith::extended_gcd<T>(240, 46, nullptr, nullptr));
assert(6 == quadiron::arith::extended_gcd<T>(54, 24, nullptr, nullptr));
assert(15 == quadiron::arith::extended_gcd<T>(210, 45, nullptr, nullptr));
assert(
15 == quadiron::arith::extended_gcd<T>(210, 45, nullptr, nullptr));
//
assert(1 == quadiron::arith::extended_gcd<T>(97, 20, bezout, nullptr));
assert(bezout[0] == -7 && bezout[1] == 34);
Expand Down Expand Up @@ -384,7 +396,8 @@ class ArithUtest {

std::vector<T> factors;
quadiron::arith::get_prime_factors<T>(order, &factors);
const T len = quadiron::arith::get_code_len_high_compo<T>(&factors, n);
const T len =
quadiron::arith::get_code_len_high_compo<T>(&factors, n);
// std::cout << "len=" << len << "\n";
assert(order % len == 0);
assert(len >= n);
Expand Down
6 changes: 4 additions & 2 deletions test/buffers_utest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class BuffersUtest {
delete this->gfp;
}

quadiron::vec::Buffers<T>* gen_buffers_rand_data(int n, int size, int _max = 0)
quadiron::vec::Buffers<T>*
gen_buffers_rand_data(int n, int size, int _max = 0)
{
const int max = (_max == 0) ? max_val : _max;
std::uniform_int_distribution<uint32_t> dis(0, max - 1);
Expand Down Expand Up @@ -240,7 +241,8 @@ class BuffersUtest {
// tmp vectors to store results
quadiron::vec::Buffers<T> vec_T_tmp(n, size);
std::vector<T*>* mem_T_tmp = vec_T_tmp.get_mem();
quadiron::vec::pack<uint8_t, T>(mem_char, mem_T_tmp, n, size, word_size);
quadiron::vec::pack<uint8_t, T>(
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
Expand Down
11 changes: 7 additions & 4 deletions test/fft_utest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class FFTUtest {
int i;
for (i = 0; i < 100; i++) {
T x = gf.weak_rand();
assert(1 == quadiron::arith::extended_gcd<T>(97, x, bezout, nullptr));
assert(
1 == quadiron::arith::extended_gcd<T>(97, x, bezout, nullptr));
// std::cerr << bezout[0] << "*" << 97 << " " << bezout[1] << "*";
// stdd:cerr << x << "=1\n";
T y = gf.inv(x);
Expand Down Expand Up @@ -340,8 +341,9 @@ class FFTUtest {
}
}

void
run_taylor_expand(const quadiron::gf::Field<T>& gf, quadiron::fft::Additive<T>* fft)
void run_taylor_expand(
const quadiron::gf::Field<T>& gf,
quadiron::fft::Additive<T>* fft)
{
int t = 2 + gf.weak_rand() % (fft->get_n() - 2);
int n = t + 1 + gf.weak_rand() % (fft->get_n() - t);
Expand Down Expand Up @@ -428,7 +430,8 @@ class FFTUtest {
quadiron::gf::BinExtension<T> 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 = quadiron::arith::get_smallest_power_of_2<T>(n_data + n_parities);
n = quadiron::arith::get_smallest_power_of_2<T>(
n_data + n_parities);
m = quadiron::arith::log2<T>(n);

// std::cerr << "n=" << n << "\n";
Expand Down

0 comments on commit 922eaf6

Please sign in to comment.