Here is code that defines a matrix and a vector and prints the matrixvector product.

Here is an explanation of the code:

np
. Without the
as np
you would have to prefix them with
numpy
, which requires more typing.

v[2]
.

M[i,j]
. M[i][j]
also
works.

M
with v
, where v
is interpreted
as a column vector. The resulting vector u
in this case
has five elements, because M
has five rows.
Try running the code to see the result.