The SPRSIN function converts an array into a row-index sparse storage mode, retaining only elements with an absolute magnitude greater than or equal to the specified threshold.
The result is a row-indexed sparse array contained in structure form. The structure consists of two linear sparse storage vectors: SA, a vector of array values, and IJA, a vector of subscripts to the SA vector. The length of these vectors is equal to the number of diagonal elements of the array, plus the number of off-diagonal elements with an absolute magnitude greater that or equal to the threshold value. Diagonal elements of the array are always retained even if their absolute magnitude is less than the specified threshold.
SPRSIN is based on the routine
sprsin
described in section 2.7 of
Numerical Recipes in C: The Art of Scientific Computing
(Second Edition), published by Cambridge University Press, and is used by permission.
Suppose we wish to convert the following array to sparse storage format:
sparse = SPRSIN(A, THRESH = 0.5) ; Convert to sparse storage mode. All elements of the array A that have absolute values less than THRESH are set to zero.
The variable SPARSE now contains a representation of A in structure form. See the description of FULSTR for an example that restores such a structure to full storage mode.