You are here: Symbol Reference > Sparse Namespace > Classes > TSparseMtx Class > public > TSparseMtx.SparseToBanded Method
MtxVec VCL
ContentsIndex
PreviousUpNext
TSparseMtx.SparseToBanded Method

Convert sparse matrix to banded matrix.

Pascal
procedure SparseToBanded(const Dst: TMtx; MaxElemCount: integer = 10000000);

Convert calling matrix, stored in HB sparse matrix format, to banded matrix format. The result (banded matrix format) is stored in Dst matrix. The size and complex properties of Dst matrix are adjusted automatically.

Step 1: construct banded matrix 

 

var subDiag, SupDiag,MainDiag: Vector; A: Matrix; begin SubDiag.Size(4); SuperDiag.Size(4); MainDiag.Size(4); A.Size(3,4); A.SubDiag := 1; // one subdiagonal A.SuperDiag := 1; // one superdiagonal SubDiag.SetIt([0,1,3,2]); SupDiag.SetIt([-1,2,7,0]); MainDiag.SetIt([2,3,5,1]); A.SetRow(SupDiag,0); A.SetRow(MainDiag,1); A.SetRow(SubDiag,2); end;

 

Step 2: convert banded matrix to sparse matrix: 

 

SparseA.BandedToSparse(A); end;
Examples on GitHub
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!