Documentation
¶
Overview ¶
vector offers a set of utility function relating to slices of field element and that are commonly used as part of the repo.
Index ¶
- func Add(res, a, b []field.Element, extras ...[]field.Element)
- func DeepCopy(pol []field.Element) []field.Element
- func Equal(a, b []field.Element) bool
- func Fill(v []field.Element, val field.Element)
- func ForTest(xs ...int) []field.Element
- func Interleave(vecs ...[]field.Element) []field.Element
- func IntoGnarkAssignment(msgData []field.Element) []frontend.Variable
- func MulElementWise(res, a, b []field.Element)
- func PowerVec(x field.Element, n int) []field.Element
- func Prettify(a []field.Element) string
- func PseudoRand(rng *rand.Rand, size int) []field.Element
- func Rand(n int) []field.Element
- func Repeat(x field.Element, n int) []field.Element
- func Reverse(v []field.Element)
- func ScalarMul(res, vec []field.Element, scalar field.Element)
- func ScalarProd(a, b []field.Element) field.Element
- func Sub(res, a, b []field.Element)
- func ZeroPad(v []field.Element, newLen int) []field.Element
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
Add adds two vectors `a` and `b` and put the result in `res` `res` must be pre-allocated by the caller and res, a and b must all have the same size. res == a or res == b or both is valid assignment.
func Equal ¶
Equal compares a and b and returns a boolean indicating whether they contain the same value. The function assumes that a and b have the same length. It panics otherwise.
func Interleave ¶
Interleave interleave two vectors:
(a, a, a, a), (b, b, b, b) -> (a, b, a, b, a, b, a, b)
The vecs[i] vectors must all have the same length
func IntoGnarkAssignment ¶
IntoGnarkAssignment converts an array of field.Element into an array of frontend.Variable that can be used to assign a vector of frontend.Variable in a circuit or to generate a vector of constant in the circuit definition.
func MulElementWise ¶
MulElementWise multiplies two vectors element wise and write the result in res. res = a is a valid assignment.
func PowerVec ¶
PowerVec allocates and returns a vector of size n consisting of consecutive powers of x, starting from x^0 = 1 and ending on x^{n-1}. The function panics if given x=0 and returns an empty vector if n=0.
func PseudoRand ¶
PseudoRand generates a vector of field element with a given size using the provided random number generator
func ScalarMul ¶
ScalarMul multiplies a vector by a scalar - in place. The result should be preallocated or it is going to panic. res = vec is a valid parameter assignment.
func ScalarProd ¶
ScalarProd returns the scalar (inner) product of a and b. The function panics if a and b do not have the same size. If they have both empty vectors, the function returns 0.
func Sub ¶
Sub substracts two vectors `a` and `b` and put the result in `res` `res` must be pre-allocated by the caller and res, a and b must all have the same size. res == a or res == b or both is valid assignment.
Types ¶
This section is empty.