cperm
C CPERM SOURCE CHAT 05/01/12 22:26:04 5004 IMPLICIT INTEGER(I-N) IMPLICIT REAL*8 (A-H,O-Z) C*********************************************************************** C NOM : CPERM C DESCRIPTION : Permutation des colonnes d'une matrice Morse. C C C LANGAGE : FORTRAN 77 C ADAPTATION : Stéphane GOUNAND (CEA/DRN/DMT/SEMT/LTMF) C mél : gounand@semt2.smts.cea.fr C AUTEUR : C Sparskit : a basic tool kit for sparse matrix computations C Version 2 (Youcef Saad) C -> URL : http://www.cs.umn.edu/Research/arpa/SPARSKIT/sparskit.html C C*********************************************************************** INTEGER NROW,JA(*),IA(NROW+1),JAO(*),IAO(NROW+1),PERM(*), JOB REAL*8 A(*), AO(*) c----------------------------------------------------------------------- c this subroutine permutes the columns of a matrix a, ja, ia. c the result is written in the output matrix ao, jao, iao. c cperm computes B = A P, where P is a permutation matrix c that maps column j into column perm(j), i.e., on return c a(i,j) becomes a(i,perm(j)) in new matrix c Y. Saad, May 2, 1990 / modified Jan. 28, 1991. c----------------------------------------------------------------------- c on entry: c---------- c nrow = row dimension of the matrix c c a, ja, ia = input matrix in csr format. c c perm = integer array of length ncol (number of columns of A c containing the permutation array the columns: c a(i,j) in the original matrix becomes a(i,perm(j)) c in the output matrix. c c job = integer indicating the work to be done: c job = 1 permute a, ja, ia into ao, jao, iao c (including the copying of real values ao and c the array iao). c job .ne. 1 : ignore real values ao and ignore iao. c c------------ c on return: c------------ c ao, jao, iao = input matrix in a, ja, ia format (array ao not needed) c c Notes: c------- c 1. if job=1 then ao, iao are not used. c 2. This routine is in place: ja, jao can be the same. c 3. If the matrix is initially sorted (by increasing column number) c then ao,jao,iao may not be on return. c c----------------------------------------------------------------------c c local parameters: INTEGER K, I, NNZ c NNZ = IA(NROW+1)-1 DO 100 K=1,NNZ JAO(K) = PERM(JA(K)) 100 CONTINUE c c done with ja array. return if no need to touch values. c IF (JOB .NE. 1) RETURN c c else get new pointers -- and copy values too. c DO 1 I=1, NROW+1 IAO(I) = IA(I) 1 CONTINUE c DO 2 K=1, NNZ AO(K) = A(K) 2 CONTINUE c RETURN c---------end-of-cperm-------------------------------------------------- c----------------------------------------------------------------------- END
© Cast3M 2003 - Tous droits réservés.
Mentions légales