math4610

Routine Name: MatrixVectorMultiply

Author: David Merkley

Language: Python

Description/Purpose: Performs matrix vector multiplication

Input: an m x n matrix, an n x 1 vector

Output: The product of the multiplication

Implementation/Code:

def matrixVectorMultiply(A, b):
    n = len(b)
    ans = [0] * n
    for i in range(n):
        for j in range(n):
            ans[i] += A[i][j] * b[j]
    return ans