Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is the difference between matrices and arrays?

arrays difference matrices
0
Posted

What is the difference between matrices and arrays?

0

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.

Related Questions

Thanksgiving questions

*Sadly, we had to bring back ads too. Hopefully more targeted.