Loading...
Compute dot products and matrix multiplications.
NumPy provides several multiplication operations:
For vectors: dot product = sum of element-wise products For matrices: standard matrix multiplication
Write a function compute_products(vec1, vec2, mat) that computes various products.
Return a dictionary with:
vec1 = [1,2,3], vec2 = [4,5,6], mat = identity
{'dot': 32, 'elementwise': [4, 10, 18], 'mat_vec': [1, 2, 3], 'vec_mat': [1, 2, 3]}Dot: 14+25+36=32, elementwise: [14, 25, 36], identity matrix preserves vectors