Contents
ccsrsm - compressed sparse row format triangular solve
SUBROUTINE CCSRSM( TRANSA, M, N, UNITD, DV, ALPHA, DESCRA,
* VAL, INDX, PNTRB, PNTRE,
* B, LDB, BETA, C, LDC, WORK, LWORK )
INTEGER TRANSA, M, N, UNITD, DESCRA(5),
* LDB, LDC, LWORK
INTEGER INDX(NNZ), PNTRB(M), PNTRE(M)
COMPLEX ALPHA, BETA
COMPLEX DV(M), VAL(NNZ), B(LDB,*), C(LDC,*), WORK(LWORK)
SUBROUTINE CCSRSM_64( TRANSA, M, N, UNITD, DV, ALPHA, DESCRA,
* VAL, INDX, PNTRB, PNTRE,
* B, LDB, BETA, C, LDC, WORK, LWORK )
INTEGER*8 TRANSA, M, N, UNITD, DESCRA(5),
* LDB, LDC, LWORK
INTEGER*8 INDX(NNZ), PNTRB(M), PNTRE(M)
COMPLEX ALPHA, BETA
COMPLEX DV(M), VAL(NNZ), B(LDB,*), C(LDC,*), WORK(LWORK)
where NNZ = PNTRE(M)-PNTRB(1)
F95 INTERFACE
SUBROUTINE CSRSM( TRANSA, M, [N], UNITD, DV, ALPHA, DESCRA, VAL, INDX,
* PNTRB, PNTRE, B, [LDB], BETA, C, [LDC], [WORK], [LWORK])
INTEGER TRANSA, M, UNITD
INTEGER, DIMENSION(:) :: DESCRA, INDX, PNTRB, PNTRE
COMPLEX ALPHA, BETA
COMPLEX, DIMENSION(:) :: VAL, DV
COMPLEX, DIMENSION(:, :) :: B, C
SUBROUTINE CSRSM_64(TRANSA, M, [N], UNITD, DV, ALPHA, DESCRA, VAL, INDX,
* PNTRB, PNTRE, B, [LDB], BETA, C, [LDC], [WORK], [LWORK])
INTEGER*8 TRANSA, M, UNITD
INTEGER*8, DIMENSION(:) :: DESCRA, INDX, PNTRB, PNTRE
COMPLEX ALPHA, BETA
COMPLEX, DIMENSION(:) :: VAL, DV
COMPLEX, DIMENSION(:, :) :: B, C
C INTERFACE
#include <sunperf.h>
void ccsrsm(int transa, int mb, int n, int unitd, complex
*dv, complex *alpha, int *descra, complex *val, int *indx,
int *pntrb, int *pntre, complex *b, int ldb, complex *beta,
complex* c, int ldc);
void ccsrsm_64(long transa, long mb, long n, long unitd,
complex *dv, complex *alpha, long *descra, complex *val,
long *indx, long *pntrb, long *pntre, complex *b, long ldb,
complex *beta, complex *c, long ldc);
ccsrsm performs one of the matrix-matrix operations
C <- alpha op(A) B + beta C, C <-alpha D op(A) B + beta C,
C <- alpha op(A) D B + beta C,
where alpha and beta are scalars, C and B are m by n dense matrices,
D is a diagonal scaling matrix, A is a sparse m by m unit, or non-unit,
upper or lower triangular matrix represented in the compressed sparse
row format and op( A ) is one of
op( A ) = inv(A) or op( A ) = inv(A') or op( A ) =inv(conjg( A' ))
(inv denotes matrix inverse, ' indicates matrix transpose).
TRANSA(input) On entry, TRANSA indicates how to operate with the
sparse matrix:
0 : operate with matrix
1 : operate with transpose matrix
2 : operate with the conjugate transpose of matrix.
2 is equivalent to 1 if matrix is real.
Unchanged on exit.
M(input) On entry, M specifies the number of rows in
the matrix A. Unchanged on exit.
N(input) On entry, N specifies the number of columns in
the matrix C. Unchanged on exit.
UNITD(input) On entry, UNITD specifies the type of scaling:
1 : Identity matrix (argument DV[] is ignored)
2 : Scale on left (row scaling)
3 : Scale on right (column scaling)
4 : Automatic row scaling (see section NOTES for
further details)
Unchanged on exit.
DV(input) On entry, DV is an array of length M consisting of the
diagonal entries of the diagonal scaling matrix D.
If UNITD is 4, DV contains diagonal matrix by which
the rows have been scaled (see section NOTES for further
details). Otherwise, unchanged on exit.
ALPHA(input) On entry, ALPHA specifies the scalar alpha. Unchanged on exit.
DESCRA (input) Descriptor argument. Five element integer array:
DESCRA(1) matrix structure
0 : general
1 : symmetric (A=A')
2 : Hermitian (A= CONJG(A'))
3 : Triangular
4 : Skew(Anti)-Symmetric (A=-A')
5 : Diagonal
6 : Skew-Hermitian (A= -CONJG(A'))
Note: For the routine, DESCRA(1)=3 is only supported.
DESCRA(2) upper/lower triangular indicator
1 : lower
2 : upper
DESCRA(3) main diagonal type
0 : non-unit
1 : unit
DESCRA(4) Array base (NOT IMPLEMENTED)
0 : C/C++ compatible
1 : Fortran compatible
DESCRA(5) repeated indices? (NOT IMPLEMENTED)
0 : unknown
1 : no repeated indices
VAL(input) On entry, VAL is a scalar array of length
NNZ = PNTRE(M)-PNTRB(1) consisting of nonzero entries
of A. If UNITD is 4, VAL contains the scaled matrix
D*A (see section NOTES for further details).
Otherwise, unchanged on exit.
INDX(input) On entry, INDX is an integer array of length
NNZ = PNTRE(M)-PNTRB(1) consisting of the column
indices of nonzero entries of A. Column indices
MUST be sorted in increasing order for each
row. Unchanged on exit.
PNTRB(input) On entry, PNTRB is an integer array of length M such
that PNTRB(J)-PNTRB(1)+1 points to location in VAL
of the first nonzero element in row J.
Unchanged on exit.
PNTRE(input) On entry, PNTRE is an integer array of length M
such that PNTRE(J)-PNTRB(1) points to location
in VAL of the last nonzero element in row J.
Unchanged on exit.
B (input) Array of DIMENSION ( LDB, N ).
On entry, the leading m by n part of the array B
must contain the matrix B. Unchanged on exit.
LDB (input) On entry, LDB specifies the first dimension of B as declared
in the calling (sub) program. Unchanged on exit.
BETA (input) On entry, BETA specifies the scalar beta. Unchanged on exit.
C(input/output) Array of DIMENSION ( LDC, N ).
On entry, the leading m by n part of the array C
must contain the matrix C. On exit, the array C is
overwritten.
LDC (input) On entry, LDC specifies the first dimension of C as declared
in the calling (sub) program. Unchanged on exit.
WORK(workspace) Scratch array of length LWORK.
On exit, if LWORK= -1, WORK(1) returns the optimum size
of LWORK.
LWORK (input) On entry, LWORK specifies the length of WORK array. LWORK
should be at least M.
For good performance, LWORK should generally be larger.
For optimum performance on multiple processors, LWORK
>=M*N_CPUS where N_CPUS is the maximum number of
processors available to the program.
If LWORK=0, the routine is to allocate workspace needed.
If LWORK = -1, then a workspace query is assumed; the
routine only calculates the optimum size of the WORK array,
returns this value as the first entry of the WORK array,
and no error message related to LWORK is issued by XERBLA.
NOTES/BUGS
1. No test for singularity or near-singularity is included
in this routine. Such tests must be performed before calling
this routine.
2. If UNITD =4, the routine scales the rows of A such that
their 2-norms are one. The scaling may improve the accuracy
of the computed solution. Corresponding entries of VAL are
changed only in the particular case. On return DV matrix
stored as a vector contains the diagonal matrix by which the
rows have been scaled. UNITD=2 should be used for the next
calls to the routine with overwritten VAL and DV.
WORK(1)=0 on return if the scaling has been completed
successfully, otherwise WORK(1) = - i where i is the row
number which 2-norm is exactly zero.
3. If DESCRA(3)=1 and UNITD < 4, the diagonal entries are
each used with the mathematical value 1. The entries of the
main diagonal in the CSR representation of a sparse matrix
do not need to be 1.0 in this usage. They are not used by
the routine in these cases. But if UNITD=4, the unit
diagonal elements MUST be referenced in the CSR
representation.
4. The routine is designed so that it checks the validity of
each sparse entry given in the sparse blas representation.
Entries with incorrect indices are not used and no error
message related to the entries is issued.
The feature also provides a possibility to use the sparse
matrix representation of a general matrix A for solving
triangular systems with the upper or lower triangle of A.
But DESCRA(1) MUST be equal to 3 even in this case.
Assume that there is the sparse matrix representation a
general matrix A decomposed in the form
A = L + D + U
where L is the strictly lower triangle of A, U is the
strictly upper triangle of A, D is the diagonal matrix.
Let's I denotes the identity matrix.
Then the correspondence between the first three values of
DESCRA and the result matrix for the sparse representation
of A is
DESCRA(1) DESCRA(2) DESCRA(3) RESULT
3 1 1 alpha*op(L+I)*B+beta*C
3 1 0 alpha*op(L+D)*B+beta*C
3 2 1 alpha*op(U+I)*B+beta*C
3 2 0 alpha*op(U+D)*B+beta*C
5. It is known that there exists another representation of
the compressed sparse row format (see for example Y.Saad,
"Iterative Methods for Sparse Linear Systems", WPS, 1996).
Its data structure consists of three array instead of the
four used in the current implementation. The main
difference is that only one array, IA, containing the
pointers to the beginning of each row in the arrays VAL and
INDX is used instead of two arrays PNTRB and PNTRE. To use
the routine with this kind of compressed sparse row format
the following calling sequence should be used
SUBROUTINE CCSRSM( TRANSA, M, N, UNITD, DV, ALPHA, DESCRA,
* VAL, INDX, IA, IA(2), B, LDB, BETA, C,
* LDC, WORK, LWORK )