NLA-lib Explorer

Worked instance: a dense matrix-vector product

Library · Source module

Worked instance: a dense matrix-vector product

The scalar routine of the dense stored operator (NLAlib.Ops.StoredDense.implRoutine), which streams each row of a matrix stored column by column through a loop of products, run with exact real arithmetic on \mathbf{A} = \begin{pmatri\mathbf{x}} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatri\mathbf{x}}, \qquad \mathbf{x} = (1, 1, 2). It exercises the indexing of a matrix in a flat buffer (entry (i, j) at cell j m + i), a routine run inside a loop, and an allocation.

Expected, from scripts/worked_instances.py (Matvec): the stored words [1, 4, 2, 5, 3, 6], the output [9, 21], 2 literal zeros, 6 multiplications and 6 additions, and one scratch cell. The total of 260 instructions and the formula 33 m n + 23 m + 16 are regression values.

Main definitions

* NLAlib.Ops.Examples.WorkedInstances.Matvec.domain: a matrix and a vector, each in its buffer, and a blank buffer for the product.

Main results

* NLAlib.Ops.Examples.WorkedInstances.Matvec.run: at every size, the product is written. * NLAlib.Ops.Examples.WorkedInstances.Matvec.calls, NLAlib.Ops.Examples.WorkedInstances.Matvec.work, NLAlib.Ops.Examples.WorkedInstances.Matvec.peak: the calls, the instructions and the scratch of the tree at every size. * NLAlib.Ops.Examples.WorkedInstances.Matvec.memory_instance, NLAlib.Ops.Examples.WorkedInstances.Matvec.instance_run: the initial memory and the run on the instance.

Declarations