Skip to content

Commit

Permalink
Style consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
dtebbs committed Oct 11, 2021
1 parent 5d1b6a6 commit 20fc9bf
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ namespace libfqfft {
template<typename FieldT>
bool arithmetic_sequence_domain<FieldT>::valid_for_size(const size_t m)
{
if (m <=1)
return false;
if (m <=1) {
return false;
}

if (FieldT::arithmetic_generator() == FieldT::zero())
return false;
if (FieldT::arithmetic_generator() == FieldT::zero()) {
return false;
}

return true;
}
Expand All @@ -54,7 +56,7 @@ void arithmetic_sequence_domain<FieldT>::FFT(std::vector<FieldT> &a)

/* Monomial to Newton */
monomial_to_newton_basis(a, this->subproduct_tree, this->m);

/* Newton to Evaluation */
std::vector<FieldT> S(this->m); /* i! * arithmetic_generator */
S[0] = FieldT::one();
Expand Down Expand Up @@ -82,7 +84,7 @@ template<typename FieldT>
void arithmetic_sequence_domain<FieldT>::iFFT(std::vector<FieldT> &a)
{
if (a.size() != this->m) throw DomainSizeException("arithmetic: expected a.size() == this->m");

if (!this->precomputation_sentinel) do_precomputation();

/* Interpolation to Newton */
Expand Down Expand Up @@ -164,7 +166,7 @@ std::vector<FieldT> arithmetic_sequence_domain<FieldT>::evaluate_all_lagrange_po

std::vector<FieldT> w(this->m);
w[0] = g_vanish.inverse() * (this->arithmetic_generator^(this->m-1));

l[0] = l_vanish * l[0].inverse() * w[0];
for (size_t i = 1; i < this->m; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion libfqfft/evaluation_domain/domains/basic_radix2_domain.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ bool basic_radix2_domain<FieldT>::valid_for_size(const size_t m)
return false;
}

if( get_root_of_unity_will_throw<FieldT>(m) )
if (get_root_of_unity_will_throw<FieldT>(m))
return false;

return true;
Expand Down
8 changes: 5 additions & 3 deletions libfqfft/evaluation_domain/domains/extended_radix2_domain.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,23 @@ namespace libfqfft {
template<typename FieldT>
bool extended_radix2_domain<FieldT>::valid_for_size(const size_t m)
{
if ( m <= 1 )
if (m <= 1) {
return false;
}

// Will `get_root_of_unity` throw?
if (!std::is_same<FieldT, libff::Double>::value)
{
const size_t logm = libff::log2(m);

if (logm != (FieldT::s + 1))
if (logm != (FieldT::s + 1)) {
return false;
}
}

size_t small_m = m / 2;

if( get_root_of_unity_will_throw<FieldT>(small_m) )
if (get_root_of_unity_will_throw<FieldT>(small_m))
return false;

return true;
Expand Down
18 changes: 10 additions & 8 deletions libfqfft/evaluation_domain/domains/geometric_sequence_domain.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ namespace libfqfft {
template<typename FieldT>
bool geometric_sequence_domain<FieldT>::valid_for_size(const size_t m)
{
if ( m <= 1 )
return false;
if ( m <= 1 ) {
return false;
}

if (FieldT::geometric_generator() == FieldT::zero())
return false;
if (FieldT::geometric_generator() == FieldT::zero()) {
return false;
}

return true;
return true;
}

template<typename FieldT>
Expand All @@ -41,13 +43,13 @@ geometric_sequence_domain<FieldT>::geometric_sequence_domain(const size_t m) : e
if (m <= 1) throw InvalidSizeException("geometric(): expected m > 1");
if (FieldT::geometric_generator() == FieldT::zero())
throw InvalidSizeException("geometric(): expected FieldT::geometric_generator() != FieldT::zero()");

precomputation_sentinel = 0;
}

template<typename FieldT>
void geometric_sequence_domain<FieldT>::FFT(std::vector<FieldT> &a)
{
{
if (a.size() != this->m) throw DomainSizeException("geometric: expected a.size() == this->m");

if (!this->precomputation_sentinel) do_precomputation();
Expand Down Expand Up @@ -83,7 +85,7 @@ template<typename FieldT>
void geometric_sequence_domain<FieldT>::iFFT(std::vector<FieldT> &a)
{
if (a.size() != this->m) throw DomainSizeException("geometric: expected a.size() == this->m");

if (!this->precomputation_sentinel) do_precomputation();

/* Interpolation to Newton */
Expand Down
8 changes: 4 additions & 4 deletions libfqfft/evaluation_domain/domains/step_radix2_domain.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace libfqfft {
template<typename FieldT>
bool step_radix2_domain<FieldT>::valid_for_size(const size_t m)
{
if ( m <= 1 )
if (m <= 1)
return false;

const size_t big_m = 1ul<<(libff::log2(m)-1);
Expand All @@ -30,11 +30,11 @@ bool step_radix2_domain<FieldT>::valid_for_size(const size_t m)
return false;

// omega
if( get_root_of_unity_will_throw<FieldT>(1ul<<libff::log2(m)) )
if (get_root_of_unity_will_throw<FieldT>(1ul<<libff::log2(m)))
return false;

// small_omega
if( get_root_of_unity_will_throw<FieldT>(1ul<<libff::log2(small_m)) )
if (get_root_of_unity_will_throw<FieldT>(1ul<<libff::log2(small_m)))
return false;

return true;
Expand All @@ -53,7 +53,7 @@ step_radix2_domain<FieldT>::step_radix2_domain(const size_t m) : evaluation_doma

try { omega = libff::get_root_of_unity<FieldT>(1ul<<libff::log2(m)); }
catch (const std::invalid_argument& e) { throw DomainSizeException(e.what()); }

big_omega = omega.squared();
small_omega = libff::get_root_of_unity<FieldT>(small_m);
}
Expand Down
20 changes: 10 additions & 10 deletions libfqfft/evaluation_domain/get_evaluation_domain.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ std::shared_ptr<evaluation_domain<FieldT> > get_evaluation_domain(const size_t m
const size_t small = min_size - big;
const size_t rounded_small = (1ul<<libff::log2(small));

if ( basic_radix2_domain<FieldT>::valid_for_size(min_size) ) {
result.reset(new basic_radix2_domain<FieldT>(min_size));
if (basic_radix2_domain<FieldT>::valid_for_size(min_size)) {
result.reset(new basic_radix2_domain<FieldT>(min_size));
}
else if ( extended_radix2_domain<FieldT>::valid_for_size(min_size) ) {
else if (extended_radix2_domain<FieldT>::valid_for_size(min_size)) {
result.reset(new extended_radix2_domain<FieldT>(min_size));
}
else if ( step_radix2_domain<FieldT>::valid_for_size(min_size) ) {
else if (step_radix2_domain<FieldT>::valid_for_size(min_size)) {
result.reset(new step_radix2_domain<FieldT>(min_size));
}
else if ( basic_radix2_domain<FieldT>::valid_for_size(big + rounded_small) ) {
else if (basic_radix2_domain<FieldT>::valid_for_size(big + rounded_small)) {
result.reset(new basic_radix2_domain<FieldT>(big + rounded_small));
}
else if ( extended_radix2_domain<FieldT>::valid_for_size(big + rounded_small) ) {
result.reset(new extended_radix2_domain<FieldT>(big + rounded_small));
else if (extended_radix2_domain<FieldT>::valid_for_size(big + rounded_small)) {
result.reset(new extended_radix2_domain<FieldT>(big + rounded_small));
}
else if ( step_radix2_domain<FieldT>::valid_for_size(big + rounded_small) ) {
else if (step_radix2_domain<FieldT>::valid_for_size(big + rounded_small)) {
result.reset(new step_radix2_domain<FieldT>(big + rounded_small));
}
else if ( geometric_sequence_domain<FieldT>::valid_for_size(min_size) ) {
else if (geometric_sequence_domain<FieldT>::valid_for_size(min_size)) {
result.reset(new geometric_sequence_domain<FieldT>(min_size));
}
else if ( arithmetic_sequence_domain<FieldT>::valid_for_size(min_size) ) {
else if (arithmetic_sequence_domain<FieldT>::valid_for_size(min_size)) {
result.reset(new arithmetic_sequence_domain<FieldT>(min_size));
}
else {
Expand Down

0 comments on commit 20fc9bf

Please sign in to comment.