dvperm
C DVPERM SOURCE CHAT 05/01/12 22:59:02 5004 IMPLICIT INTEGER(I-N) IMPLICIT REAL*8 (A-H,O-Z) C*********************************************************************** C NOM : IVPERM C DESCRIPTION : Permutation d'un tableau de réels. 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) REAL*8 X(N) c----------------------------------------------------------------------- c this subroutine performs an in-place permutation of a real vector x c according to the permutation array perm(*), i.e., on return, c the vector x satisfies, c c x(perm(j)) :== x(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 x = input vector c c on return: c---------- c x = vector x permuted according to x(perm(*)) := x(*) c c----------------------------------------------------------------------c c Y. Saad, Sep. 21 1989 c c----------------------------------------------------------------------c c local variables REAL*8 TMP, TMP1 INTEGER II,J,K,INIT,NEXT c INIT = 1 TMP = X(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 = X(II) X(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 reinitilaize cycle -- c 65 INIT = INIT+1 IF (INIT .GT. N) GOTO 101 IF (PERM(INIT) .LT. 0) GOTO 65 TMP = X(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-dvperm--------------------------------------- c----------------------------------------------------------------------- END
© Cast3M 2003 - Tous droits réservés.
Mentions légales