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

Creates quadratic non-complex non-singular sparse matrix.

Pascal
procedure RandomSparse(const X: TVec; const Y: TVec; Symmetric: boolean = false; FillInPercent: double = 33; MaxNonZeroCount: integer = 10000000); overload;

Creates general/symmetric quadratic non-complex non-singular sparse matrix. It returns the right hand side in vector Y and the solution in vector X. If Symmetric is true the method will generate a matrix with symmetric pattern. The FillInPercent parameter defines the percentage of non-zero in the sparse matrix. The MaxNonZeroCount parameter defines an upper limit to prevent against excessive memory usage (consequence of invalid user parameters) and consecutive system lock up.

You have to set Cols property to definethe size of the matrix before calling this routine.

Uses MtxExpr, sparse, MtxVecTee; procedure Example; var SparseA: TMtxSparse; GridSeries: TMtxGridSeries; v1,v2: Vector; A: Matrix; begin // ... SparseA.Size(7500,4000,4000,false); SparseA.RandomSparse(v1,v2); SparseA.PixelDownSample(A); DrawValues(A,GridSeries); // showing A end;
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!