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....



CreateSparse


Unit:SDL_matrix
Class: TIntMatrix
Declaration: constructor CreateSparse (AOwner: TComponent; AllocBy: longint);

The call to the constructor CreateSparse instantiates an object of the class TIntMatrix as a sparse matrix and allocates the necessary heap memory. If there is not enough memory space on the heap, an exception is generated ('not enough memory on heap').

Sparse matrices have the advantage that they are much more memory efficient for matrices which mainly consist of zeroes. In addition, sparse matrices need not to be dimensioned prior to using them. On the other hand, the major drawback of a sparse matrix is the (much) slower access to its elements.

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.

Hint: Please note that sparse matrices exceed normal matrix implementations in their requirement of storage space if more than 30 % (in the case of the integer matrix type TIntMatrix ) of the matrix elements are non-zero.


Last Update: 2023-Feb-06