2 *****************************************************************************
4 Implementation of interfaces for an accumulation vector.
6 See accumulation_vector.hpp .
8 *****************************************************************************
9 * @author This file is part of libsnark, developed by SCIPR Lab
10 * and contributors (see AUTHORS).
11 * @copyright MIT license (see LICENSE file)
12 *****************************************************************************/
14 #ifndef ACCUMULATION_VECTOR_TCC_
15 #define ACCUMULATION_VECTOR_TCC_
21 bool accumulation_vector<T>::operator==(
22 const accumulation_vector<T> &other) const
24 return (this->first == other.first && this->rest == other.rest);
27 template<typename T> bool accumulation_vector<T>::is_fully_accumulated() const
32 template<typename T> size_t accumulation_vector<T>::domain_size() const
34 return rest.domain_size();
37 template<typename T> size_t accumulation_vector<T>::size() const
39 return rest.domain_size();
42 template<typename T> size_t accumulation_vector<T>::size_in_bits() const
44 const size_t first_size_in_bits = T::size_in_bits();
45 const size_t rest_size_in_bits = rest.size_in_bits();
46 return first_size_in_bits + rest_size_in_bits;
50 template<typename FieldT>
51 accumulation_vector<T> accumulation_vector<T>::accumulate_chunk(
52 const typename std::vector<FieldT>::const_iterator &it_begin,
53 const typename std::vector<FieldT>::const_iterator &it_end,
54 const size_t offset) const
56 std::pair<T, sparse_vector<T>> acc_result =
57 rest.template accumulate<FieldT>(it_begin, it_end, offset);
58 T new_first = first + acc_result.first;
59 return accumulation_vector<T>(
60 std::move(new_first), std::move(acc_result.second));
64 std::ostream &operator<<(std::ostream &out, const accumulation_vector<T> &v)
66 out << v.first << OUTPUT_NEWLINE;
67 out << v.rest << OUTPUT_NEWLINE;
73 std::istream &operator>>(std::istream &in, accumulation_vector<T> &v)
76 libff::consume_OUTPUT_NEWLINE(in);
78 libff::consume_OUTPUT_NEWLINE(in);
83 } // namespace libsnark
85 #endif // ACCUMULATION_VECTOR_TCC_