## SPRSAB

The SPRSAB function performs matrix multiplication on two row-indexed sparse arrays created by SPRSIN. The routine computes all components of the matrix products, but only stores those values whose absolute magnitude exceeds the threshold value. The result is a row-indexed sparse array.

SPRSAB is based on the routine ``` sprstm``` 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. The difference between the two routines is that SPRSAB performs the matrix multiplication A.B rather than A.B T .

### Calling Sequence

Result = SPRSAB( A, B )

### Arguments

#### A, B

Row-indexed sparse arrays created by the SPRSIN function.

### Keywords

#### DOUBLE

Set this keyword to force the computation to be done in double-precision arithmetic.

#### 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 calculations, the default is 1.0  ¥  10 -14 .

### Example

Begin by creating two arrays:

A = [[ 5.0, 0.0, 0.0, 1.0], \$

[ 3.0, -2.0, 0.0, 1.0], \$

[ 4.0, -1.0, 0.0, 2.0], \$

[ 0.0, 3.0, 3.0, 1.0]]

B = [[ 1.0, 2.0, 3.0, 1.0], \$

[ 3.0, -3.0, 0.0, 1.0], \$

[-1.0, 3.0, 1.0, 2.0], \$

[ 0.0, 3.0, 3.0, 1.0]]

sparse = SPRSAB(SPRSIN(A), SPRSIN(B)) ; Convert the arrays to sparse array format before multiplying. The variable SPARSE holds the result in sparse array form.

result = FULSTR(sparse) ; Restore the sparse array structure to full storage mode.

PRINT, result ; Print the result.

IDL prints:

5.00000 13.0000 18.0000   6.00000

-3.00000 15.0000 12.0000   2.00000

1.00000 17.0000 18.0000   5.00000

6.00000  3.00000 6.00000 10.0000

We can check this result by multiplying the original arrays:

exact = B # A

PRINT, exact

IDL prints:

5.00000 13.0000 18.0000   6.00000

-3.00000 15.0000 12.0000   2.00000

1.00000 17.0000 18.0000   5.00000

6.00000  3.00000 6.00000 10.0000