def dotProduct(x,y):
prod=0
for i in range(len(x)):
prod=prod+x[i]*y[i]
return prod
Dot product Matrices
-
30-03-2022 - |
Question
Hey so I was just wondering how to compute the the dotproduct of two matrices using a user defined function.
For example:
row(C,0)=[4, 1, 9]
col(D,0)=[2, 5, 1]
def dotProduct(x,y):
print(dotProduct(row(C,0), col(D,0)))
Should result in 22
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow