Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::Polynomial< Fr > Class Template Reference

Structured polynomial class that represents the coefficients 'a' of a_0 + a_1 x ... a_n x^n of a finite field polynomial equation of degree that is at most the size of some zk circuit. Past 'n' it has a virtual size where it conceptually has coefficients all equal to 0. Notably, we allow indexing past 'n' up to our virtual size (checked only in a debug build, however). As well, we have a start index that means coefficients before start_index are also considered to be 0. The polynomial is used to represent the gates of our arithmetized zk programs. Polynomials use the majority of the memory in proving, so caution should be used in making sure unnecessary copies are avoided, both for avoiding unnecessary memory usage and performance due to unnecessary allocations. The polynomial has a maximum degree in the underlying SharedShiftedVirtualZeroesArray, dictated by the circuit size, this is just used for debugging as we represent. More...

#include <polynomial.hpp>

Public Types

enum class  DontZeroMemory { FLAG }
 
using FF = Fr
 

Public Member Functions

 Polynomial (size_t size, size_t virtual_size, size_t start_index=0)
 Initialize a Polynomial to size 'size', zeroing memory.
 
 Polynomial (size_t size)
 
 Polynomial (size_t size, size_t virtual_size, size_t start_index, DontZeroMemory flag)
 Initialize a Polynomial to size 'size'. Important: This does NOT zero memory.
 
 Polynomial (size_t size, size_t virtual_size, DontZeroMemory flag)
 
 Polynomial (size_t size, DontZeroMemory flag)
 
 Polynomial (const Polynomial &other)
 
 Polynomial (const Polynomial &other, size_t target_size)
 
 Polynomial (Polynomial &&other) noexcept=default
 
 Polynomial (std::span< const Fr > coefficients, size_t virtual_size)
 
 Polynomial (std::span< const Fr > coefficients)
 
 Polynomial ()=default
 
 Polynomial (std::span< const Fr > interpolation_points, std::span< const Fr > evaluations, size_t virtual_size)
 Create the degree-(m-1) polynomial T(X) that interpolates the given evaluations. We have T(xⱼ) = yⱼ for j=1,...,m.
 
Polynomialoperator= (Polynomial &&other) noexcept=default
 
Polynomialoperator= (const Polynomial &other)
 
 ~Polynomial ()=default
 
Polynomial share () const
 
void clear ()
 
bool is_zero () const
 Check whether or not a polynomial is identically zero.
 
bool operator== (Polynomial const &rhs) const
 
const Frget (size_t i, size_t virtual_padding=0) const
 Retrieves the value at the specified index.
 
bool is_empty () const
 
Polynomial shifted () const
 Returns a Polynomial the left-shift of self.
 
Polynomial right_shifted (const size_t magnitude) const
 Returns a Polynomial equal to the right-shift-by-magnitude of self.
 
Polynomial reverse () const
 Returns the polynomial equal to the reverse of self.
 
Fr evaluate_mle (std::span< const Fr > evaluation_points, bool shift=false) const
 evaluate multi-linear extension p(X_0,…,X_{n-1}) = \sum_i a_i*L_i(X_0,…,X_{n-1}) at u = (u_0,…,u_{n-1}) If the polynomial is embedded into a lower dimension k<n, i.e, start_index + size <= 2^k, we evaluate it in a more efficient way. Note that a_j == 0 for any j >= 2^k. We fold over k dimensions and then multiply the result by (1 - u_k) * (1 - u_{k+1}) ... * (1 - u_{n-1}). In this case, for any i < 2^k, L_i is a multiple of (1 - X_k) * (1 - X_{k+1}) ... * (1 - X_{n-1}). Dividing p by this monomial leads to a multilinear extension over variables X_0, X_1, ..X_{k-1}.
 
Fr compute_barycentric_evaluation (const Fr &z, const EvaluationDomain< Fr > &domain)
 
void factor_roots (const Fr &root)
 Divides p(X) by (X-r) in-place. Assumes that p(rⱼ)=0 for all j.
 
