Numérotation des lignes :

csort
C CSORT     SOURCE    CHAT      05/01/12    22:32:01     5004      SUBROUTINE CSORT(N,A,JA,IA,IWORK,VALUES)      IMPLICIT INTEGER(I-N)      IMPLICIT REAL*8 (A-H,O-Z)C***********************************************************************C NOM         : CSORTC DESCRIPTION : Ordonnancement du profil ou d'une matrice Morse.CCC LANGAGE     : FORTRAN 77C ADAPTATION  :  Stéphane GOUNAND (CEA/DRN/DMT/SEMT/LTMF)C                mél : gounand@semt2.smts.cea.frC AUTEUR      :C  Sparskit : a basic tool kit for sparse matrix computationsC  Version 2 (Youcef Saad)C  -> URL : http://www.cs.umn.edu/Research/arpa/SPARSKIT/sparskit.htmlCC***********************************************************************      LOGICAL VALUES      INTEGER N, JA(*), IA(N+1), IWORK(*)      REAL*8 A(*)c-----------------------------------------------------------------------c This routine sorts the elements of  a matrix (stored in Compressedc Sparse Row Format) in increasing order of their column indices withinc each row. It uses a form of bucket sort with a cost of O(nnz) wherec nnz = number of nonzero elements.c requires an integer work array of length 2*nnz.c-----------------------------------------------------------------------c on entry:c---------c n     = the row dimension of the matrixc a     = the matrix A in compressed sparse row format.c ja    = the array of column indices of the elements in array a.c ia    = the array of pointers to the rows.c iwork = integer work array of length max ( n+1, 2*nnz )c         where nnz = (ia(n+1)-ia(1))  ) .c values= logical indicating whether or not the real values a(*) mustc         also be permuted. if (.not. values) then the array a is notc         touched by csort and can be a dummy array.cc on return:c----------c the matrix stored in the structure a, ja, ia is permuted in such ac way that the column indices are in increasing order within each row.c iwork(1:nnz) contains the permutation used  to rearrange the elements.c-----------------------------------------------------------------------c Y. Saad - Feb. 1, 1991.c-----------------------------------------------------------------------c local variables      INTEGER I, K, J, IFIRST, NNZ, NEXT      INTEGER IROW,KOcc count the number of elements in each columnc* gounand : déjà fait*      DO 1 I=1,N+1*         IWORK(I) = 0* 1    CONTINUE      DO 3 I=1, N         DO 2 K=IA(I), IA(I+1)-1            J = JA(K)+1            IWORK(J) = IWORK(J)+1 2       CONTINUE 3    CONTINUEcc compute pointers from lengths.c      IWORK(1) = 1      DO 4 I=1,N         IWORK(I+1) = IWORK(I) + IWORK(I+1) 4    CONTINUECC get the positions of the nonzero elements in order of columns.C      IFIRST = IA(1)      NNZ = IA(N+1)-IFIRST      DO 5 I=1,N         DO 51 K=IA(I),IA(I+1)-1            J = JA(K)            NEXT = IWORK(J)            IWORK(NNZ+NEXT) = K            IWORK(J) = NEXT+1 51      CONTINUE 5    CONTINUEcc convert to coordinate formatc      DO 6 I=1, N         DO 61 K=IA(I), IA(I+1)-1            IWORK(K) = I 61      CONTINUE 6    CONTINUEcc loop to find permutation: for each element find the correctc position in (sorted) arrays a, ja. Record this in iwork.c      DO 7 K=1, NNZ         KO = IWORK(NNZ+K)         IROW = IWORK(KO)         NEXT = IA(IROW)cc the current element should go in next position in row. iworkc records this position.c         IWORK(KO) = NEXT         IA(IROW)  = NEXT+1 7       CONTINUEcc perform an in-place permutation of the  arrays.c         CALL IVPERM (NNZ, JA(IFIRST), IWORK)         IF (VALUES) CALL DVPERM (NNZ, A(IFIRST), IWORK)cc reshift the pointers of the original matrix back.c      DO 8 I=N,1,-1         IA(I+1) = IA(I) 8    CONTINUE      IA(1) = IFIRSTc      RETURNc---------------end-of-csort--------------------------------------------c-----------------------------------------------------------------------      END   

© Cast3M 2003 - Tous droits réservés.
Mentions légales