root / src / lapack / double / dlamrg.f @ 2
Historique | Voir | Annoter | Télécharger (2,8 ko)
| 1 | 1 | pfleura2 | SUBROUTINE DLAMRG( N1, N2, A, DTRD1, DTRD2, INDEX ) |
|---|---|---|---|
| 2 | 1 | pfleura2 | * |
| 3 | 1 | pfleura2 | * -- LAPACK routine (version 3.2) -- |
| 4 | 1 | pfleura2 | * -- LAPACK is a software package provided by Univ. of Tennessee, -- |
| 5 | 1 | pfleura2 | * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- |
| 6 | 1 | pfleura2 | * November 2006 |
| 7 | 1 | pfleura2 | * |
| 8 | 1 | pfleura2 | * .. Scalar Arguments .. |
| 9 | 1 | pfleura2 | INTEGER DTRD1, DTRD2, N1, N2 |
| 10 | 1 | pfleura2 | * .. |
| 11 | 1 | pfleura2 | * .. Array Arguments .. |
| 12 | 1 | pfleura2 | INTEGER INDEX( * ) |
| 13 | 1 | pfleura2 | DOUBLE PRECISION A( * ) |
| 14 | 1 | pfleura2 | * .. |
| 15 | 1 | pfleura2 | * |
| 16 | 1 | pfleura2 | * Purpose |
| 17 | 1 | pfleura2 | * ======= |
| 18 | 1 | pfleura2 | * |
| 19 | 1 | pfleura2 | * DLAMRG will create a permutation list which will merge the elements |
| 20 | 1 | pfleura2 | * of A (which is composed of two independently sorted sets) into a |
| 21 | 1 | pfleura2 | * single set which is sorted in ascending order. |
| 22 | 1 | pfleura2 | * |
| 23 | 1 | pfleura2 | * Arguments |
| 24 | 1 | pfleura2 | * ========= |
| 25 | 1 | pfleura2 | * |
| 26 | 1 | pfleura2 | * N1 (input) INTEGER |
| 27 | 1 | pfleura2 | * N2 (input) INTEGER |
| 28 | 1 | pfleura2 | * These arguements contain the respective lengths of the two |
| 29 | 1 | pfleura2 | * sorted lists to be merged. |
| 30 | 1 | pfleura2 | * |
| 31 | 1 | pfleura2 | * A (input) DOUBLE PRECISION array, dimension (N1+N2) |
| 32 | 1 | pfleura2 | * The first N1 elements of A contain a list of numbers which |
| 33 | 1 | pfleura2 | * are sorted in either ascending or descending order. Likewise |
| 34 | 1 | pfleura2 | * for the final N2 elements. |
| 35 | 1 | pfleura2 | * |
| 36 | 1 | pfleura2 | * DTRD1 (input) INTEGER |
| 37 | 1 | pfleura2 | * DTRD2 (input) INTEGER |
| 38 | 1 | pfleura2 | * These are the strides to be taken through the array A. |
| 39 | 1 | pfleura2 | * Allowable strides are 1 and -1. They indicate whether a |
| 40 | 1 | pfleura2 | * subset of A is sorted in ascending (DTRDx = 1) or descending |
| 41 | 1 | pfleura2 | * (DTRDx = -1) order. |
| 42 | 1 | pfleura2 | * |
| 43 | 1 | pfleura2 | * INDEX (output) INTEGER array, dimension (N1+N2) |
| 44 | 1 | pfleura2 | * On exit this array will contain a permutation such that |
| 45 | 1 | pfleura2 | * if B( I ) = A( INDEX( I ) ) for I=1,N1+N2, then B will be |
| 46 | 1 | pfleura2 | * sorted in ascending order. |
| 47 | 1 | pfleura2 | * |
| 48 | 1 | pfleura2 | * ===================================================================== |
| 49 | 1 | pfleura2 | * |
| 50 | 1 | pfleura2 | * .. Local Scalars .. |
| 51 | 1 | pfleura2 | INTEGER I, IND1, IND2, N1SV, N2SV |
| 52 | 1 | pfleura2 | * .. |
| 53 | 1 | pfleura2 | * .. Executable Statements .. |
| 54 | 1 | pfleura2 | * |
| 55 | 1 | pfleura2 | N1SV = N1 |
| 56 | 1 | pfleura2 | N2SV = N2 |
| 57 | 1 | pfleura2 | IF( DTRD1.GT.0 ) THEN |
| 58 | 1 | pfleura2 | IND1 = 1 |
| 59 | 1 | pfleura2 | ELSE |
| 60 | 1 | pfleura2 | IND1 = N1 |
| 61 | 1 | pfleura2 | END IF |
| 62 | 1 | pfleura2 | IF( DTRD2.GT.0 ) THEN |
| 63 | 1 | pfleura2 | IND2 = 1 + N1 |
| 64 | 1 | pfleura2 | ELSE |
| 65 | 1 | pfleura2 | IND2 = N1 + N2 |
| 66 | 1 | pfleura2 | END IF |
| 67 | 1 | pfleura2 | I = 1 |
| 68 | 1 | pfleura2 | * while ( (N1SV > 0) & (N2SV > 0) ) |
| 69 | 1 | pfleura2 | 10 CONTINUE |
| 70 | 1 | pfleura2 | IF( N1SV.GT.0 .AND. N2SV.GT.0 ) THEN |
| 71 | 1 | pfleura2 | IF( A( IND1 ).LE.A( IND2 ) ) THEN |
| 72 | 1 | pfleura2 | INDEX( I ) = IND1 |
| 73 | 1 | pfleura2 | I = I + 1 |
| 74 | 1 | pfleura2 | IND1 = IND1 + DTRD1 |
| 75 | 1 | pfleura2 | N1SV = N1SV - 1 |
| 76 | 1 | pfleura2 | ELSE |
| 77 | 1 | pfleura2 | INDEX( I ) = IND2 |
| 78 | 1 | pfleura2 | I = I + 1 |
| 79 | 1 | pfleura2 | IND2 = IND2 + DTRD2 |
| 80 | 1 | pfleura2 | N2SV = N2SV - 1 |
| 81 | 1 | pfleura2 | END IF |
| 82 | 1 | pfleura2 | GO TO 10 |
| 83 | 1 | pfleura2 | END IF |
| 84 | 1 | pfleura2 | * end while |
| 85 | 1 | pfleura2 | IF( N1SV.EQ.0 ) THEN |
| 86 | 1 | pfleura2 | DO 20 N1SV = 1, N2SV |
| 87 | 1 | pfleura2 | INDEX( I ) = IND2 |
| 88 | 1 | pfleura2 | I = I + 1 |
| 89 | 1 | pfleura2 | IND2 = IND2 + DTRD2 |
| 90 | 1 | pfleura2 | 20 CONTINUE |
| 91 | 1 | pfleura2 | ELSE |
| 92 | 1 | pfleura2 | * N2SV .EQ. 0 |
| 93 | 1 | pfleura2 | DO 30 N2SV = 1, N1SV |
| 94 | 1 | pfleura2 | INDEX( I ) = IND1 |
| 95 | 1 | pfleura2 | I = I + 1 |
| 96 | 1 | pfleura2 | IND1 = IND1 + DTRD1 |
| 97 | 1 | pfleura2 | 30 CONTINUE |
| 98 | 1 | pfleura2 | END IF |
| 99 | 1 | pfleura2 | * |
| 100 | 1 | pfleura2 | RETURN |
| 101 | 1 | pfleura2 | * |
| 102 | 1 | pfleura2 | * End of DLAMRG |
| 103 | 1 | pfleura2 | * |
| 104 | 1 | pfleura2 | END |