{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {},
  "_ordered_sections": [],
  "item_file": null,
  "item_line": null,
  "item_type": null,
  "aliases": [],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": null,
  "references": null,
  "qa": "reference:routines.linalg",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Target",
          "__tag": 4061,
          "label": "routines.linalg"
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The NumPy linear algebra functions rely on BLAS and LAPACK to provide efficient low level implementations of standard linear algebra algorithms. Those libraries may be provided by NumPy itself using C versions of a subset of their reference implementations but, when possible, highly optimized libraries that take advantage of specialized processor functionality are preferred. Examples of such libraries are "
            },
            {
              "__type": "Link",
              "__tag": 4049,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "OpenBLAS"
                }
              ],
              "url": "https://www.openblas.net/",
              "title": ""
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", MKL (TM), and ATLAS. Because those libraries are multithreaded and processor dependent, environmental variables and external packages such as "
            },
            {
              "__type": "Link",
              "__tag": 4049,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "threadpoolctl"
                }
              ],
              "url": "https://github.com/joblib/threadpoolctl",
              "title": ""
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " may be needed to control the number of threads or specify the processor architecture."
            }
          ]
        },
        {
          "__type": "Target",
          "__tag": 4061,
          "label": "OpenBLAS"
        },
        {
          "__type": "Target",
          "__tag": 4061,
          "label": "threadpoolctl"
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The SciPy library also contains a "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "linalg",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "scipy",
                "version": "*",
                "kind": "api",
                "path": "scipy.linalg"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " submodule, and there is overlap in the functionality provided by the SciPy and NumPy submodules.  SciPy contains functions not found in "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.linalg",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy.linalg"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", such as functions related to LU decomposition and the Schur decomposition, multiple ways of calculating the pseudoinverse, and matrix transcendentals such as the matrix logarithm.  Some functions that exist in both have augmented functionality in "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "scipy.linalg",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "scipy",
                "version": "*",
                "kind": "api",
                "path": "scipy.linalg"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". For example, "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "scipy.linalg.eig",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "scipy",
                "version": "*",
                "kind": "api",
                "path": "scipy.linalg._decomp:eig"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " can take a second matrix argument for solving generalized eigenvalue problems.  Some functions in NumPy, however, have more flexible broadcasting options.  For example, "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.linalg.solve",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy.linalg:solve"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " can handle \"stacked\" arrays, while "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "scipy.linalg.solve",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "scipy",
                "version": "*",
                "kind": "api",
                "path": "scipy.linalg._basic:solve"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " accepts only a single square array as its first argument."
            }
          ]
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "note",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "note "
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "The term "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "matrix"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " as it is used on this page indicates a 2d "
                },
                {
                  "__type": "CrossRef",
                  "__tag": 4002,
                  "value": "numpy.array",
                  "reference": {
                    "__type": "RefInfo",
                    "__tag": 4000,
                    "module": "numpy",
                    "version": "*",
                    "kind": "api",
                    "path": "numpy:array"
                  },
                  "kind": "module"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " object, and "
                },
                {
                  "__type": "Emphasis",
                  "__tag": 4047,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "not"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " a "
                },
                {
                  "__type": "CrossRef",
                  "__tag": 4002,
                  "value": "numpy.matrix",
                  "reference": {
                    "__type": "RefInfo",
                    "__tag": 4000,
                    "module": "numpy",
                    "version": "*",
                    "kind": "api",
                    "path": "numpy:matrix"
                  },
                  "kind": "module"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " object. The latter is no longer recommended, even for linear algebra. See "
                },
                {
                  "__type": "InlineRole",
                  "__tag": 4003,
                  "value": "the matrix object documentation<matrix-objects>",
                  "domain": null,
                  "role": "ref",
                  "inventory": null
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " for more information."
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Linear algebra"
        }
      ],
      "level": 0,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Introduced in NumPy 1.10.0, the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "@"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " operator is preferable to other methods when computing the matrix product between 2d arrays. The "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.matmul",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy:matmul"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " function implements the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "@"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " operator."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "The "
        },
        {
          "__type": "InlineCode",
          "__tag": 4051,
          "value": "@"
        },
        {
          "__type": "Text",
          "__tag": 4046,
          "value": " operator"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    dot\n    linalg.multi_dot\n    vdot\n    vecdot\n    linalg.vecdot\n    inner\n    outer\n    linalg.outer\n    matmul\n    linalg.matmul (Array API compatible location)\n    matvec\n    vecmat\n    tensordot\n    linalg.tensordot (Array API compatible location)\n    einsum\n    einsum_path\n    linalg.matrix_power\n    kron\n    linalg.cross",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Matrix and vector products"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    linalg.cholesky\n    linalg.qr\n    linalg.svd\n    linalg.svdvals",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Decompositions"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    linalg.eig\n    linalg.eigh\n    linalg.eigvals\n    linalg.eigvalsh",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Matrix eigenvalues"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    linalg.norm\n    linalg.matrix_norm (Array API compatible)\n    linalg.vector_norm (Array API compatible)\n    linalg.cond\n    linalg.det\n    linalg.matrix_rank\n    linalg.slogdet\n    trace\n    linalg.trace (Array API compatible)",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Norms and other numbers"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    linalg.solve\n    linalg.tensorsolve\n    linalg.lstsq\n    linalg.inv\n    linalg.pinv\n    linalg.tensorinv",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Solving equations and inverting matrices"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    diagonal\n    linalg.diagonal (Array API compatible)\n    linalg.matrix_transpose (Array API compatible)",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Other matrix operations"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ".. autosummary:: \n    :toctree:generated/\n    linalg.LinAlgError",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Exceptions"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Several of the linear algebra routines listed above are able to compute results for several matrices at once, if they are stacked into the same array."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This is indicated in the documentation via input parameter specifications such as "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "a : (..., M, M) array_like"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". This means that if for instance given an input array "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "a.shape == (N, M, M)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", it is interpreted as a \"stack\" of N matrices, each of size M-by-M. Similar specification applies to return values, for instance the determinant has "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "det : (...)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and will in this case return an array of shape "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "det(a).shape == (N,)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". This generalizes to linear algebra operations on higher-dimensional arrays: the last 1 or 2 dimensions of a multidimensional array are interpreted as vectors or matrices, as appropriate for each operation."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Linear algebra on several matrices at once"
        }
      ],
      "level": 1,
      "target": "routines.linalg-broadcasting"
    }
  ],
  "local_refs": []
}