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

Convert dense matrix to sparse matrix format.

Pascal
procedure DenseToSparse(const A: TMtx; ZeroThreshold: double = 0; PreserveZeroDiagElem: boolean = true);

Convert dense matrix A to modified compressed column sparse matrix format.

Step 1: Construct dense matrix, 

 

var A,B: Matrix; SparseA: TSparseMtx; /// ... A.SetIt(3,3,false,[1,0,0,0,2,0,0,1,3]);

 

 

Step 2: Convert dense matrix to sparse matrix 

 

/// ... SparseA.DenseToSparse(A);

 

 

Step 3: Convert sparse matrix back to dense and compare 

 

/// ... SparseA.SparseToDense(B); if not A.Equal(B,1.0e-5) then ERaise('Not Equal!');
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!