{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This helper function simply runs over the array looking for the nonzero entries whether there exists a banded structure in the array or not. Hence, the performance depends on the density of nonzero entries and also memory-layout. Fortran- or C- contiguous arrays are handled best and otherwise suffers from extra random memory access cost."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The strategy is to look for only untested band elements in the upper and lower triangular parts separately; depending on the memory layout we scan row-wise or column-wise. Moreover, say we are scanning rows and in the 6th row, 4th entry is nonzero then, on the succeeding rows the horizontal search is done only up to that band entries since we know that band is occupied. Therefore, a completely dense matrix scan cost is in the order of n."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "",
              "annotation": "TypeError",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If the dtype of the array is not supported, in particular, for NumPy float16, float128 and complex256 and other NumPy non-numeric types."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "lower",
              "annotation": "int | ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Lower bandwidth. A scalar "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "np.int64"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is assigned per 2D slice of the input array of last two dimensions. A value of 0 means the slice is upper triangular; "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "N - 1"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " means the lower part is full. If the input array is 2D then an "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "int",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "builtins",
                        "version": "?",
                        "kind": "module",
                        "path": "builtins:int"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is returned."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "upper",
              "annotation": "int | ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Upper bandwidth. Same shape rules as "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "lower",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": null,
                        "version": null,
                        "kind": "local",
                        "path": "lower"
                      },
                      "kind": "local"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". A value of 0 means the slice is lower triangular; "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "M - 1"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " means the upper part is full. If the input array is 2D then a scalar "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "int",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "builtins",
                        "version": "?",
                        "kind": "module",
                        "path": "builtins:int"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is returned."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Return the lower and upper bandwidth of a numeric array."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "a",
              "annotation": "(..., N, M) array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Input array of at least 2 dimensions."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "build-install/usr/lib/python3.14/site-packages/scipy/linalg/_misc.py",
  "item_line": 197,
  "item_type": "function",
  "aliases": [
    "scipy.linalg.bandwidth"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy.linalg import bandwidth\nA = np.array([[3., 0., 0., 0., 0.],\n              [0., 4., 0., 0., 0.],\n              [0., 0., 5., 1., 0.],\n              [8., 0., 0., 6., 2.],\n              [0., 9., 0., 0., 7.]])\nbandwidth(A)\n",
        "execution_status": "success",
        "out": "(3, 1)\n"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "a",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "bandwidth"
  },
  "references": null,
  "qa": "scipy.linalg._misc:bandwidth",
  "arbitrary": [],
  "local_refs": [
    "a",
    "lower",
    "upper"
  ]
}