A Matrix–Vector Product by Row Dot Products
Each output component of a matrix–vector product combines one input row with the vector through matching positions.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a small multiplication
Rows \((2,1)\) and \((0,3)\) applied to \((4,5)\) give \(2\cdot4+1\cdot5=13\) and \(0\cdot4+3\cdot5=15\). Row and column indices identify the pairing.
Check shape and missing entries
The vector length must match the column count. A sparse matrix can omit known zeros while retaining its declared shape. See sparse layout.[1][2]
Match each row to one output coordinate
Multiply the two-row matrix with rows [1,3,-2] and [4,0,5] by vector [2,1,3]. The first output is \(2+3-6=-1\). The second is \(8+0+15=23\). See parallel work by rows.
Input vector length: 3
Row zero dot: -1
Row one dot: 23
Result shape: length 2
Test non-square and zero-row shapes
A square matrix can conceal a transpose error. A row of zeros should yield zero independent of other rows. Verify dimension matching before using a flattened or sparse representation. An input with a fourth coordinate violates the three-column contract even if the extra coordinate happens to be zero.