2 *****************************************************************************
3 * @author This file is part of libff, developed by SCIPR Lab
4 * and contributors (see AUTHORS).
5 * @copyright MIT license (see LICENSE file)
6 *****************************************************************************/
14 template<typename FieldT> void bn_batch_invert(std::vector<FieldT> &vec)
16 std::vector<FieldT> prod;
17 prod.reserve(vec.size());
23 prod.emplace_back(acc);
24 FieldT::mul(acc, acc, el);
27 FieldT acc_inverse = acc;
28 acc_inverse.inverse();
30 for (long i = vec.size() - 1; i >= 0; --i) {
31 const FieldT old_el = vec[i];
32 FieldT::mul(vec[i], acc_inverse, prod[i]);
33 FieldT::mul(acc_inverse, acc_inverse, old_el);
38 #endif // FIELD_UTILS_TCC_