Skip to main content
`Ctrl`+`K`
scipy.sparse.linalg.

# spbandwidth

scipy.sparse.linalg.spbandwidth(A)

  Return the lower and upper bandwidth of a 2D numeric array.

  Computes the lower and upper limits on the bandwidth of the sparse 2D array `A`. The result is summarized as a 2-tuple of positive integers `(lo, hi)`. A zero denotes no sub/super diagonal entries on that side (tringular). The maximum value for `lo``(``hi`) is one less than the number of rows(cols).

  Only the sparse structure is used here. Values are not checked for zeros.

  Parameters:
    ASciPy sparse array or matrix

      A sparse matrix preferrably in CSR or CSC format.

  Returns:
    below, above2-tuple of int

      The distance to the farthest non-zero diagonal below/above the main diagonal.

      Added in version 1.15.0.

  Examples

      >>> import numpy as np
      >>> from scipy.sparse.linalg import spbandwidth
      >>> from scipy.sparse import csc_array, eye_array
      >>> A = csc_array([[3, 0, 0], [1, -1, 0], [2, 0, 1]], dtype=float)
      >>> spbandwidth(A)
      (2, 0)
      >>> D = eye_array(3, format='csr')
      >>> spbandwidth(D)
      (0, 0)