Fr evaluate (const Fr &z, size_t target_size) const
 
Fr evaluate (const Fr &z) const
 
void add_scaled (PolynomialSpan< const Fr > other, Fr scaling_factor) &
 adds the polynomial q(X) 'other', multiplied by a scaling factor.
 
void add_scaled_chunk (const ThreadChunk &chunk, PolynomialSpan< const Fr > other, Fr scaling_factor) &
 
Polynomialoperator+= (PolynomialSpan< const Fr > other)
 adds the polynomial q(X) 'other'.
 
Polynomialoperator-= (PolynomialSpan< const Fr > other)
 subtracts the polynomial q(X) 'other'.
 
Polynomialoperator*= (Fr scaling_factor)
 sets this = p(X) to s⋅p(X)
 
void multiply_chunk (const ThreadChunk &chunk, Fr scaling_factor)
 
void mask ()
 Add random values to the coefficients of a polynomial. In practice, this is used for ensuring the commitment and evaluation of a polynomial don't leak information about the coefficients in the context of zero knowledge.
 
std::size_t size () const
 
std::size_t virtual_size () const
 
void increase_virtual_size (const size_t size_in)
 
Frdata ()
 
const Frdata () const
 
Frat (size_t index)
 Our mutable accessor, unlike operator[]. We abuse precedent a bit to differentiate at() and operator[] as mutable and immutable, respectively. This means at() can only index within start_index()..end_index() unlike operator[] which can index 0..virtual_size.
 
const Frat (size_t index) const
 
const Froperator[] (size_t i)
 
const Froperator[] (size_t i) const
 
void shrink_end_index (const size_t new_end_index)
 The end_index of the polynomial is decreased without any memory de-allocation. This is a very fast way to zeroize the polynomial tail from new_end_index to the end. It also means that the new end_index might be smaller than the backed memory.
 
Polynomial full () const
 Copys the polynomial, but with the whole address space usable. The value of the polynomial remains the same, but defined memory region differs.
 
size_t start_index () const
 
size_t end_index () const
 
std::span< Frcoeffs (size_t offset=0)
 Strictly iterates the defined region of the polynomial. We keep this explicit, instead of having an implicit conversion to span. This is safer as it is more likely that we need to consider our start_index() along with the span, as in PolynomialSpan below.
 
std::span< const Frcoeffs (size_t offset=0) const
 
 operator PolynomialSpan< Fr > ()
 Convert to an std::span bundled with our start index.
 
 operator PolynomialSpan< const Fr > () const
 Convert to an std::span bundled with our start index.
 
auto indices () const
 
auto indexed_values ()
 
auto indexed_values () const
 
bool is_valid_set_index (size_t index) const
 Is this index valid for a set? i.e. calling poly.at(index) = value.
 
void set_if_valid_index (size_t index, const Fr &value)
 Like setting with at(), but allows zeroes to result in no set.
 
template<typename T >
void copy_vector (const std::vector< T > &vec)
 Copy over values from a vector that is of a convertible type.
 
Fr debug_hash () const
 

Static Public Member Functions

static Polynomial shiftable (size_t virtual_size)
 Utility to create a shiftable polynomial of given virtual size.
 
static Polynomial shiftable (size_t size, size_t virtual_size)
 Utility to create a shiftable polynomial of given size and virtual size.
 
static Polynomial random (size_t size, size_t start_index=0)
 
static Polynomial random (size_t size, size_t virtual_size, size_t start_index)
 
static Polynomial create_non_parallel_zero_init (size_t size, size_t virtual_size)
 A factory to construct a polynomial where parallel initialization is not possible (e.g. AVM code).
 

Private Member Functions

void allocate_backing_memory (size_t size, size_t virtual_size, size_t start_index)
 
bool in_place_operation_viable (size_t domain_size)
 

Private Attributes

SharedShiftedVirtualZeroesArray< Frcoefficients_
 

Detailed Description

template<typename Fr>
class bb::Polynomial< Fr >

