Skip to content

Commit

Permalink
Fixed issues when compiling on g++-6
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlaine committed Jun 16, 2020
1 parent eac2802 commit 111cc33
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
20 changes: 7 additions & 13 deletions native/src/seal/batchencoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,9 @@ namespace seal

// First write the values to destination coefficients. Read
// in top row, then bottom row.
using index_type = decltype(values_matrix)::size_type;
for (size_t i = 0; i < values_matrix_size; i++)
{
*(destination.data() + matrix_reps_index_map_[i]) = values_matrix[static_cast<index_type>(i)];
*(destination.data() + matrix_reps_index_map_[i]) = values_matrix[i];
}
for (size_t i = values_matrix_size; i < slots_; i++)
{
Expand Down Expand Up @@ -267,13 +266,11 @@ namespace seal

// First write the values to destination coefficients. Read
// in top row, then bottom row.
using index_type = decltype(values_matrix)::size_type;
for (size_t i = 0; i < values_matrix_size; i++)
{
*(destination.data() + matrix_reps_index_map_[i]) =
(values_matrix[static_cast<index_type>(i)] < 0)
? (modulus + static_cast<uint64_t>(values_matrix[static_cast<index_type>(i)]))
: static_cast<uint64_t>(values_matrix[static_cast<index_type>(i)]);
(values_matrix[i] < 0) ? (modulus + static_cast<uint64_t>(values_matrix[i]))
: static_cast<uint64_t>(values_matrix[i]);
}
for (size_t i = values_matrix_size; i < slots_; i++)
{
Expand Down Expand Up @@ -436,7 +433,6 @@ namespace seal

auto &context_data = *context_->first_context_data();

using index_type = decltype(destination)::size_type;
if (unsigned_gt(destination.size(), numeric_limits<int>::max()) || unsigned_neq(destination.size(), slots_))
{
throw invalid_argument("destination has incorrect size");
Expand All @@ -457,7 +453,7 @@ namespace seal
// Read top row
for (size_t i = 0; i < slots_; i++)
{
destination[static_cast<index_type>(i)] = temp_dest[matrix_reps_index_map_[i]];
destination[i] = temp_dest[matrix_reps_index_map_[i]];
}
}

Expand All @@ -479,7 +475,6 @@ namespace seal
auto &context_data = *context_->first_context_data();
uint64_t modulus = context_data.parms().plain_modulus().value();

using index_type = decltype(destination)::size_type;
if (unsigned_gt(destination.size(), numeric_limits<int>::max()) || unsigned_neq(destination.size(), slots_))
{
throw invalid_argument("destination has incorrect size");
Expand All @@ -502,10 +497,9 @@ namespace seal
for (size_t i = 0; i < slots_; i++)
{
uint64_t curr_value = temp_dest[matrix_reps_index_map_[i]];
destination[static_cast<index_type>(i)] =
(curr_value > plain_modulus_div_two)
? (static_cast<int64_t>(curr_value) - static_cast<int64_t>(modulus))
: static_cast<int64_t>(curr_value);
destination[i] = (curr_value > plain_modulus_div_two)
? (static_cast<int64_t>(curr_value) - static_cast<int64_t>(modulus))
: static_cast<int64_t>(curr_value);
}
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions native/src/seal/evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ namespace seal
encrypted_iter += encrypted_size - 1;

SEAL_ITERATE(iter(size_t(0)), relins_needed, [&](auto I) {
switch_key_inplace(
this->switch_key_inplace(
encrypted, *encrypted_iter, static_cast<const KSwitchKeys &>(relin_keys),
RelinKeys::get_index(encrypted_size - 1 - I), pool);
});
Expand Down Expand Up @@ -1987,7 +1987,7 @@ namespace seal
if (safe_cast<size_t>(abs(step)) != (coeff_count >> 1))
{
// Apply rotation for this step
rotate_internal(encrypted, step, galois_keys, pool);
this->rotate_internal(encrypted, step, galois_keys, pool);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion native/src/seal/keygenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ namespace seal
#endif
destination.data().resize(num_keys);
SEAL_ITERATE(iter(new_keys, destination.data()), num_keys, [&](auto I) {
generate_one_kswitch_key(get<0>(I), get<1>(I), save_seed);
this->generate_one_kswitch_key(get<0>(I), get<1>(I), save_seed);
});
}
} // namespace seal
8 changes: 4 additions & 4 deletions native/src/seal/util/galois.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace seal
}
#endif
SEAL_ITERATE(iter(operand, modulus, result), coeff_modulus_size, [&](auto I) {
apply_galois(get<0>(I), galois_elt, get<1>(I), get<2>(I));
this->apply_galois(get<0>(I), galois_elt, get<1>(I), get<2>(I));
});
}

Expand All @@ -71,7 +71,7 @@ namespace seal
#endif
auto coeff_modulus_size = result.coeff_modulus_size();
SEAL_ITERATE(iter(operand, result), size, [&](auto I) {
apply_galois(get<0>(I), coeff_modulus_size, galois_elt, modulus, get<1>(I));
this->apply_galois(get<0>(I), coeff_modulus_size, galois_elt, modulus, get<1>(I));
});
}

Expand All @@ -91,7 +91,7 @@ namespace seal
}
#endif
SEAL_ITERATE(iter(operand, result), coeff_modulus_size, [&](auto I) {
apply_galois_ntt(get<0>(I), galois_elt, get<1>(I));
this->apply_galois_ntt(get<0>(I), galois_elt, get<1>(I));
});
}

Expand All @@ -114,7 +114,7 @@ namespace seal
#endif
auto coeff_modulus_size = result.coeff_modulus_size();
SEAL_ITERATE(iter(operand, result), size, [&](auto I) {
apply_galois_ntt(get<0>(I), coeff_modulus_size, galois_elt, get<1>(I));
this->apply_galois_ntt(get<0>(I), coeff_modulus_size, galois_elt, get<1>(I));
});
}

Expand Down

0 comments on commit 111cc33

Please sign in to comment.