What are the differences between numpy arrays and matrices? Which one should I use?

前端 未结 5 1930
野的像风
野的像风 2020-11-22 07:08

What are the advantages and disadvantages of each?

From what I\'ve seen, either one can work as a replacement for the other if need be, so should I bother using both

5条回答
  •  佛祖请我去吃肉
    2020-11-22 07:45

    Scipy.org recommends that you use arrays:

    *'array' or 'matrix'? Which should I use? - Short answer

    Use arrays.

    • They are the standard vector/matrix/tensor type of numpy. Many numpy function return arrays, not matrices.

    • There is a clear distinction between element-wise operations and linear algebra operations.

    • You can have standard vectors or row/column vectors if you like.

    The only disadvantage of using the array type is that you will have to use dot instead of * to multiply (reduce) two tensors (scalar product, matrix vector multiplication etc.).

提交回复
热议问题