Structured polynomial class that represents the coefficients 'a' of a_0 + a_1 x ... a_n x^n of a finite field polynomial equation of degree that is at most the size of some zk circuit. Past 'n' it has a virtual size where it conceptually has coefficients all equal to 0. Notably, we allow indexing past 'n' up to our virtual size (checked only in a debug build, however). As well, we have a start index that means coefficients before start_index are also considered to be 0. The polynomial is used to represent the gates of our arithmetized zk programs. Polynomials use the majority of the memory in proving, so caution should be used in making sure unnecessary copies are avoided, both for avoiding unnecessary memory usage and performance due to unnecessary allocations. The polynomial has a maximum degree in the underlying SharedShiftedVirtualZeroesArray, dictated by the circuit size, this is just used for debugging as we represent.

Template Parameters
Frthe finite field type.

Definition at line 75 of file polynomial.hpp.

Member Typedef Documentation

◆ FF

Definition at line 77 of file polynomial.hpp.

Member Enumeration Documentation

◆ DontZeroMemory

Enumerator
FLAG 

Definition at line 78 of file polynomial.hpp.

Constructor & Destructor Documentation

◆ Polynomial() [1/12]

template<typename Fr >
bb::Polynomial< Fr >::Polynomial ( size_t  size,
size_t  virtual_size,
size_t  start_index = 0 
)

Initialize a Polynomial to size 'size', zeroing memory.

Constructors / Destructors

Parameters
sizeThe size of the polynomial.

Definition at line 72 of file polynomial.cpp.

◆ Polynomial() [2/12]

template<typename Fr >
bb::Polynomial< Fr >::Polynomial ( size_t  size)
inline

Definition at line 82 of file polynomial.hpp.

◆ Polynomial() [3/12]

template<typename Fr >
bb::Polynomial< Fr >::Polynomial ( size_t  size,
size_t  virtual_size,
size_t  start_index,
DontZeroMemory  flag 
)

Initialize a Polynomial to size 'size'. Important: This does NOT zero memory.

Parameters
sizeThe initial size of the polynomial.
flagSignals that we do not zero memory.

Definition at line 97 of file polynomial.cpp.

◆ Polynomial() [4/12]

template<typename Fr >
bb::Polynomial< Fr >::Polynomial ( size_t  size,
size_t  virtual_size,
DontZeroMemory  flag 
)
inline

Definition at line 87 of file polynomial.hpp.

◆ Polynomial() [5/12]

template<typename Fr >
bb::Polynomial< Fr >::Polynomial ( size_t  size,
DontZeroMemory  flag 
)
inline

Definition at line 90 of file polynomial.hpp.

◆ Polynomial() [6/12]

template<typename Fr >
bb::Polynomial< Fr >::Polynomial ( const Polynomial< Fr > &  other)

◆ Polynomial() [7/12]

template<typename Fr >
bb::Polynomial< Fr >::Polynomial ( const Polynomial< Fr > &  other,
size_t  target_size 
)

◆ Polynomial() [8/12]

template<typename Fr >
bb::Polynomial< Fr >::Polynomial ( Polynomial< Fr > &&  other)
defaultnoexcept

◆ Polynomial() [9/12]

template<typename Fr >
bb::Polynomial< Fr >::Polynomial ( std::span< const Fr coefficients,
size_t  virtual_size 
)

Definition at line 127 of file polynomial.cpp.

◆ Polynomial() [10/12]

template<typename Fr >
bb::Polynomial< Fr >::Polynomial ( std::span< const Fr coefficients)
inline

Definition at line 100 of file polynomial.hpp.

◆ Polynomial() [11/12]

template<typename Fr >
bb::Polynomial< Fr >::Polynomial ( )
default

◆ Polynomial() [12/12]

template<typename Fr >
bb::Polynomial< Fr >::Polynomial ( std::span< const Fr interpolation_points,
std::span< const Fr evaluations,
size_t  virtual_size 
)

Create the degree-(m-1) polynomial T(X) that interpolates the given evaluations. We have T(xⱼ) = yⱼ for j=1,...,m.

