Download cperm.eso

Back to the list

   1 : C CPERM     SOURCE    CHAT      05/01/12    22:26:04     5004           
   2 :       SUBROUTINE CPERM (NROW,A,JA,IA,AO,JAO,IAO,PERM,JOB) 
   3 :       IMPLICIT INTEGER(I-N)
   4 :       IMPLICIT REAL*8 (A-H,O-Z)
   5 : C***********************************************************************
   6 : C NOM         : CPERM
   7 : C DESCRIPTION : Permutation des colonnes d'une matrice Morse. 
   8 : C
   9 : C
  10 : C LANGAGE     : FORTRAN 77
  11 : C ADAPTATION  :  Stéphane GOUNAND (CEA/DRN/DMT/SEMT/LTMF)
  12 : C                mél : gounand@semt2.smts.cea.fr
  13 : C AUTEUR      :
  14 : C  Sparskit : a basic tool kit for sparse matrix computations
  15 : C  Version 2 (Youcef Saad)
  16 : C  -> URL : http://www.cs.umn.edu/Research/arpa/SPARSKIT/sparskit.html
  17 : C
  18 : C***********************************************************************
  19 :       INTEGER NROW,JA(*),IA(NROW+1),JAO(*),IAO(NROW+1),PERM(*), JOB
  20 :       REAL*8 A(*), AO(*) 
  21 : c-----------------------------------------------------------------------
  22 : c this subroutine permutes the columns of a matrix a, ja, ia.
  23 : c the result is written in the output matrix  ao, jao, iao.
  24 : c cperm computes B = A P, where  P is a permutation matrix
  25 : c that maps column j into column perm(j), i.e., on return 
  26 : c      a(i,j) becomes a(i,perm(j)) in new matrix 
  27 : c Y. Saad, May 2, 1990 / modified Jan. 28, 1991. 
  28 : c-----------------------------------------------------------------------
  29 : c on entry:
  30 : c----------
  31 : c nrow  = row dimension of the matrix
  32 : c
  33 : c a, ja, ia = input matrix in csr format. 
  34 : c
  35 : c perm  = integer array of length ncol (number of columns of A
  36 : c         containing the permutation array  the columns: 
  37 : c         a(i,j) in the original matrix becomes a(i,perm(j))
  38 : c         in the output matrix.
  39 : c
  40 : c job   = integer indicating the work to be done:
  41 : c               job = 1 permute a, ja, ia into ao, jao, iao 
  42 : c                       (including the copying of real values ao and
  43 : c                       the array iao).
  44 : c               job .ne. 1 :  ignore real values ao and ignore iao.
  45 : c
  46 : c------------
  47 : c on return: 
  48 : c------------ 
  49 : c ao, jao, iao = input matrix in a, ja, ia format (array ao not needed)
  50 : c
  51 : c Notes:
  52 : c------- 
  53 : c 1. if job=1 then ao, iao are not used.
  54 : c 2. This routine is in place: ja, jao can be the same. 
  55 : c 3. If the matrix is initially sorted (by increasing column number) 
  56 : c    then ao,jao,iao  may not be on return. 
  57 : c 
  58 : c----------------------------------------------------------------------c
  59 : c local parameters:
  60 :       INTEGER K, I, NNZ
  61 : c
  62 :       NNZ = IA(NROW+1)-1
  63 :       DO 100 K=1,NNZ
  64 :          JAO(K) = PERM(JA(K)) 
  65 :  100  CONTINUE
  66 : c
  67 : c     done with ja array. return if no need to touch values.
  68 : c
  69 :       IF (JOB .NE. 1) RETURN
  70 : c
  71 : c else get new pointers -- and copy values too.
  72 : c 
  73 :       DO 1 I=1, NROW+1
  74 :          IAO(I) = IA(I)
  75 :  1    CONTINUE
  76 : c
  77 :       DO 2 K=1, NNZ
  78 :          AO(K) = A(K)
  79 :  2    CONTINUE
  80 : c
  81 :       RETURN
  82 : c---------end-of-cperm-------------------------------------------------- 
  83 : c-----------------------------------------------------------------------
  84 :       END
  85 :  
  86 :  

© Cast3M 2003 - All rights reserved.
Disclaimer