HyperMath

BandMatrixIndices

BandMatrixIndices

Previous topic Next topic No expanding text in this topic  

BandMatrixIndices

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

Computes the indices for the compressed diagonal storage  matrix equivalent of a banded matrix.  This needs to be called for each of the original matrix entries within the band.

Syntax

row, col = BandMatrixIndices(i, j, size, kl, ku)

Arguments

Name

Description

 

i

The row index of the element of the original matrix.

 

j

The column index of the element of the original matrix.

 

size

The size of each dimension of the original square matrix.

 

kl

Number of sub-diagonals in the lower band of the original matrix.  This should include zero entry off-diagonals that are placed in-between.

 

ku

Number of super diagonals in the upper band of the original matrix.  This should include zero entry off-diagonals that are placed in-between.

Output

Name

Description

 

row

The corresponding row index in the compressed diagonal storage format for index i in source matrix.

 

col

The corresponding column index in the compressed diagonal storage format for index j in source matrix.

Example

Construct the compressed diagonal storage matrix for A, where A is a 3x3 matrix with one sub- and super-diagonal.

 

Syntax

 

A = [1,2,0;41,15,6;0,8,9]; // 3x3 band matrix

kl=1; ku=1; // off diagonal bandwidths

M = BandMatrix(3,kl,ku); // This will hold the compressed matrix

// For each band entry (i,j) of A do the following two operations

row,col = BandMatrixIndices(i,j,3,kl,ku);

M(row,col) = A(i,j);

 

Result

 

M will be the compressed diagonal storage matrix version of A.

[Matrix] 4 x 3

0               0               0            

0               2               6              

1               15              9

41              8               0              

Comments

The matrix M becomes an input to a function such as LSolveB.

See Also:

BandMatrix

SymBandMatrix

SymBandMatrixIndices