Parameters
interpolation_points(x₁,…,xₘ)
evaluations(y₁,…,yₘ)

Definition at line 116 of file polynomial.cpp.

◆ ~Polynomial()

template<typename Fr >
bb::Polynomial< Fr >::~Polynomial ( )
default

Member Function Documentation

◆ add_scaled()

template<typename Fr >
void bb::Polynomial< Fr >::add_scaled ( PolynomialSpan< const Fr other,
Fr  scaling_factor 
) &

adds the polynomial q(X) 'other', multiplied by a scaling factor.

Parameters
otherq(X)
scaling_factorscaling factor by which all coefficients of q(X) are multiplied

Definition at line 258 of file polynomial.cpp.

◆ add_scaled_chunk()

template<typename Fr >
void bb::Polynomial< Fr >::add_scaled_chunk ( const ThreadChunk chunk,
PolynomialSpan< const Fr other,
Fr  scaling_factor 
) &

Definition at line 267 of file polynomial.cpp.

◆ allocate_backing_memory()

template<typename Fr >
void bb::Polynomial< Fr >::allocate_backing_memory ( size_t  size,
size_t  virtual_size,
size_t  start_index 
)
private

Definition at line 51 of file polynomial.cpp.

◆ at() [1/2]

template<typename Fr >
Fr & bb::Polynomial< Fr >::at ( size_t  index)
inline

Our mutable accessor, unlike operator[]. We abuse precedent a bit to differentiate at() and operator[] as mutable and immutable, respectively. This means at() can only index within start_index()..end_index() unlike operator[] which can index 0..virtual_size.

Parameters
indexthe index, to be subtracted by start_index() and read into the array memory
Returns
Fr& a mutable reference.

Definition at line 293 of file polynomial.hpp.

◆ at() [2/2]

template<typename Fr >
const Fr & bb::Polynomial< Fr >::at ( size_t  index) const
inline

Definition at line 294 of file polynomial.hpp.

◆ clear()

template<typename Fr >
void bb::Polynomial< Fr >::clear ( )
inline

Definition at line 140 of file polynomial.hpp.

◆ coeffs() [1/2]

template<typename Fr >
std::span< Fr > bb::Polynomial< Fr >::coeffs ( size_t  offset = 0)
inline

Strictly iterates the defined region of the polynomial. We keep this explicit, instead of having an implicit conversion to span. This is safer as it is more likely that we need to consider our start_index() along with the span, as in PolynomialSpan below.

Returns
std::span<Fr> a span covering start_index() to end_index()

Definition at line 351 of file polynomial.hpp.

◆ coeffs() [2/2]

template<typename Fr >
std::span< const Fr > bb::Polynomial< Fr >::coeffs ( size_t  offset = 0) const
inline

Definition at line 352 of file polynomial.hpp.

◆ compute_barycentric_evaluation()

template<typename Fr >
requires polynomial_arithmetic::SupportsFFT<Fr>
Fr bb::Polynomial< Fr >::compute_barycentric_evaluation ( const Fr z,
const EvaluationDomain< Fr > &  domain 
)

Definition at line 205 of file polynomial.cpp.

◆ copy_vector()

template<typename Fr >
template<typename T >
void bb::Polynomial< Fr >::copy_vector ( const std::vector< T > &  vec)
inline

Copy over values from a vector that is of a convertible type.

There is an underlying assumption that the relevant start index in the vector corresponds to the start_index of the destination polynomial and also that the number of elements we want to copy corresponds to the size of the polynomial. This is quirky behavior and we might want to improve the UX.

Todo:
https://github.com/AztecProtocol/barretenberg/issues/1292
Template Parameters
Ta convertible type
Parameters
vecthe vector

Definition at line 395 of file polynomial.hpp.

◆ create_non_parallel_zero_init()

template<typename Fr >
Polynomial< Fr > bb::Polynomial< Fr >::create_non_parallel_zero_init ( size_t  size,
size_t  virtual_size 
)
static

