Index Mathematics Conjectures nbv lettuce Widgets

slice_ref!

A sub-vector of a named variable, without moving the variable. Vectors

slice_ref! name, start, len

Like slice!, but the vector must be a named variable and it is only read, not moved. Use it to take several slices of one large vector without cloning the whole vector each time.

Arguments

name
A named variable, static or witness. Any other expression is an error.
start
Static scalar, the first index.
len
Static scalar, the number of elements. Unlike slice! it is required.

Returns

A vector of length len with the location of the variable. slice_ref! is an expression.

Constraints

None.

Example

(let x)
let lo = slice_ref! x, 0, 2
let hi = slice_ref! x, 2, 2
# x is still available
(sum(lo), sum(hi))

Notes

Errors if start + len exceeds the length of the variable.

Used in the standard library

polynomial/mat_poly_compose_horizontal