polynomial.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2020-2021 Mikhail Komarov <nemo@nil.foundation>
3 // Copyright (c) 2020-2021 Nikita Kaskov <nbering@nil.foundation>
4 //
5 // MIT License
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included in all
15 // copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 // SOFTWARE.
24 //---------------------------------------------------------------------------//
25 
26 #ifndef CRYPTO3_MATH_POLYNOMIAL_POLYNOM_HPP
27 #define CRYPTO3_MATH_POLYNOMIAL_POLYNOM_HPP
28 
29 #include <algorithm>
30 #include <vector>
31 
33 
34 namespace nil {
35  namespace crypto3 {
36  namespace math {
37  template<typename FieldValueType, typename Allocator = std::allocator<FieldValueType>>
38  class polynomial {
39  typedef std::vector<FieldValueType, Allocator> container_type;
40 
41  container_type val;
42 
43  public:
44  typedef typename container_type::value_type value_type;
45  typedef typename container_type::allocator_type allocator_type;
46  typedef typename container_type::reference reference;
47  typedef typename container_type::const_reference const_reference;
48  typedef typename container_type::size_type size_type;
49  typedef typename container_type::difference_type difference_type;
50  typedef typename container_type::pointer pointer;
51  typedef typename container_type::const_pointer const_pointer;
52  typedef typename container_type::iterator iterator;
53  typedef typename container_type::const_iterator const_iterator;
54  typedef typename container_type::reverse_iterator reverse_iterator;
55  typedef typename container_type::const_reverse_iterator const_reverse_iterator;
56 
57  polynomial() : val({0}) {
58  }
59 
60  explicit polynomial(size_type n) : val(n) {
61  }
62  explicit polynomial(size_type n, const allocator_type& a) : val(n, a) {
63  }
64 
65  polynomial(size_type n, const value_type& x) : val(n, x) {
66  }
67  polynomial(size_type n, const value_type& x, const allocator_type& a) : val(n, x, a) {
68  }
69  template<typename InputIterator>
70  polynomial(InputIterator first, InputIterator last) : val(first, last) {
71  }
72  template<typename InputIterator>
73  polynomial(InputIterator first, InputIterator last, const allocator_type& a) : val(first, last, a) {
74  }
75 
76  ~polynomial() = default;
77 
78  polynomial(const polynomial& x) : val(x.val) {
79  }
80  polynomial(const polynomial& x, const allocator_type& a) : val(x.val, a) {
81  }
82 
83  polynomial(std::initializer_list<value_type> il) : val(il) {
84  }
85 
86  polynomial(std::initializer_list<value_type> il, const allocator_type& a) : val(il, a) {
87  }
88 
89  polynomial(polynomial&& x) BOOST_NOEXCEPT(std::is_nothrow_move_constructible<allocator_type>::value) :
90  val(x.val) {
91  }
92 
93  polynomial(polynomial&& x, const allocator_type& a) : val(x.val, a) {
94  }
95 
96  polynomial(const FieldValueType& value, std::size_t power = 0) : val(power + 1, FieldValueType(0)) {
97  this->operator[](power) = value;
98  }
99 
100  polynomial(const container_type &c) : val(c) {
101 
102  }
103 
104  polynomial(container_type &&c) : val(c) {
105 
106  }
107 
109  val = x.val;
110  return *this;
111  }
112 
114  val = x.val;
115  return *this;
116  }
117 
118  polynomial& operator=(const container_type& x) {
119  val = x;
120  return *this;
121  }
122 
123  polynomial& operator=(container_type&& x) {
124  val = x;
125  return *this;
126  }
127 
128  polynomial& operator=(std::initializer_list<value_type> il) {
129  val.assign(il.begin(), il.end());
130  return *this;
131  }
132 
133  bool operator==(const polynomial& rhs) const {
134  return val == rhs.val;
135  }
136  bool operator!=(const polynomial& rhs) const {
137  return !(rhs == *this);
138  }
139 
140  template<typename InputIterator>
141  typename std::iterator_traits<InputIterator>::reference assign(InputIterator first,
142  InputIterator last) {
143  return val.assign(first, last);
144  }
145 
147  return val.assign(n, u);
148  }
149 
150  void assign(std::initializer_list<value_type> il) {
151  assign(il.begin(), il.end());
152  }
153 
154  allocator_type get_allocator() const BOOST_NOEXCEPT {
155  return this->val.__alloc();
156  }
157 
158  iterator begin() BOOST_NOEXCEPT {
159  return val.begin();
160  }
161 
162  const_iterator begin() const BOOST_NOEXCEPT {
163  return val.begin();
164  }
165  iterator end() BOOST_NOEXCEPT {
166  return val.end();
167  }
168  const_iterator end() const BOOST_NOEXCEPT {
169  return val.end();
170  }
171 
172  reverse_iterator rbegin() BOOST_NOEXCEPT {
173  return val.rbegin();
174  }
175 
176  const_reverse_iterator rbegin() const BOOST_NOEXCEPT {
177  return val.rbegin();
178  }
179 
180  reverse_iterator rend() BOOST_NOEXCEPT {
181  return reverse_iterator(begin());
182  }
183 
184  const_reverse_iterator rend() const BOOST_NOEXCEPT {
185  return const_reverse_iterator(begin());
186  }
187 
188  const_iterator cbegin() const BOOST_NOEXCEPT {
189  return begin();
190  }
191 
192  const_iterator cend() const BOOST_NOEXCEPT {
193  return end();
194  }
195 
196  const_reverse_iterator crbegin() const BOOST_NOEXCEPT {
197  return rbegin();
198  }
199 
200  const_reverse_iterator crend() const BOOST_NOEXCEPT {
201  return rend();
202  }
203 
204  size_type size() const BOOST_NOEXCEPT {
205  return val.size();
206  }
207 
208  size_type degree() const BOOST_NOEXCEPT {
209  return size() - 1;
210  }
211 
212  size_type capacity() const BOOST_NOEXCEPT {
213  return val.capacity();
214  }
215  bool empty() const BOOST_NOEXCEPT {
216  return val.empty();
217  }
218  size_type max_size() const BOOST_NOEXCEPT {
219  return val.max_size();
220  }
221  void reserve(size_type _n) {
222  return val.reserve(_n);
223  }
224  void shrink_to_fit() BOOST_NOEXCEPT {
225  return val.shrink_to_fit();
226  }
227 
228  reference operator[](size_type _n) BOOST_NOEXCEPT {
229  return val[_n];
230  }
231  const_reference operator[](size_type _n) const BOOST_NOEXCEPT {
232  return val[_n];
233  }
235  return val.at(_n);
236  }
238  return val.at(_n);
239  }
240 
241  reference front() BOOST_NOEXCEPT {
242  return val.front();
243  }
244  const_reference front() const BOOST_NOEXCEPT {
245  return val.front();
246  }
247  reference back() BOOST_NOEXCEPT {
248  return val.back();
249  }
250  const_reference back() const BOOST_NOEXCEPT {
251  return val.back();
252  }
253 
254  value_type* data() BOOST_NOEXCEPT {
255  return val.data();
256  }
257 
258  const value_type* data() const BOOST_NOEXCEPT {
259  return val.data();
260  }
261 
263  val.push_back(_x);
264  }
265 
266  void push_back(value_type&& _x) {
267  val.push_back(_x);
268  }
269 
270  template<class... Args>
271  reference emplace_back(Args&&... _args) {
272  return val.template emplace_back(_args...);
273  }
274 
275  void pop_back() {
276  val.pop_back();
277  }
278 
280  return val.insert(_position, _x);
281  }
282 
284  return val.insert(_position, _x);
285  }
286  template<class... Args>
287  iterator emplace(const_iterator _position, Args&&... _args) {
288  return val.template emplace(_position, _args...);
289  }
290 
292  return val.insert(_position, _n, _x);
293  }
294 
295  template<class InputIterator>
296  iterator insert(const_iterator _position, InputIterator _first, InputIterator _last) {
297  return val.insert(_position, _first, _last);
298  }
299 
300  iterator insert(const_iterator _position, std::initializer_list<value_type> _il) {
301  return insert(_position, _il.begin(), _il.end());
302  }
303 
305  return val.erase(_position);
306  }
307 
309  return val.erase(_first, _last);
310  }
311 
312  void clear() BOOST_NOEXCEPT {
313  val.clear();
314  }
315 
316  void resize(size_type _sz) {
317  return val.resize(_sz);
318  }
319 
321  return val.resize(_sz, _x);
322  }
323 
324  void swap(polynomial& other) {
325  val.swap(other.val);
326  }
327 
328  template<typename Range>
329  FieldValueType evaluate(const Range& values) const {
330 
331  assert(values.size() + 1 == this->size());
332 
333  FieldValueType result = (*this)[0];
334  for (std::size_t i = 0; i < values.size(); i++) {
335  result += (*this)[i + 1] * values[i];
336  }
337 
338  return result;
339  }
340 
341  FieldValueType evaluate(const FieldValueType& value) const {
342  FieldValueType result = 0;
343  auto end = this->end();
344  while (end != this->begin()) {
345  result = result * value + *--end;
346  }
347  return result;
348  }
349 
353  bool is_zero() const {
354  return std::all_of(this->begin(), this->end(),
355  [](FieldValueType i) { return i == FieldValueType(0); });
356  }
357 
363  void condense() {
364  while (std::distance(this->cbegin(), this->cend()) > 1 &&
365  this->back() == typename std::iterator_traits<decltype(std::begin(
366  std::declval<container_type>()))>::value_type()) {
367  this->pop_back();
368  }
369  }
370 
376  void reverse(std::size_t n) {
377  std::reverse(this->begin(), this->end());
378  this->resize(n);
379  }
380 
385  polynomial operator+(const polynomial& other) const {
386  if (this->is_zero()) {
387  return other;
388  } else if (other.is_zero()) {
389  return *this;
390  } else {
391  polynomial result;
392 
393  std::size_t a_size = std::distance(this->begin(), this->end());
394  std::size_t b_size = std::distance(other.begin(), other.end());
395 
396  if (a_size > b_size) {
397  result.resize(a_size);
398  std::transform(other.begin(), other.end(), this->begin(), result.begin(),
399  std::plus<FieldValueType>());
400  std::copy(this->begin() + b_size, this->end(), result.begin() + b_size);
401  } else {
402  result.resize(b_size);
403  std::transform(this->begin(), this->end(), other.begin(), result.begin(),
404  std::plus<FieldValueType>());
405  std::copy(other.begin() + a_size, other.end(), result.begin() + a_size);
406  }
407 
408  result.condense();
409 
410  return result;
411  }
412  }
413 
415 
416  polynomial result(this->size());
417  std::transform(this->begin(), this->end(), result.begin(), std::negate<FieldValueType>());
418 
419  return result;
420  }
421 
426  polynomial operator-(const polynomial& other) const {
427  if (this->is_zero()) {
428  return -(other);
429  } else if (other.is_zero()) {
430  return *this;
431  } else {
432  polynomial result;
433 
434  std::size_t a_size = std::distance(this->begin(), this->end());
435  std::size_t b_size = std::distance(other.begin(), other.end());
436 
437  if (a_size > b_size) {
438  result.resize(a_size);
439  std::transform(this->begin(), this->begin() + b_size, other.begin(), result.begin(),
440  std::minus<FieldValueType>());
441  std::copy(this->begin() + b_size, this->end(), result.begin() + b_size);
442  } else {
443  result.resize(b_size);
444  std::transform(this->begin(), this->end(), other.begin(), result.begin(),
445  std::minus<FieldValueType>());
446  std::transform(other.begin() + a_size, other.end(), result.begin() + a_size,
447  std::negate<FieldValueType>());
448  }
449 
450  result.condense();
451 
452  return result;
453  }
454  }
455 
460  polynomial operator*(const polynomial& other) const {
461  polynomial result;
462  fft_multiplication(result, *this, other);
463  return result;
464  }
465 
471  polynomial operator/(const polynomial& other) const {
472 
473  std::size_t d = other.size() - 1; /* Degree of B */
474  FieldValueType c = other.back().inversed(); /* Inverse of Leading Coefficient of B */
475 
476  polynomial r(*this);
477  polynomial q = polynomial(r.size(), FieldValueType::zero());
478 
479  std::size_t r_deg = r.size() - 1;
480  std::size_t shift;
481 
482  while (r_deg >= d && !r.is_zero()) {
483  if (r_deg >= d) {
484  shift = r_deg - d;
485  } else {
486  shift = 0;
487  }
488 
489  FieldValueType lead_coeff = r.back() * c;
490 
491  q[shift] += lead_coeff;
492 
493  if (other.size() + shift + 1 > r.size()) {
494  r.resize(other.size() + shift + 1);
495  }
496  auto glambda = [=](const FieldValueType& x, const FieldValueType& y) {
497  return y - (x * lead_coeff);
498  };
499  std::transform(other.begin(), other.end(), r.begin() + shift, r.begin() + shift, glambda);
500  r.condense();
501 
502  r_deg = r.size() - 1;
503  }
504  q.condense();
505 
506  return q;
507  }
508 
514  polynomial operator%(const polynomial& other) const {
515  std::size_t d = other.size() - 1; /* Degree of B */
516  FieldValueType c = other.back().inversed(); /* Inverse of Leading Coefficient of B */
517 
518  polynomial r(*this);
519  polynomial q = polynomial(r.size(), FieldValueType::zero());
520 
521  std::size_t r_deg = r.size() - 1;
522  std::size_t shift;
523 
524  while (r_deg >= d && !r.is_zero()) {
525  if (r_deg >= d) {
526  shift = r_deg - d;
527  } else {
528  shift = 0;
529  }
530 
531  FieldValueType lead_coeff = r.back() * c;
532 
533  q[shift] += lead_coeff;
534 
535  if (other.size() + shift + 1 > r.size()) {
536  r.resize(other.size() + shift + 1);
537  }
538  auto glambda = [=](FieldValueType x, FieldValueType y) { return y - (x * lead_coeff); };
539  std::transform(other.begin(), other.end(), r.begin() + shift, r.begin() + shift, glambda);
540  r.condense();
541 
542  r_deg = r.size() - 1;
543  }
544 
545  return r;
546  }
547  };
548 
549  template<typename FieldValueType, typename Allocator = std::allocator<FieldValueType>,
550  typename = typename std::enable_if<detail::is_field_element<FieldValueType>::value>::type>
552  const FieldValueType& B) {
553 
554  return A + polynomial<FieldValueType>(B);
555  }
556 
557  template<typename FieldValueType, typename Allocator = std::allocator<FieldValueType>,
558  typename = typename std::enable_if<detail::is_field_element<FieldValueType>::value>::type>
561 
562  return polynomial<FieldValueType>(A) + B;
563  }
564 
565  template<typename FieldValueType, typename Allocator = std::allocator<FieldValueType>,
566  typename = typename std::enable_if<detail::is_field_element<FieldValueType>::value>::type>
568  const FieldValueType& B) {
569 
570  return A - polynomial<FieldValueType>(B);
571  }
572 
573  template<typename FieldValueType, typename Allocator = std::allocator<FieldValueType>,
574  typename = typename std::enable_if<detail::is_field_element<FieldValueType>::value>::type>
577 
578  return polynomial<FieldValueType>(A) - B;
579  }
580 
581  template<typename FieldValueType, typename Allocator = std::allocator<FieldValueType>,
582  typename = typename std::enable_if<detail::is_field_element<FieldValueType>::value>::type>
584  const FieldValueType& B) {
585 
586  return A * polynomial<FieldValueType>(B);
587  }
588 
589  template<typename FieldValueType, typename Allocator = std::allocator<FieldValueType>,
590  typename = typename std::enable_if<detail::is_field_element<FieldValueType>::value>::type>
593 
594  return polynomial<FieldValueType>(A) * B;
595  }
596 
597  template<typename FieldValueType, typename Allocator = std::allocator<FieldValueType>,
598  typename = typename std::enable_if<detail::is_field_element<FieldValueType>::value>::type>
600  const FieldValueType& B) {
601 
602  return A / polynomial<FieldValueType>(B);
603  }
604 
605  template<typename FieldValueType, typename Allocator = std::allocator<FieldValueType>,
606  typename = typename std::enable_if<detail::is_field_element<FieldValueType>::value>::type>
609 
610  return polynomial<FieldValueType>(A) / B;
611  }
612  } // namespace math
613  } // namespace crypto3
614 } // namespace nil
615 
616 #endif // CRYPTO3_MATH_POLYNOMIAL_POLYNOM_HPP
Definition: polynomial.hpp:38
FieldValueType evaluate(const Range &values) const
Definition: polynomial.hpp:329
polynomial(InputIterator first, InputIterator last, const allocator_type &a)
Definition: polynomial.hpp:73
void resize(size_type _sz)
Definition: polynomial.hpp:316
const_reference operator[](size_type _n) const BOOST_NOEXCEPT
Definition: polynomial.hpp:231
container_type::reverse_iterator reverse_iterator
Definition: polynomial.hpp:54
polynomial(const container_type &c)
Definition: polynomial.hpp:100
polynomial(container_type &&c)
Definition: polynomial.hpp:104
void condense()
Definition: polynomial.hpp:363
polynomial operator-() const
Definition: polynomial.hpp:414
size_type size() const BOOST_NOEXCEPT
Definition: polynomial.hpp:204
const_iterator end() const BOOST_NOEXCEPT
Definition: polynomial.hpp:168
container_type::const_reverse_iterator const_reverse_iterator
Definition: polynomial.hpp:55
polynomial(size_type n, const allocator_type &a)
Definition: polynomial.hpp:62
void push_back(value_type &&_x)
Definition: polynomial.hpp:266
polynomial operator%(const polynomial &other) const
Definition: polynomial.hpp:514
container_type::const_reference const_reference
Definition: polynomial.hpp:47
polynomial & operator=(std::initializer_list< value_type > il)
Definition: polynomial.hpp:128
const_reverse_iterator crend() const BOOST_NOEXCEPT
Definition: polynomial.hpp:200
polynomial & operator=(container_type &&x)
Definition: polynomial.hpp:123
container_type::difference_type difference_type
Definition: polynomial.hpp:49
const_iterator cbegin() const BOOST_NOEXCEPT
Definition: polynomial.hpp:188
polynomial(std::initializer_list< value_type > il)
Definition: polynomial.hpp:83
iterator insert(const_iterator _position, value_type &&_x)
Definition: polynomial.hpp:283
const_reverse_iterator rend() const BOOST_NOEXCEPT
Definition: polynomial.hpp:184
reverse_iterator rbegin() BOOST_NOEXCEPT
Definition: polynomial.hpp:172
bool empty() const BOOST_NOEXCEPT
Definition: polynomial.hpp:215
container_type::const_pointer const_pointer
Definition: polynomial.hpp:51
iterator erase(const_iterator _first, const_iterator _last)
Definition: polynomial.hpp:308
reference emplace_back(Args &&... _args)
Definition: polynomial.hpp:271
container_type::const_iterator const_iterator
Definition: polynomial.hpp:53
void reverse(std::size_t n)
Definition: polynomial.hpp:376
std::iterator_traits< InputIterator >::reference assign(InputIterator first, InputIterator last)
Definition: polynomial.hpp:141
iterator insert(const_iterator _position, const_reference _x)
Definition: polynomial.hpp:279
void shrink_to_fit() BOOST_NOEXCEPT
Definition: polynomial.hpp:224
polynomial(const polynomial &x, const allocator_type &a)
Definition: polynomial.hpp:80
container_type::value_type value_type
Definition: polynomial.hpp:44
polynomial operator*(const polynomial &other) const
Definition: polynomial.hpp:460
iterator insert(const_iterator _position, InputIterator _first, InputIterator _last)
Definition: polynomial.hpp:296
const_reverse_iterator rbegin() const BOOST_NOEXCEPT
Definition: polynomial.hpp:176
polynomial(const FieldValueType &value, std::size_t power=0)
Definition: polynomial.hpp:96
reverse_iterator rend() BOOST_NOEXCEPT
Definition: polynomial.hpp:180
container_type::pointer pointer
Definition: polynomial.hpp:50
polynomial(polynomial &&x) BOOST_NOEXCEPT(std
Definition: polynomial.hpp:89
container_type::iterator iterator
Definition: polynomial.hpp:52
value_type * data() BOOST_NOEXCEPT
Definition: polynomial.hpp:254
polynomial()
Definition: polynomial.hpp:57
container_type::size_type size_type
Definition: polynomial.hpp:48
polynomial(InputIterator first, InputIterator last)
Definition: polynomial.hpp:70
iterator insert(const_iterator _position, size_type _n, const_reference _x)
Definition: polynomial.hpp:291
const_reference back() const BOOST_NOEXCEPT
Definition: polynomial.hpp:250
bool operator!=(const polynomial &rhs) const
Definition: polynomial.hpp:136
iterator end() BOOST_NOEXCEPT
Definition: polynomial.hpp:165
void push_back(const_reference _x)
Definition: polynomial.hpp:262
void assign(size_type n, const_reference u)
Definition: polynomial.hpp:146
polynomial operator/(const polynomial &other) const
Definition: polynomial.hpp:471
iterator begin() BOOST_NOEXCEPT
Definition: polynomial.hpp:158
const_reference at(size_type _n) const
Definition: polynomial.hpp:237
polynomial(size_type n)
Definition: polynomial.hpp:60
void reserve(size_type _n)
Definition: polynomial.hpp:221
void pop_back()
Definition: polynomial.hpp:275
void clear() BOOST_NOEXCEPT
Definition: polynomial.hpp:312
iterator insert(const_iterator _position, std::initializer_list< value_type > _il)
Definition: polynomial.hpp:300
polynomial(const polynomial &x)
Definition: polynomial.hpp:78
polynomial(size_type n, const value_type &x, const allocator_type &a)
Definition: polynomial.hpp:67
reference at(size_type _n)
Definition: polynomial.hpp:234
container_type::reference reference
Definition: polynomial.hpp:46
const_reverse_iterator crbegin() const BOOST_NOEXCEPT
Definition: polynomial.hpp:196
iterator emplace(const_iterator _position, Args &&... _args)
Definition: polynomial.hpp:287
polynomial & operator=(const polynomial &x)
Definition: polynomial.hpp:108
polynomial(size_type n, const value_type &x)
Definition: polynomial.hpp:65
polynomial operator+(const polynomial &other) const
Definition: polynomial.hpp:385
polynomial(polynomial &&x, const allocator_type &a)
Definition: polynomial.hpp:93
container_type::allocator_type allocator_type
Definition: polynomial.hpp:45
const_iterator cend() const BOOST_NOEXCEPT
Definition: polynomial.hpp:192
size_type max_size() const BOOST_NOEXCEPT
Definition: polynomial.hpp:218
polynomial & operator=(polynomial &&x)
Definition: polynomial.hpp:113
bool operator==(const polynomial &rhs) const
Definition: polynomial.hpp:133
const_reference front() const BOOST_NOEXCEPT
Definition: polynomial.hpp:244
const value_type * data() const BOOST_NOEXCEPT
Definition: polynomial.hpp:258
void swap(polynomial &other)
Definition: polynomial.hpp:324
const_iterator begin() const BOOST_NOEXCEPT
Definition: polynomial.hpp:162
polynomial & operator=(const container_type &x)
Definition: polynomial.hpp:118
void resize(size_type _sz, const_reference _x)
Definition: polynomial.hpp:320
reference back() BOOST_NOEXCEPT
Definition: polynomial.hpp:247
void assign(std::initializer_list< value_type > il)
Definition: polynomial.hpp:150
polynomial operator-(const polynomial &other) const
Definition: polynomial.hpp:426
reference operator[](size_type _n) BOOST_NOEXCEPT
Definition: polynomial.hpp:228
iterator erase(const_iterator _position)
Definition: polynomial.hpp:304
bool is_zero() const
Definition: polynomial.hpp:353
size_type capacity() const BOOST_NOEXCEPT
Definition: polynomial.hpp:212
polynomial(std::initializer_list< value_type > il, const allocator_type &a)
Definition: polynomial.hpp:86
reference front() BOOST_NOEXCEPT
Definition: polynomial.hpp:241
FieldValueType evaluate(const FieldValueType &value) const
Definition: polynomial.hpp:341
size_type degree() const BOOST_NOEXCEPT
Definition: polynomial.hpp:208
allocator_type get_allocator() const BOOST_NOEXCEPT
Definition: polynomial.hpp:154
decoded_range< UnaryFunction, SinglePassRange > transform(SinglePassRange &rng, UnaryFunction fn)
Definition: decrypted.hpp:100
nil::crypto3::math::expressions::detail::parser::power_ power
void fft_multiplication(Range &c, const Range &a, const Range &b)
Definition: basic_operations.hpp:145
polynomial< FieldValueType, Allocator > operator-(const polynomial< FieldValueType, Allocator > &A, const FieldValueType &B)
Definition: polynomial.hpp:567
polynomial< FieldValueType, Allocator > operator*(const polynomial< FieldValueType, Allocator > &A, const FieldValueType &B)
Definition: polynomial.hpp:583
polynomial< FieldValueType, Allocator > operator/(const polynomial< FieldValueType, Allocator > &A, const FieldValueType &B)
Definition: polynomial.hpp:599
void reverse(Range &a, std::size_t n)
Definition: basic_operations.hpp:54
polynomial< FieldValueType, Allocator > operator+(const polynomial< FieldValueType, Allocator > &A, const FieldValueType &B)
Definition: polynomial.hpp:551
Definition: pair.hpp:31