A factory to construct a polynomial where parallel initialization is not possible (e.g. AVM code).

Returns
a polynomial initialized with zero on the range defined by size

Definition at line 237 of file polynomial.cpp.

◆ data() [1/2]

template<typename Fr >
Fr * bb::Polynomial< Fr >::data ( )
inline

Definition at line 282 of file polynomial.hpp.

◆ data() [2/2]

template<typename Fr >
const Fr * bb::Polynomial< Fr >::data ( ) const
inline

Definition at line 283 of file polynomial.hpp.

◆ debug_hash()

template<typename Fr >
Fr bb::Polynomial< Fr >::debug_hash ( ) const
inline

Definition at line 407 of file polynomial.hpp.

◆ end_index()

template<typename Fr >
size_t bb::Polynomial< Fr >::end_index ( ) const
inline

Definition at line 341 of file polynomial.hpp.

◆ evaluate() [1/2]

template<typename Fr >
Fr bb::Polynomial< Fr >::evaluate ( const Fr z) const

Definition at line 193 of file polynomial.cpp.

◆ evaluate() [2/2]

template<typename Fr >
Fr bb::Polynomial< Fr >::evaluate ( const Fr z,
size_t  target_size 
) const

Definition at line 187 of file polynomial.cpp.

◆ evaluate_mle()

template<typename Fr >
Fr bb::Polynomial< Fr >::evaluate_mle ( std::span< const Fr evaluation_points,
bool  shift = false 
) const

evaluate multi-linear extension p(X_0,…,X_{n-1}) = \sum_i a_i*L_i(X_0,…,X_{n-1}) at u = (u_0,…,u_{n-1}) If the polynomial is embedded into a lower dimension k<n, i.e, start_index + size <= 2^k, we evaluate it in a more efficient way. Note that a_j == 0 for any j >= 2^k. We fold over k dimensions and then multiply the result by (1 - u_k) * (1 - u_{k+1}) ... * (1 - u_{n-1}). In this case, for any i < 2^k, L_i is a multiple of (1 - X_k) * (1 - X_{k+1}) ... * (1 - X_{n-1}). Dividing p by this monomial leads to a multilinear extension over variables X_0, X_1, ..X_{k-1}.

this function allocates a temporary buffer of size 2^(k-1)

Parameters
evaluation_pointsevaluation vector of size n
shifta boolean and when set to true, we evaluate the shifted counterpart polynomial: enforce a_0 == 0 and compute \sum_i a_{i+1}*L_i(X_0,…,X_{n-1})

Definition at line 199 of file polynomial.cpp.

◆ factor_roots()

template<typename Fr >
void bb::Polynomial< Fr >::factor_roots ( const Fr root)
inline

Divides p(X) by (X-r) in-place. Assumes that p(rⱼ)=0 for all j.

we specialize the method when only a single root is given. if one of the roots is 0, then we first factor all other roots. dividing by X requires only a left shift of all coefficient.

Parameters
roota single root r

Definition at line 224 of file polynomial.hpp.

◆ full()

template<typename Fr >
Polynomial< Fr > bb::Polynomial< Fr >::full ( ) const

Copys the polynomial, but with the whole address space usable. The value of the polynomial remains the same, but defined memory region differs.

Returns
a polynomial with a larger size() but same virtual_size()

Definition at line 250 of file polynomial.cpp.

◆ get()

template<typename Fr >
const Fr & bb::Polynomial< Fr >::get ( size_t  i,
size_t  virtual_padding = 0 
) const
inline

Retrieves the value at the specified index.

Parameters
indexThe index from which to retrieve the value.
virtual_paddingFor the rare case where we explicitly want the 0-returning behavior beyond our usual virtual_size.

Definition at line 168 of file polynomial.hpp.

◆ in_place_operation_viable()

template<typename Fr >
bool bb::Polynomial< Fr >::in_place_operation_viable ( size_t  domain_size)
inlineprivate

Definition at line 422 of file polynomial.hpp.

