Matrix-vector multiplication

Write codeEasy15 minNvidia style

Your task

Implement matrix-vector multiplication from scratch. Given a matrix as a list of rows (each row a list of numbers, all rows the same length) and a vector whose length equals the number of columns, return the result vector: each output entry is the dot product of the corresponding matrix row with the vector. The matrix has at least one row. Return integer values where exact (do not round).

Examples

matvec(matrix: list[list[float]], vec: list[float]) -> list[float]
Example 1
Inputmatvec([[1, 0], [0, 1]], [5, 7])
Output[5, 7]