Consider switching to numpy for efficient vector and matrix operations.
In [1]: import numpy as np
In [2]: %paste
y = [1,2,3,4,5,6]
## -- End pasted text --
In [3]: a = np.array(y)
In [4]: a
Out[4]: array([1, 2, 3, 4, 5, 6])
In [5]: np.dot(a, a)
Out[5]: 91
With a matrix:
In [7]: M = np.matrix(np.arange(0, 15, 0.5).reshape((6, 5)))
In [8]: M
Out[8]:
matrix([[ 0. , 0.5, 1. , 1.5, 2. ],
[ 2.5, 3. , 3.5, 4. , 4.5],
[ 5. , 5.5, 6. , 6.5, 7. ],
[ 7.5, 8. , 8.5, 9. , 9.5],
[ 10. , 10.5, 11. , 11.5, 12. ],
[ 12.5, 13. , 13.5, 14. , 14.5]])
In [9]: a * M
Out[9]: matrix([[ 175. , 185.5, 196. , 206.5, 217. ]])
or simply:
In [10]: M = np.arange(0, 15, 0.5).reshape((6, 5))
In [11]: np.dot(a, M)
Out[11]: array([ 175. , 185.5, 196. , 206.5, 217. ])