◆ increase_virtual_size()

template<typename Fr >
void bb::Polynomial< Fr >::increase_virtual_size ( const size_t  size_in)
inline

Definition at line 280 of file polynomial.hpp.

◆ indexed_values() [1/2]

template<typename Fr >
auto bb::Polynomial< Fr >::indexed_values ( )
inline

Definition at line 366 of file polynomial.hpp.

◆ indexed_values() [2/2]

template<typename Fr >
auto bb::Polynomial< Fr >::indexed_values ( ) const
inline

Definition at line 367 of file polynomial.hpp.

◆ indices()

template<typename Fr >
auto bb::Polynomial< Fr >::indices ( ) const
inline

Definition at line 365 of file polynomial.hpp.

◆ is_empty()

template<typename Fr >
bool bb::Polynomial< Fr >::is_empty ( ) const
inline

Definition at line 170 of file polynomial.hpp.

◆ is_valid_set_index()

template<typename Fr >
bool bb::Polynomial< Fr >::is_valid_set_index ( size_t  index) const
inline

Is this index valid for a set? i.e. calling poly.at(index) = value.

Definition at line 371 of file polynomial.hpp.

◆ is_zero()

template<typename Fr >
bool bb::Polynomial< Fr >::is_zero ( ) const
inline

Check whether or not a polynomial is identically zero.

Definition at line 146 of file polynomial.hpp.

◆ mask()

template<typename Fr >
void bb::Polynomial< Fr >::mask ( )
inline

Add random values to the coefficients of a polynomial. In practice, this is used for ensuring the commitment and evaluation of a polynomial don't leak information about the coefficients in the context of zero knowledge.

Definition at line 267 of file polynomial.hpp.

◆ multiply_chunk()

template<typename Fr >
void bb::Polynomial< Fr >::multiply_chunk ( const ThreadChunk chunk,
Fr  scaling_factor 
)

Definition at line 230 of file polynomial.cpp.

◆ operator PolynomialSpan< const Fr >()

template<typename Fr >
bb::Polynomial< Fr >::operator PolynomialSpan< const Fr > ( ) const
inline

Convert to an std::span bundled with our start index.

Returns
PolynomialSpan<Fr> A span covering the entire polynomial.

Definition at line 363 of file polynomial.hpp.

◆ operator PolynomialSpan< Fr >()

template<typename Fr >
bb::Polynomial< Fr >::operator PolynomialSpan< Fr > ( )
inline

Convert to an std::span bundled with our start index.

Returns
PolynomialSpan<Fr> A span covering the entire polynomial.

Definition at line 357 of file polynomial.hpp.

◆ operator*=()

template<typename Fr >
Polynomial< Fr > & bb::Polynomial< Fr >::operator*= ( Fr  scaling_factor)

sets this = p(X) to s⋅p(X)

Parameters
scaling_factors

Definition at line 224 of file polynomial.cpp.

◆ operator+=()

adds the polynomial q(X) 'other'.

Parameters
otherq(X)

Definition at line 174 of file polynomial.cpp.

◆ operator-=()

subtracts the polynomial q(X) 'other'.

Parameters
otherq(X)

Definition at line 211 of file polynomial.cpp.

◆ operator=() [1/2]

template<typename Fr >
Polynomial & bb::Polynomial< Fr >::operator= ( const Polynomial< Fr > &  other)

◆ operator=() [2/2]

template<typename Fr >
Polynomial & bb::Polynomial< Fr >::operator= ( Polynomial< Fr > &&  other)
defaultnoexcept

◆ operator==()

template<typename Fr >
bool bb::Polynomial< Fr >::operator== ( Polynomial< Fr > const rhs) const

Definition at line 153 of file polynomial.cpp.

◆ operator[]() [1/2]

template<typename Fr >
const Fr & bb::Polynomial< Fr >::operator[] ( size_t  i)
inline

Definition at line 296 of file polynomial.hpp.

◆ operator[]() [2/2]

