All problems
Dot Product of Matrix Columns
Problem
Compute the dot product of columns i and j of a matrix A.
Sum the products of paired entries down the two columns. When i = j this returns the squared norm of that column.
Hint
Walk down the rows and accumulate row[i] * row[j].
Test cases
case 1
in: [[[1,2],[3,4]],0,1]
expected: 14
case 2
in: [[[1,2],[3,4]],0,0]
expected: 10
case 3
in: [[[1,0],[1,0]],0,1]
expected: 0
case 4
in: [[[1,2],[3,4],[5,6]],0,1]
expected: 44
Starter codePython
def matrix_columns_dot(A, i, j):
# Your code here
pass4 test cases · run your code against them in the editor