SPRSIN

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.

Calling Sequence

Result = SPRSIN( A )

Arguments

A

An n by n array of any type except string or complex.

Keywords

COLUMN

Set this keyword if the input array A is in column-major format (composed of column vectors) rather than in row-major format (composed of row vectors).

DOUBLE

Set this keyword to convert the sparse array to double-precision.

THRESH

Use this keyword to set the criterion for deciding the absolute magnitude of the elements to be retained in sparse storage mode. For single-precision calculations, the default value is 1.0  ¥  10 -7 . For double-precision values, the default is 1.0  ¥  10 -14 .

Example

Suppose we wish to convert the following array to sparse storage format:

A = [[ 5.0, -0.2, 0.1], $

     [ 3.0, -2.0, 0.3], $

     [ 4.0, -1.0, 0.0]]

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.

See Also

FULSTR , LINBCG , SPRSAB , SPRSAX , READ_SPR , WRITE_SPR