template<typename Fr >
const Fr & bb::Polynomial< Fr >::operator[] ( size_t  i) const
inline

Definition at line 297 of file polynomial.hpp.

◆ random() [1/2]

template<typename Fr >
static Polynomial bb::Polynomial< Fr >::random ( size_t  size,
size_t  start_index = 0 
)
inlinestatic

Definition at line 299 of file polynomial.hpp.

◆ random() [2/2]

template<typename Fr >
static Polynomial bb::Polynomial< Fr >::random ( size_t  size,
size_t  virtual_size,
size_t  start_index 
)
inlinestatic

Definition at line 306 of file polynomial.hpp.

◆ reverse()

template<typename Fr >
Polynomial< Fr > bb::Polynomial< Fr >::reverse ( ) const

Returns the polynomial equal to the reverse of self.

If the coefficients of self are \((a_0, \dots, a_n)\), we return the polynomial with coefficients \((a_n, \dots, a_0)\)

Note
Resulting polynomial uses new backing memory; n = self->size()

Definition at line 297 of file polynomial.cpp.

◆ right_shifted()

template<typename Fr >
Polynomial< Fr > bb::Polynomial< Fr >::right_shifted ( const size_t  magnitude) const

Returns a Polynomial equal to the right-shift-by-magnitude of self.

Note
Resulting Polynomial shares the memory of that used to generate it

Definition at line 286 of file polynomial.cpp.

◆ set_if_valid_index()

template<typename Fr >
void bb::Polynomial< Fr >::set_if_valid_index ( size_t  index,
const Fr value 
)
inline

Like setting with at(), but allows zeroes to result in no set.

Definition at line 375 of file polynomial.hpp.

◆ share()

template<typename Fr >
Polynomial< Fr > bb::Polynomial< Fr >::share ( ) const

Return a shallow clone of the polynomial. i.e. underlying memory is shared.

Definition at line 146 of file polynomial.cpp.

◆ shiftable() [1/2]

template<typename Fr >
static Polynomial bb::Polynomial< Fr >::shiftable ( size_t  size,
size_t  virtual_size 
)
inlinestatic

Utility to create a shiftable polynomial of given size and virtual size.

Definition at line 114 of file polynomial.hpp.

◆ shiftable() [2/2]

template<typename Fr >
static Polynomial bb::Polynomial< Fr >::shiftable ( size_t  virtual_size)
inlinestatic

Utility to create a shiftable polynomial of given virtual size.

Definition at line 107 of file polynomial.hpp.

◆ shifted()

template<typename Fr >
Polynomial< Fr > bb::Polynomial< Fr >::shifted ( ) const

Returns a Polynomial the left-shift of self.

If the n coefficients of self are (0, a₁, …, aₙ₋₁), we returns the view of the n-1 coefficients (a₁, …, aₙ₋₁).

Definition at line 276 of file polynomial.cpp.

◆ shrink_end_index()

template<typename Fr >
void bb::Polynomial< Fr >::shrink_end_index ( const size_t  new_end_index)

The end_index of the polynomial is decreased without any memory de-allocation. This is a very fast way to zeroize the polynomial tail from new_end_index to the end. It also means that the new end_index might be smaller than the backed memory.

Definition at line 244 of file polynomial.cpp.

◆ size()

template<typename Fr >
std::size_t bb::Polynomial< Fr >::size ( ) const
inline

Definition at line 278 of file polynomial.hpp.

◆ start_index()

template<typename Fr >
size_t bb::Polynomial< Fr >::start_index ( ) const
inline

Definition at line 340 of file polynomial.hpp.

◆ virtual_size()

template<typename Fr >
std::size_t bb::Polynomial< Fr >::virtual_size ( ) const
inline

Definition at line 279 of file polynomial.hpp.

Member Data Documentation

◆ coefficients_

template<typename Fr >
SharedShiftedVirtualZeroesArray<Fr> bb::Polynomial< Fr >::coefficients_
private

Definition at line 426 of file polynomial.hpp.


The documentation for this class was generated from the following files: