This subprogram computes the matrix-vector product for square sparse matrix A, stored in compressed-diagonal storage mode, using either the matrix or its transpose, and vectors x and y:
where A, x, and y contain long-precision real numbers.
Fortran | CALL DSDMX (iopt, n, nd, ad, lda, trans, la, x, y) |
C and C++ | dsdmx (iopt, n, nd, ad, lda, trans, la, x, y); |
PL/I | CALL DSDMX (iopt, n, nd, ad, lda, trans, la, x, y); |
If iopt = 0, matrix A is a general sparse matrix, where all the nonzero diagonals in matrix A are used to set up the storage arrays.
If iopt = 1, matrix A is a symmetric sparse matrix, where only the nonzero main diagonal and one of each of the unique nonzero diagonals are used to set up the storage arrays.
Specified as: a fullword integer; iopt = 0 or 1.
If trans = 'N', A is used in the computation.
If trans = 'T', AT is used in the computation.
Specified as: an lda by (at least) nd array, containing long-precision real numbers; lda >= n.
If trans = 'N', A is used in the computation.
If trans = 'T', AT is used in the computation.
Specified as: a single character; trans = 'N' or 'T'.
Specified as: a one-dimensional array of (at least) length nd, containing fullword integers; 1-n <= LA(i) <= n-1.
The matrix-vector product of a square sparse matrix or its transpose, is computed for a matrix stored in compressed-diagonal storage mode:
where:
It is expressed as follows for y<--Ax:
It is expressed as follows for y<--ATx:
If n is 0, no computation is performed; if nd is 0, output vector y is set to zero, because matrix A contains all zeros.
None
This example shows the matrix-vector product using trans = 'N', which is computed for the following sparse matrix A of order 6. The matrix is stored in compressed-matrix storage mode in arrays AD and LA using the storage variation for general sparse matrices, storing all nonzero diagonals. Matrix A is:
* * | 4.0 0.0 7.0 0.0 0.0 0.0 | | 3.0 4.0 0.0 2.0 0.0 0.0 | | 0.0 2.0 4.0 0.0 4.0 0.0 | | 0.0 0.0 7.0 4.0 0.0 1.0 | | 1.0 0.0 0.0 3.0 4.0 0.0 | | 1.0 1.0 0.0 0.0 3.0 4.0 | * *
IOPT N ND AD LDA TRANS LA X Y | | | | | | | | | CALL DSDMX( 0 , 6 , 5 , AD , 6 , 'N' , LA , X , Y )
* * | 4.0 0.0 0.0 0.0 7.0 | | 4.0 0.0 0.0 3.0 2.0 | AD = | 4.0 0.0 0.0 2.0 4.0 | | 4.0 0.0 0.0 7.0 1.0 | | 4.0 0.0 1.0 3.0 0.0 | | 4.0 1.0 1.0 3.0 0.0 | * *
LA = (0, -5, -4, -1, 2) X = (1.0, 2.0, 3.0, 4.0, 5.0, 6.0)
Y = (25.0, 19.0, 36.0, 43.0, 33.0, 42.0)
This example shows the matrix-vector product using trans = 'N', which is computed for the following sparse matrix A of order 6. The matrix is stored in compressed-matrix storage mode in arrays AD and LA using the storage variation for symmetric sparse matrices, storing the nonzero main diagonal and one of each of the unique nonzero diagonals. Matrix A is:
* * | 11.0 0.0 13.0 0.0 15.0 0.0 | | 0.0 22.0 0.0 24.0 0.0 26.0 | | 13.0 0.0 33.0 0.0 35.0 0.0 | | 0.0 24.0 0.0 44.0 0.0 46.0 | | 15.0 0.0 35.0 0.0 55.0 0.0 | | 0.0 26.0 0.0 46.0 0.0 66.0 | * *
IOPT N ND AD LDA TRANS LA X Y | | | | | | | | | CALL DSDMX( 1 , 6 , 3 , AD , 6 , 'N' , LA , X , Y )
* * | 11.0 13.0 0.0 | | 22.0 24.0 0.0 | AD = | 33.0 35.0 0.0 | | 44.0 46.0 0.0 | | 55.0 0.0 15.0 | | 66.0 0.0 26.0 | * *
LA = (0, 2, -4) X = (1.0, 2.0, 3.0, 4.0, 5.0, 6.0)
Y = (125.0, 296.0, 287.0, 500.0, 395.0, 632.0)
This example is the same as Example 1 except that it shows the matrix-vector product for the transpose of a matrix, using trans = 'T'. It is computed using the transpose of the following sparse matrix A of order 6, which is stored in compressed-matrix storage mode in arrays AD and LA, using the storage variation for general sparse matrices, storing all nonzero diagonals. It uses the same matrix A as in Example 1.
IOPT N ND AD LDA TRANS LA X Y | | | | | | | | | CALL DSDMX( 0 , 6 , 5 , AD , 6 , 'T' , LA , X , Y )
Y = (21.0, 20.0, 47.0, 35.0, 50.0, 28.0)