Function fold_rows

Source
pub fn fold_rows<F, DataMat, DataVec>(
    mat: &FieldBuffer<F, DataMat>,
    vec: &FieldBuffer<F, DataVec>,
) -> Result<FieldBuffer<F>, Error>
where F: Field, DataMat: Deref<Target = [F]>, DataVec: Deref<Target = [F]>,
Expand description

Computes a linear combination of the rows of a matrix.

A row-combination of a matrix is a vector-matrix multiplication.

This implementation is a naive, single-threaded implementation operating on buffers of scalar elements.

§Mathematical Definition

This operation accepts

  • $n \in \mathbb{N}$ (vec.len()),
  • $m \in \mathbb{N}$ (out.len()),
  • $M \in K^{n \times m}$ (mat),
  • $v \in K^m$ (vec),

and computes the vector $v^\top M^\top$.

§Args

  • mat - a buffer of n * m F elements, interpreted as a row-major matrix.
  • vec - a buffer of n F elements containing the row scalars.

§Returns

The vector-matrix product, as a buffer of F elements.

§Throws

  • Returns an error if mat.len() does not equal vec.len() * out.len().
  • Returns an error if mat is not a subfield of F.