alexa
Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry

How to dot product 1D and 2D lists in python without using NumPy or .dot in python ?

How to dot product 1D and 2D lists in python without using NumPy or .dot in python ?

If you do not mind using numpy, this is a solution

 import numpy as np

matrix_A = [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23], [24, 25, 26, 27], [28, 29, 30, 31]]
vector_x = [0, 1, 2, 3]

res = np.sum(np.array(matrix_A) * np.array(vector_x), axis=1)
print(res)

86 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online