Skip to content

bandwidth

Matrix bandwidth

low = bandwidth(A)

  • A should be a matrix.
  • It returns the lower bandwidth of A.
  • It returns, say, low==3, if elements of A lying below the 3rd lower-diagonal are all equal to zero.
  • It returns 0 if A is empty.

[low,up] = bandwidth(A)

  • A should be a matrix.
  • It returns the lower and upper bandwidths of A.
  • It returns, say, low==3 and upper==4, if elements of A lying below the 3rd lower-diagonal or above the 4th upper-diagonal are all equal to zero.
  • It returns 0 if A is empty.

Example 1: Finding lower and upper bandwidths of a randomly generated matrix.

% Creating a random complex matrix with 30% of its entries
% being non-zero.
a=zeros(5);
i=randi(numel(a),1,ceil(numel(a)*.3));
a(i)=7+7i
% Finding lower and upper bandwidths
[l,u]=bandwidth(a)
a =
 0.000 + 0.000i   7.000 + 7.000i   0.000 + 0.000i   0.000 + 0.000i   0.000 + 0.000i
 0.000 + 0.000i   0.000 + 0.000i   0.000 + 0.000i   0.000 + 0.000i   0.000 + 0.000i
 0.000 + 0.000i   0.000 + 0.000i   0.000 + 0.000i   7.000 + 7.000i   7.000 + 7.000i
 0.000 + 0.000i   0.000 + 0.000i   7.000 + 7.000i   0.000 + 0.000i   7.000 + 7.000i
 0.000 + 0.000i   7.000 + 7.000i   7.000 + 7.000i   0.000 + 0.000i   7.000 + 7.000i

l =
 3.000

u =
 2.000

bandwidth(A, type)

  • A should be a matrix.
  • type should be either 'upper' or 'lower'.
  • If type is 'upper', it returns the upper bandwidth of A. If otherwise, it returns the lower bandwidth.
  • It returns 0 if A is empty.

Example 2: Finding lower and upper bandwidths of a randomly generated matrix.

% Creating a random complex matrix with 30% of its entries
% being non-zero.
a=zeros(5);
i=randi(numel(a),1,ceil(numel(a)*.3));
a(i)=7+7i
% Finding lower and upper bandwidths
l=bandwidth(a,'lower')
u=bandwidth(a,'upper')
a =
 0.000 + 0.000i   0.000 + 0.000i   0.000 + 0.000i   0.000 + 0.000i   0.000 + 0.000i
 0.000 + 0.000i   0.000 + 0.000i   0.000 + 0.000i   7.000 + 7.000i   0.000 + 0.000i
 7.000 + 7.000i   0.000 + 0.000i   0.000 + 0.000i   0.000 + 0.000i   7.000 + 7.000i
 0.000 + 0.000i   7.000 + 7.000i   0.000 + 0.000i   7.000 + 7.000i   0.000 + 0.000i
 0.000 + 0.000i   0.000 + 0.000i   7.000 + 7.000i   0.000 + 0.000i   0.000 + 0.000i

l =
 2.000

u =
 2.000