ivperm
C IVPERM SOURCE CHAT 05/01/13 00:45:44 5004 IMPLICIT INTEGER(I-N) IMPLICIT REAL*8 (A-H,O-Z) C*********************************************************************** C NOM : IVPERM C DESCRIPTION : Permutation d'un tableau d'entiers. 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 N, PERM(N), IX(N) c----------------------------------------------------------------------- c this subroutine performs an in-place permutation of an integer vector c ix according to the permutation array perm(*), i.e., on return, c the vector x satisfies, c c ix(perm(j)) :== ix(j), j=1,2,.., n c c----------------------------------------------------------------------- c on entry: c--------- c n = length of vector x. c perm = integer array of length n containing the permutation array. c ix = input vector c c on return: c---------- c ix = vector x permuted according to ix(perm(*)) := ix(*) c c----------------------------------------------------------------------c c Y. Saad, Sep. 21 1989 c c----------------------------------------------------------------------c c local variables INTEGER TMP, TMP1 INTEGER II,J,K,INIT,NEXT c INIT = 1 TMP = IX(INIT) II = PERM(INIT) PERM(INIT)= -PERM(INIT) K = 0 c c loop c 6 CONTINUE K = K+1 c c save the chased element -- c TMP1 = IX(II) IX(II) = TMP NEXT = PERM(II) IF (NEXT .LT. 0 ) GOTO 65 c c test for end c IF (K .GT. N) GOTO 101 TMP = TMP1 PERM(II) = - PERM(II) II = NEXT c c end loop c GOTO 6 c c reinitialize cycle -- c 65 CONTINUE INIT = INIT+1 IF (INIT .GT. N) GOTO 101 IF (PERM(INIT) .LT. 0) GOTO 65 TMP = IX(INIT) II = PERM(INIT) PERM(INIT)=-PERM(INIT) GOTO 6 c 101 CONTINUE DO 200 J=1, N PERM(J) = -PERM(J) 200 CONTINUE C RETURN c-------------------end-of-ivperm--------------------------------------- c----------------------------------------------------------------------- END
© Cast3M 2003 - Tous droits réservés.
Mentions légales