What is the difference between matrices and arrays?
NumPy’s basic data type is the multidimensional array. These can be one-dimensional (that is, one index, like a list or a vector), two-dimensional (two indices, like an image), three-dimensional, or more (zero-dimensional arrays exist and are a slightly strange corner case). They support various operations, including addition, subtraction, multiplication, exponentiation, and so on – but all of these are elementwise operations. If you want matrix multiplication between two two-dimensional arrays, the function :func:`numpy.dot` does this. It also works fine for getting the matrix product of a two-dimensional array and a one-dimensional array, in either direction, or two one-dimensional arrays. If you want some kind of matrix multiplication-like operation on higher-dimensional arrays (tensor contraction), you need to think which indices you want to be contracting over. Some combination of :func:`tensordot` and :func:`rollaxis` should do what you want.