11.1: Dot Product Review
( \newcommand{\kernel}{\mathrm{null}\,}\)
We covered inner products a while ago. This assignment will extend the idea of inner products to matrix multiplication. As a reminder, Sections 1.4 of the Stephen Boyd and Lieven Vandenberghe Applied Linear algebra book covers the dot product. Here is a quick review:
Given two vectors u and v in Rn (i.e. they have the same length), the “dot” product operation multiplies all of the corresponding elements and then adds them together. Ex:
u=[u1,u2,…,un]
v=[v1,v2,…,vn]
u⋅v=u1v1+u2v2+⋯+unvn
or:
u⋅v=n∑i=1uivi
This can easily be written as python code as follows:
In numpy
the dot product between two vectors can be calculated using the following built in function:
What is the dot product of any vector and the zero vector?
What happens to the numpy.dot
function if the two input vectors are not the same size?