+def inner_product(vec1, vec2):
+ """
+ Compute the Euclidean inner product of two vectors.
+
+ Parameters
+ ----------
+
+ vec1, vec2 : matrix
+ The two vectors whose inner product you want.
+
+ Returns
+ -------
+ float
+ The inner product of ``vec1`` and ``vec2``.
+
+ Examples
+ --------
+
+ >>> x = [1,2,3]
+ >>> y = [3,4,1]
+ >>> inner_product(x,y)
+ 14
+
+ >>> x = matrix([1,1,1])
+ >>> y = matrix([2,3,4], (1,3))
+ >>> inner_product(x,y)
+ 9
+
+ >>> x = [1,2,3]
+ >>> y = [1,1]
+ >>> inner_product(x,y)
+ Traceback (most recent call last):
+ ...
+ TypeError: the lengths of vec1 and vec2 must match
+
+ """
+ if not len(vec1) == len(vec2):
+ raise TypeError('the lengths of vec1 and vec2 must match')
+
+ return sum([x*y for (x, y) in zip(vec1, vec2)])
+
+