Skip to content
All library documents

NumPy Matrix Objects: Construction, Operations, and Array Differences

Article FMZ forum · Author: 发明者量化-小小梦

Summary

This translated reference explains NumPy’s matrix subclass and how its behavior differs from the general ndarray type. It describes matrix construction from strings, nested sequences, and arrays, along with helper functions for creating or combining matrices. Examples illustrate matrix multiplication, transposition, and building a block matrix.

The key practical point is that matrices remain two-dimensional, and their multiplication and power operators perform matrix operations rather than elementwise array operations. The note also lists convenience attributes for transpose, conjugate transpose, inverse, and access to the underlying two-dimensional array. These distinctions matter when mixing matrix and ndarray objects, since operations may return a matrix unexpectedly. The document is a brief, translated API overview with illustrative examples; it does not discuss trading applications, performance comparisons, or numerical stability, so it is best treated as a basic reference rather than guidance for quantitative analysis.

Key ideas

  • NumPy matrix objects inherit ndarray behavior but remain two-dimensional.
  • Matrix multiplication and powers use linear algebra semantics rather than elementwise operations.
  • Matrix objects can be constructed from strings, nested sequences, or arrays.
  • Convenience attributes expose transpose, conjugate transpose, inverse, and underlying array data.
  • Mixing matrix and ndarray objects can produce matrix results, so return types should be checked.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.