bandwidth
Lower and upper bandwidth of a matrix.
Category: Mathematics > Linear Algebra
Syntax
[lower, upper] = bandwidth(A)
Returns both bandwidths.
B = bandwidth(A, type)
Returns one bandwidth, where type is 'lower' or 'upper'.
Description
The lower bandwidth is the largest i - j over the nonzero entries A(i,j) with i > j, and the upper bandwidth is the largest j - i. A diagonal matrix has both equal to 0, a tridiagonal matrix has both equal to 1, and a full square n-by-n matrix has both equal to n - 1 (when its triangles are nonzero).
Bandwidth tells which solver or storage scheme is worthwhile: banded systems can be solved in time proportional to n times the bandwidth squared.
Input arguments
A- Numeric matrix.
type'lower'or'upper'.
Output arguments
lower- Number of diagonals below the main one that hold a nonzero.
upper- Number of diagonals above the main one that hold a nonzero.
Example
A tridiagonal matrix
A = [1 2 0 0; 3 4 5 0; 0 6 7 8; 0 0 9 10];
[lo, up] = bandwidth(A)
bandwidth(A, 'lower')
Output
lo = 1
up = 1
ans = 1