## Band Matrices | Extreme Optimization Numerical Libraries for .NET Professional |

A band matrix is a matrix whose only nonzero elements lie on diagonal bands above and/or below the main diagonal. The number of nonzero diagonals above the main diagonal is called the upper bandwidth. The number of nonzero diagonals below the main diagonal is called the lower bandwidth.

Band matrices exist in the usual variations. A general band matrix has nonzero elements both above and below the main diagonal. An upper band matrix only has elements on and above the main diagonal. A lower band matrix has elements on and below the main diagonal. A symmetric band matrix has identical elements on either side of the main diagonal.

All these variations of band matrices are implemented by the
BandMatrix

Band matrices are created using static methods of the Matrix class.

The CreateBanded creates general band matrices. It has two overloads. The first overload takes four arguments: the number of rows and columns of the matrix, the upper bandwidth, and the lower bandwidth. The element type must be specified as a generic type argument. The second overload takes an additional Boolean argument that specifies whether extra space should be allocated to compute an LU decomposition. The factors of an LU decomposition of a band matrix that uses partial pivoting have a larger upper bandwidth than the original matrix. As a result, extra storage space must be reserved to store these elements.

The shape of the band matrix is fixed. Once created, the upper and lower bandwidth cannot be changed. If the lower bandwidth is zero, the matrix is considered to be an upper band matrix. If the upper bandwidth is zero, the matrix is considered to be a lower band matrix.

The following example constructs a 5x7 band matrix with a lower bandwidth of 2 and an upper bandwidth of 1:

The CreateUpperBanded and CreateLowerBanded methods create upper and lower banded matrices. The first two arguments are the number of rows and columns. Next is the bandwidth above or below the diagonal. The last, optional argument is a MatrixDiagonal value that specifies whether the main diagonal of the matrix contains all ones.

The code below creates two band matrices. The first is a 7x6 upper band matrix with a bandwidth of 2 with unit diagonal. The second is a 7x7 lower band matrix with a bandwidth of 3.

var b2 = Matrix.CreateUpperBanded<double>(7, 6, 2, MatrixDiagonal.UnitDiagonal); var b3 = Matrix.CreateLowerBanded<double>(7, 7, 3);

Finally, the
CreateSymmetricBanded

The BandMatrix

The UpperBandwidth and LowerBandwidth properties return the number of non-zero diagonals above and below the main diagonal, respectively. The TotalBandwidth property returns the total number of diagonals that may contain nonzero elements, including the main diagonal.

A group of properties returns information about the structure of the matrix. The IsSymmetrical, IsUpperTriangular, IsLowerTriangular and IsUnitDiagonal properties fall in this category. Their names are self-explanatory.

The GetRow
and The GetColumn
methods of a BandMatrix

The LU decomposition for a general band matrix and the Cholesky decomposition of a symmetric band matrix also have a special form. Two special classes have been defined to take advantage of this special structure.

Copyright Â© 2004-2023,
Extreme Optimization. All rights reserved.

*Extreme Optimization,* *Complexity made simple*, *M#*, and *M
Sharp* are trademarks of ExoAnalytics Inc.

*Microsoft*, *Visual C#, Visual Basic, Visual Studio*, *Visual
Studio.NET*, and the *Optimized for Visual Studio* logo

are
registered trademarks of Microsoft Corporation.