Skip to content

Commit

Permalink
Fixed bug in IterTuple value_type
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlaine committed May 31, 2020
1 parent 70c090b commit 46a2487
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
8 changes: 4 additions & 4 deletions native/src/seal/evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,14 @@ namespace seal

// This lambda function takes as input an IterTuple with three components:
//
// 1. ConstRNSIter to read an input polynomial from
// 1. (Const)RNSIter to read an input polynomial from
// 2. RNSIter for the output in base q
// 3. RNSIter for the output in base Bsk
//
// It performs steps (1)-(3) of the BEHZ multiplication (see above) on the given input polynomial (given as an
// RNSIter or ConstRNSIter) and writes the results in base q and base Bsk to the given output
// iterators.
auto behz_extend_base_convert_to_ntt = [&](IterTuple<ConstRNSIter, RNSIter, RNSIter> I) {
auto behz_extend_base_convert_to_ntt = [&](auto I) {
// Make copy of input polynomial (in base q) and convert to NTT form
// Lazy reduction
set_poly(get<0>(I), coeff_count, base_q_size, get<1>(I));
Expand Down Expand Up @@ -607,13 +607,13 @@ namespace seal

// This lambda function takes as input an IterTuple with three components:
//
// 1. ConstRNSIter to read an input polynomial from
// 1. (Const)RNSIter to read an input polynomial from
// 2. RNSIter for the output in base q
// 3. RNSIter for the output in base Bsk
//
// It performs steps (1)-(3) of the BEHZ multiplication on the given input polynomial (given as an RNSIter
// or ConstRNSIter) and writes the results in base q and base Bsk to the given output iterators.
auto behz_extend_base_convert_to_ntt = [&](IterTuple<ConstRNSIter, RNSIter, RNSIter> I) {
auto behz_extend_base_convert_to_ntt = [&](auto I) {
// Make copy of input polynomial (in base q) and convert to NTT form
// Lazy reduction
set_poly(get<0>(I), coeff_count, base_q_size, get<1>(I));
Expand Down
37 changes: 20 additions & 17 deletions native/src/seal/util/iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,24 @@ namespace seal
}
};

namespace iterator_internal
{
template <typename... SEALIters>
struct extend_iter_tuple;

template <typename SEALIter, typename... Rest>
struct extend_iter_tuple<SEALIter, IterTuple<Rest...>>
{
using type = IterTuple<SEALIter, Rest...>;
};

template <typename SEALIter1, typename SEALIter2>
struct extend_iter_tuple<SEALIter1, SEALIter2>
{
using type = IterTuple<SEALIter1, SEALIter2>;
};
}

template <typename SEALIter, typename... Rest>
class IterTuple<SEALIter, Rest...> : public SEALIterBase
{
Expand All @@ -1584,9 +1602,9 @@ namespace seal
using self_type = IterTuple<SEALIter, Rest...>;

// Standard iterator typedefs
using value_type = IterTuple<
using value_type = typename iterator_internal::extend_iter_tuple<
typename std::iterator_traits<SEALIter>::value_type,
typename std::iterator_traits<IterTuple<Rest>>::value_type...>;
typename std::iterator_traits<IterTuple<Rest...>>::value_type>::type;
using pointer = void;
using reference = const value_type &;
using iterator_category = std::random_access_iterator_tag;
Expand Down Expand Up @@ -1970,21 +1988,6 @@ namespace seal
return iterator_internal::GetHelperStruct<N>::apply(it);
}

template <typename... SEALIters>
struct extend_iter_tuple;

template <typename SEALIter, typename... Rest>
struct extend_iter_tuple<SEALIter, IterTuple<Rest...>>
{
using type = IterTuple<SEALIter, Rest...>;
};

template <typename SEALIter1, typename SEALIter2>
struct extend_iter_tuple<SEALIter1, SEALIter2>
{
using type = IterTuple<SEALIter1, SEALIter2>;
};

template <typename T, typename... Rest>
struct iter_type<
std::void_t<
Expand Down

0 comments on commit 46a2487

Please sign in to comment.