pub fn add_fixed_fv_unchecked
[
N : Nat
]
( x : Fixed[N, $post, @prover] $pre @public,
xv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Vectorization
Adding a scalar to all elements of a fixed-point vector.
pub fn add_fv
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Adding two fixed-point vectors elementwise, checked, very slow.
pub fn add_fv_exact
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Vectorization
Adding two fixed-point vectors elementwise, increases the
lenby1to guarantee fitting, very fast.
pub fn add_fv_unchecked
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Vectorization
Adding two fixed-point vectors elementwise, unchecked, very fast.
pub fn add_prefixed_fv_unchecked
[
N : Nat
]
( x : Fixed[N, $pre, @public] $pre @public,
xv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Adding a constant to all elements of a fixed-point vector.
pub fn check_fv
[
N : Nat
]
( xv : FixedVec[N] $pre @public
)
-> () $pre @public
where
Field[N],
Vectorization
Checking that each element of a fixed-point vector fits in
lenbits. The same aschecked_fvbut without returning the input vector.
pub fn checked_fv
[
N : Nat
]
( xv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Returning the same fixed-point vector after checking that each element fits in
lenbits. Can be applied to the result of functions with the suffix_uncheckedto make them safe. Sometimes it is possible to make several_uncheckedoperations in a row before calling the expensivechecked_fv, as long as the intermediate results do not overflow the modulus (but they do not have to fit intolenbits). For example, three fixed-point vectors can be added together bychecked_fv(add_fv_unchecked(xs, add_fv_unchecked(ys, zs))), callingchecked_fvonly once rather than twice. This is safe if3*(2^len - 1) < N.
pub fn decrease_len_fv_unchecked
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
new_len : uint[18446744073709551616] $pre @public
)
-> FixedVec[N] $pre @public
Decreasing the
lenof each element of a fixed-point vector without checking for fitting into the newlenbits.
pub fn div_fixed_fv
[
N : Nat
]
( x : Fixed[N, $post, @prover] $pre @public,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Dividing a scalar by each element of a fixed-point vector.
pub fn div_fv
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Dividing two fixed-point vectors elementwise.
pub fn empty_fv
[
N : Nat
]
()
-> FixedVec[N] $pre @public
where
Vectorization
An empty fixed-point vector.
pub fn fv_checked
[
N : Nat
]
( coefs : arr[uint[N] $post @prover] $pre @public,
len : uint[18446744073709551616] $pre @public,
pplen : uint[18446744073709551616] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Creating a fixed-point vector, checking for fitting in
lenbits.
pub fn fv_unchecked
[
N : Nat
]
( coefs : arr[uint[N] $post @prover] $pre @public,
len : uint[18446744073709551616] $pre @public,
pplen : uint[18446744073709551616] $pre @public
)
-> FixedVec[N] $pre @public
Creating a fixed-point vector without checking for fitting in
lenbits.
pub fn ge_fv_fixed
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
y : Fixed[N, $post, @prover] $pre @public
)
-> arr[uint[N] $post @prover] $pre @public
where
Field[N],
Vectorization
Comparing each element of the input fixed-point vector
xvwith a scalary. Returns a fixed-point vector with the same number of elements asxv, with theith element being1ifxv[i] >= yand0otherwise.
pub fn increase_pplen_fv
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
new_pplen : uint[18446744073709551616] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Increasing
pplenof each element of a fixed-point vector to a given value and increasing thelento keeplen - pplenthe same as before.
pub fn le_fv_fixed
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
y : Fixed[N, $post, @prover] $pre @public
)
-> arr[uint[N] $post @prover] $pre @public
where
Field[N],
Vectorization
Comparing each element of the input fixed-point vector
xvwith a scalary. Returns a fixed-point vector with the same number of elements asxv, with theith element being1ifxv[i] <= yand0otherwise.
pub fn make_unknown_fv
[
N : Nat
]
( xv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
Removing values from the wire range corresponding to the fixed-point vector, to make circuit generation faster if the values are no longer needed in
$pre.
pub fn max_fixed_fv
[
N : Nat
]
( x : Fixed[N, $post, @prover] $pre @public,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
The ith element of the output is the maximum of the scalar and the ith element of the input fixed-point vector.
pub fn max_fv
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Elementwise maximum of two fixed-point vectors.
pub fn min_fixed_fv
[
N : Nat
]
( x : Fixed[N, $post, @prover] $pre @public,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
The ith element of the output is the minimum of the scalar and the ith element of the input fixed-point vector.
pub fn min_fv
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Elementwise minimum of two fixed-point vectors.
pub fn mul_fixed_fv_exact
[
N : Nat
]
( x : Fixed[N, $post, @prover] $pre @public,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Vectorization
Multiplying all elements of a fixed-point vector by a scalar, no rounding, fast, the
lenandpplenof the result are the sum of thelenandpplenof the arguments, respectively.
pub fn mul_fixed_uv_unchecked
[
N : Nat
]
( x : Fixed[N, $post, @prover] $pre @public,
xs : arr[uint[N] $post @prover] $pre @public
)
-> FixedVec[N] $pre @public
where
Vectorization
Multiplying all elements of an integer vector by a fixed-point scalar, unchecked, fast.
pub fn mul_fv
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Multiplying two fixed-point vectors elementwise, rounding, slow.
pub fn mul_fv_exact
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Vectorization
Multiplying two fixed-point vectors elementwise, no rounding, fast, the
lenandpplenof the result are the sum of thelenandpplenof the arguments, respectively.
pub fn mul_prefixed_fv_exact
[
N : Nat
]
( x : Fixed[N, $pre, @public] $pre @public,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Multiplying all elements of a fixed-point vector by a constant, no rounding, fast, the
lenandpplenof the result are the sum of thelenandpplenof the arguments, respectively.
pub fn mul_uint_fv_unchecked
[
N : Nat
]
( x : uint[N] $post @prover,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Vectorization
Multiplying all elements of a fixed-point vector by an integer scalar, unchecked, fast.
pub fn mul_uv_fv_unchecked
[
N : Nat
]
( xs : arr[uint[N] $post @prover] $pre @public,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Vectorization
Multiplying an integer vector and a fixed-point vector elementwise, unchecked, fast.
pub fn negate_fv
[
N : Nat
]
( xv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Negating (multiplying by
-1) the elements of a fixed-point vector.
pub fn round_down_fv
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
new_len : uint[18446744073709551616] $pre @public,
new_pplen : uint[18446744073709551616] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Decreasing the
pplenof each element of a fixed-point vector by rounding down (towards minus infinity) some of the final bits.
pub fn round_down_fv_to_half
[
N : Nat
]
( xv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Rounding down half of the bits after the point of each element of a fixed-point vector, can be used after
mul_fv_exactto get back to the originallenandpplen.
pub fn round_down_fv_to_int
[
N : Nat
]
( xv : FixedVec[N] $pre @public
)
-> arr[uint[N] $post @prover] $pre @public
where
Field[N],
Vectorization
Rounding each element of a fixed-point vector down to an integer (taking the floor of each element).
pub fn round_down_fv_unchecked
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
new_len : uint[18446744073709551616] $pre @public,
new_pplen : uint[18446744073709551616] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Unchecked version of round_down_fv, about twice as fast.
pub fn scalar_prod_uv_fv_unchecked
[
N : Nat
]
( xs : arr[uint[N] $post @prover] $pre @public,
yv : FixedVec[N] $pre @public
)
-> Fixed[N, $post, @prover] $pre @public
where
Vectorization
The scalar product (dot product) of an integer vector and a fixed-point vector, unchecked.
pub fn slice_fv
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
i1 : uint[18446744073709551616] $pre @public,
i2 : uint[18446744073709551616] $pre @public
)
-> FixedVec[N] $pre @public
A slice of another fixed-point vector, including elements with indices from
i1(inclusive) toi2(exclusive).
pub fn sqrt_fv
[
N : Nat
]
( xv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Taking a square root of all elements of a fixed-point vector.
pub fn sub_fv
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Subtracting two fixed-point vectors elementwise, checked, very slow.
pub fn sub_fv_unchecked
[
N : Nat
]
( xv : FixedVec[N] $pre @public,
yv : FixedVec[N] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Subtracting two fixed-point vectors elementwise, unchecked, very fast.
pub fn sum_fv_unchecked
[
N : Nat
]
( xv : FixedVec[N] $pre @public
)
-> Fixed[N, $post, @prover] $pre @public
where
Vectorization
The sum of the elements of a fixed-point vector, unchecked.
pub fn thaw_fv
[
N : Nat
]
( xv : FixedVec[N] $pre @public
)
-> list[Fixed[N, $post, @prover] $pre @public] $pre @public
Converting a fixed-point vector to a list of fixed-point scalars.
pub fn uv_to_fv_unchecked
[
N : Nat
]
( xs : arr[uint[N] $post @prover] $pre @public,
len : uint[18446744073709551616] $pre @public,
pplen : uint[18446744073709551616] $pre @public
)
-> FixedVec[N] $pre @public
where
Field[N],
Vectorization
Converting an integer vector into a fixed-point vector, unchecked.