C============================================================================== C This subroutine gives the minimal component of the vector A C C Input: C - A : Vector C - N : Number of component of A C C Output: C - IMIN : Index of the minimal component C============================================================================== SUBROUTINE VMIN(N,A,IMIN) DOUBLE PRECISION A(*) C C Local variables C INTEGER I C IMIN = 1 DO I = 2, N IF (A(I).LT.A(IMIN)) IMIN = I ENDDO C END C============================================================================== C This subroutine searchs the component that value is NIDEL C and delete it from the vector NI C C Input: C NI: The vector C N : Size of this vector C NIDEL : Value of the component to delete C============================================================================== SUBROUTINE VDELI(N,NI,NIDEL) INTEGER NI(*) C C Local variables C INTEGER I C I = 1 1 IF (NI(I).EQ.NIDEL) GOTO 10 I = I + 1 GOTO 1 10 IF (I.EQ.N) GOTO 20 I = I + 1 NI(I-1) = NI(I) GOTO 10 20 CONTINUE C END C============================================================================== C This subroutine sorts a vector NI (integer) of size N C in ascending order C C Input: C NI: The vector C N : Size of this vector C C Output: C NI C============================================================================== SUBROUTINE VSORTI(N,NI) INTEGER NI(*) C C Local variables C INTEGER I, J, NITMP C DO I = 1, N - 1 DO J = I + 1, N IF (NI(I).GT.NI(J)) THEN NITMP = NI(I) NI(I) = NI(J) NI(J) = NITMP ENDIF ENDDO ENDDO C END C============================================================================== C This subroutine sorts a vector A of size N in ascending order C of the absolute value of its components. C C Input: C A: The vector (double precision) C N: Size of this vector C Output: C NI: Matrice contain indices of sorted elements C============================================================================== SUBROUTINE VSORT(N,A,NI) DOUBLE PRECISION A(*) INTEGER NI(*) C C Local variables C INTEGER I, J, NITMP C DO I = 1, N NI(I) = I ENDDO DO I = 1, N - 1 DO J = I + 1, N IF (DABS(A(NI(I))).GT.DABS(A(NI(J)))) THEN NITMP = NI(I) NI(I) = NI(J) NI(J) = NITMP ENDIF ENDDO ENDDO C END C============================================================================== C This subroutine gives the maximal component (absolute value) C of the normed vector A C C Input: C - A : Vector (double precision) C - N : Number of component of A C Output: C - IOMAX : Index of the maximal composant C============================================================================== SUBROUTINE VMAXC(N,A,IOMAX) DOUBLE PRECISION A(*) C C Local variables C DOUBLE PRECISION COMAX2, RUNSUM, CO2 INTEGER I C I = 1 IOMAX = I COMAX2 = A(I)**2 RUNSUM = COMAX2 10 IF (COMAX2.GT.(1-RUNSUM)) GOTO 20 IF (I.LT.N) THEN I = I + 1 CO2 = A(I)**2 RUNSUM = RUNSUM + CO2 IF (COMAX2.LT.CO2) THEN COMAX2 = CO2 IOMAX = I ENDIF GOTO 10 ENDIF 20 CONTINUE C END C============================================================================== C This subroutine gives maximals components (absolute value) C of the vector A C C Input: C - A, N: tail of A C - NC : Number of Maximal component C C Output: C - IMAXS : Index of maximals composants C============================================================================== SUBROUTINE VMAXCS(N,A,NC,IMAXS) C DOUBLE PRECISION A(*) INTEGER IMAXS(NC) C C Local variables C INTEGER NI(N), I C CALL VSORT(N,A,NI) DO I = 1, NC IMAXS(I) = NI(N-I+1) ENDDO C END C============================================================================== C This subroutine gives components of the vector A whose C absolute value is greater than a given value (positive) C C Input: C - A, N: tail of A C - GV : Given value C C Output: C - IMAXV : Index of components C - NMAXV : Number of retained components C============================================================================== SUBROUTINE VMAXCV(N,A,GV,NMAXV,IMAXV) C DOUBLE PRECISION A(*),GV INTEGER IMAXV(*) C C Local variables C INTEGER NI(N), I C CALL VSORT(N,A,NI) I = 1 1 IF (A(NI(N-I+1))*A(NI(N-I+1)).GT.GV) THEN IMAXV(I) = NI(N-I+1) I = I + 1 GOTO 1 ENDIF NMAXV = I - 1 C END C============================================================================== C This function calculate the norm of a given vector A of size N C C Input: C - A, N: tail of A C Output: C - AN : Norm of the vector A C============================================================================== SUBROUTINE VNORM(N,A,AN) DOUBLE PRECISION A(*), AN C C Local variables C INTEGER I C AN = 0D0 DO I = 1, N AN = AN + A(I)*A(I) ENDDO C END C============================================================================== C This subroutine normalize a given vector A of size N C C Input: C - A, N: tail of A C C Output: C - AP : Resulted vector C============================================================================== SUBROUTINE VNORMZ(N,A,AP) DOUBLE PRECISION A(*),AP(*) C C Local variables C DOUBLE PRECISION SRANOR, ANORM INTEGER I C CALL VNORM(N,A,ANORM) SRANOR = DSQRT(ANORM) DO I = 1, N AP(I) = A(I)/SRANOR ENDDO C END C============================================================================== C This subroutine take a given vector A of size N, extract NC C biggest components to make another vector AP C C Input: C - A, N: tail of A C - NC : Number of component retained C C Output: C - AP : Resulted vector C============================================================================== SUBROUTINE VCUT(N,A,NC,AP) DOUBLE PRECISION A(*),AP(*) C C Local variables C INTEGER NI(N), I C CALL VMAXCS(N,A,NC,NI) DO I = 1, NC AP(I) = A(NI(I)) ENDDO C END C============================================================================== C This subroutine take a given vector A of size N, extract NC C biggest components to make another vector AP, and then normalize AP C C Input: C - A, N: tail of A C - NC : Number of component retained C C Output: C - AP : Resulted vector C============================================================================== SUBROUTINE VCUTN(N,A,NC,AP) DOUBLE PRECISION A(*),AP(*) C CALL VCUT(N,A,NC,AP) CALL VNORMZ(NC,AP,AP) C END