0

It seesms like we can have n dimensional array by numpy.array also numpy.matrix is exact matrix I want.

which one is generally used?

Hypnoz
  • 1,115
  • 4
  • 15
  • 27

1 Answers1

1

Objects of type numpy.array are n-dimensional, meaning they can represent 2-dimensional matrices, as well as 3D, 4D, 5D, etc.

The numpy.matrix, however, is designed specifically for the purpose of 2-dimensional matrices. As part of this specialisation, some of the operators are modified, for example * refers to matrix multiplication.

Use whichever is most sensible for your work, but make sure you remain consistent. If you'll occasionally have to deal with higher-dimensional data then it makes sense to use numpy.array all the time (you can still do matrix multiplication with 2D numpy.array, but you have to use a method as opposed to the * operator).

Ffisegydd
  • 51,807
  • 15
  • 147
  • 125