|The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....|
|Home MathPack Matrix Classes TIntMatrix, TMatrix and TMat3D Methods ArrayToSparse|
|See also: CreateSparse, SparseToArray|
The method ArrayToSparse converts a normal full array-based representation of the matrix into a sparse matrix. Please note that this conversion is only meaningful for matrices which contain at least 70 % zeroes. Sparse matrices are in general more memory efficient if the matrix contains a high percentage of zeroes, however access to a sparse matrix is much slower.
The parameter AllocBy specifies the number of elements for which memory is allocated in advance. AllocBy should be set approx. 10 % higher than the expected number of non-zero elements in order to ensure maximum performance. The minimum amount of memory required by a sparse matrix is given by 12*AllocBy for TIntMatrix, or 16*AllocBy for TMatrix