LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
slatm7.f
Go to the documentation of this file.
00001 *> \brief \b SLATM7
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *  Definition:
00009 *  ===========
00010 *
00011 *       SUBROUTINE SLATM7( MODE, COND, IRSIGN, IDIST, ISEED, D, N,
00012 *                          RANK, INFO )
00013 * 
00014 *       .. Scalar Arguments ..
00015 *       REAL               COND
00016 *       INTEGER            IDIST, INFO, IRSIGN, MODE, N, RANK
00017 *       ..
00018 *       .. Array Arguments ..
00019 *       REAL               D( * )
00020 *       INTEGER            ISEED( 4 )
00021 *       ..
00022 *  
00023 *
00024 *> \par Purpose:
00025 *  =============
00026 *>
00027 *> \verbatim
00028 *>
00029 *>    SLATM7 computes the entries of D as specified by MODE
00030 *>    COND and IRSIGN. IDIST and ISEED determine the generation
00031 *>    of random numbers. SLATM7 is called by SLATMT to generate
00032 *>    random test matrices.
00033 *> \endverbatim
00034 *
00035 *  Arguments:
00036 *  ==========
00037 *
00038 *> \verbatim
00039 *>  MODE   - INTEGER
00040 *>           On entry describes how D is to be computed:
00041 *>           MODE = 0 means do not change D.
00042 *>
00043 *>           MODE = 1 sets D(1)=1 and D(2:RANK)=1.0/COND
00044 *>           MODE = 2 sets D(1:RANK-1)=1 and D(RANK)=1.0/COND
00045 *>           MODE = 3 sets D(I)=COND**(-(I-1)/(RANK-1)) I=1:RANK
00046 *>
00047 *>           MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND)
00048 *>           MODE = 5 sets D to random numbers in the range
00049 *>                    ( 1/COND , 1 ) such that their logarithms
00050 *>                    are uniformly distributed.
00051 *>           MODE = 6 set D to random numbers from same distribution
00052 *>                    as the rest of the matrix.
00053 *>           MODE < 0 has the same meaning as ABS(MODE), except that
00054 *>              the order of the elements of D is reversed.
00055 *>           Thus if MODE is positive, D has entries ranging from
00056 *>              1 to 1/COND, if negative, from 1/COND to 1,
00057 *>           Not modified.
00058 *>
00059 *>  COND   - REAL
00060 *>           On entry, used as described under MODE above.
00061 *>           If used, it must be >= 1. Not modified.
00062 *>
00063 *>  IRSIGN - INTEGER
00064 *>           On entry, if MODE neither -6, 0 nor 6, determines sign of
00065 *>           entries of D
00066 *>           0 => leave entries of D unchanged
00067 *>           1 => multiply each entry of D by 1 or -1 with probability .5
00068 *>
00069 *>  IDIST  - CHARACTER*1
00070 *>           On entry, IDIST specifies the type of distribution to be
00071 *>           used to generate a random matrix .
00072 *>           1 => UNIFORM( 0, 1 )
00073 *>           2 => UNIFORM( -1, 1 )
00074 *>           3 => NORMAL( 0, 1 )
00075 *>           Not modified.
00076 *>
00077 *>  ISEED  - INTEGER array, dimension ( 4 )
00078 *>           On entry ISEED specifies the seed of the random number
00079 *>           generator. The random number generator uses a
00080 *>           linear congruential sequence limited to small
00081 *>           integers, and so should produce machine independent
00082 *>           random numbers. The values of ISEED are changed on
00083 *>           exit, and can be used in the next call to SLATM7
00084 *>           to continue the same random number sequence.
00085 *>           Changed on exit.
00086 *>
00087 *>  D      - REAL array, dimension ( MIN( M , N ) )
00088 *>           Array to be computed according to MODE, COND and IRSIGN.
00089 *>           May be changed on exit if MODE is nonzero.
00090 *>
00091 *>  N      - INTEGER
00092 *>           Number of entries of D. Not modified.
00093 *>
00094 *>  RANK   - INTEGER
00095 *>           The rank of matrix to be generated for modes 1,2,3 only.
00096 *>           D( RANK+1:N ) = 0.
00097 *>           Not modified.
00098 *>
00099 *>  INFO   - INTEGER
00100 *>            0  => normal termination
00101 *>           -1  => if MODE not in range -6 to 6
00102 *>           -2  => if MODE neither -6, 0 nor 6, and
00103 *>                  IRSIGN neither 0 nor 1
00104 *>           -3  => if MODE neither -6, 0 nor 6 and COND less than 1
00105 *>           -4  => if MODE equals 6 or -6 and IDIST not in range 1 to 3
00106 *>           -7  => if N negative
00107 *> \endverbatim
00108 *
00109 *  Authors:
00110 *  ========
00111 *
00112 *> \author Univ. of Tennessee 
00113 *> \author Univ. of California Berkeley 
00114 *> \author Univ. of Colorado Denver 
00115 *> \author NAG Ltd. 
00116 *
00117 *> \date November 2011
00118 *
00119 *> \ingroup real_matgen
00120 *
00121 *  =====================================================================
00122       SUBROUTINE SLATM7( MODE, COND, IRSIGN, IDIST, ISEED, D, N,
00123      $                   RANK, INFO )
00124 *
00125 *  -- LAPACK computational routine (version 3.4.0) --
00126 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00127 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00128 *     November 2011
00129 *
00130 *     .. Scalar Arguments ..
00131       REAL               COND
00132       INTEGER            IDIST, INFO, IRSIGN, MODE, N, RANK
00133 *     ..
00134 *     .. Array Arguments ..
00135       REAL               D( * )
00136       INTEGER            ISEED( 4 )
00137 *     ..
00138 *
00139 *  =====================================================================
00140 *
00141 *     .. Parameters ..
00142       REAL               ONE
00143       PARAMETER          ( ONE = 1.0E0 )
00144       REAL               ZERO
00145       PARAMETER          ( ZERO = 0.0E0 )
00146       REAL               HALF
00147       PARAMETER          ( HALF = 0.5E0 )
00148 *     ..
00149 *     .. Local Scalars ..
00150       REAL               ALPHA, TEMP
00151       INTEGER            I
00152 *     ..
00153 *     .. External Functions ..
00154       REAL               SLARAN
00155       EXTERNAL           SLARAN
00156 *     ..
00157 *     .. External Subroutines ..
00158       EXTERNAL           SLARNV, XERBLA
00159 *     ..
00160 *     .. Intrinsic Functions ..
00161       INTRINSIC          ABS, EXP, LOG, REAL
00162 *     ..
00163 *     .. Executable Statements ..
00164 *
00165 *     Decode and Test the input parameters. Initialize flags & seed.
00166 *
00167       INFO = 0
00168 *
00169 *     Quick return if possible
00170 *
00171       IF( N.EQ.0 )
00172      $   RETURN
00173 *
00174 *     Set INFO if an error
00175 *
00176       IF( MODE.LT.-6 .OR. MODE.GT.6 ) THEN
00177          INFO = -1
00178       ELSE IF( ( MODE.NE.-6 .AND. MODE.NE.0 .AND. MODE.NE.6 ) .AND.
00179      $         ( IRSIGN.NE.0 .AND. IRSIGN.NE.1 ) ) THEN
00180          INFO = -2
00181       ELSE IF( ( MODE.NE.-6 .AND. MODE.NE.0 .AND. MODE.NE.6 ) .AND.
00182      $         COND.LT.ONE ) THEN
00183          INFO = -3
00184       ELSE IF( ( MODE.EQ.6 .OR. MODE.EQ.-6 ) .AND.
00185      $         ( IDIST.LT.1 .OR. IDIST.GT.3 ) ) THEN
00186          INFO = -4
00187       ELSE IF( N.LT.0 ) THEN
00188          INFO = -7
00189       END IF
00190 *
00191       IF( INFO.NE.0 ) THEN
00192          CALL XERBLA( 'SLATM7', -INFO )
00193          RETURN
00194       END IF
00195 *
00196 *     Compute D according to COND and MODE
00197 *
00198       IF( MODE.NE.0 ) THEN
00199          GO TO ( 100, 130, 160, 190, 210, 230 )ABS( MODE )
00200 *
00201 *        One large D value:
00202 *
00203   100    CONTINUE
00204          DO 110 I = 2, RANK
00205             D( I ) = ONE / COND
00206   110    CONTINUE
00207          DO 120 I = RANK + 1, N
00208             D( I ) = ZERO
00209   120    CONTINUE
00210          D( 1 ) = ONE
00211          GO TO 240
00212 *
00213 *        One small D value:
00214 *
00215   130    CONTINUE
00216          DO 140 I = 1, RANK - 1
00217             D( I ) = ONE
00218   140    CONTINUE
00219          DO 150 I = RANK + 1, N
00220             D( I ) = ZERO
00221   150    CONTINUE
00222          D( RANK ) = ONE / COND
00223          GO TO 240
00224 *
00225 *        Exponentially distributed D values:
00226 *
00227   160    CONTINUE
00228          D( 1 ) = ONE
00229          IF( N.GT.1 ) THEN
00230             ALPHA = COND**( -ONE / REAL( RANK-1 ) )
00231             DO 170 I = 2, RANK
00232                D( I ) = ALPHA**( I-1 )
00233   170       CONTINUE
00234             DO 180 I = RANK + 1, N
00235                D( I ) = ZERO
00236   180       CONTINUE
00237          END IF
00238          GO TO 240
00239 *
00240 *        Arithmetically distributed D values:
00241 *
00242   190    CONTINUE
00243          D( 1 ) = ONE
00244          IF( N.GT.1 ) THEN
00245             TEMP = ONE / COND
00246             ALPHA = ( ONE-TEMP ) / REAL( N-1 )
00247             DO 200 I = 2, N
00248                D( I ) = REAL( N-I )*ALPHA + TEMP
00249   200       CONTINUE
00250          END IF
00251          GO TO 240
00252 *
00253 *        Randomly distributed D values on ( 1/COND , 1):
00254 *
00255   210    CONTINUE
00256          ALPHA = LOG( ONE / COND )
00257          DO 220 I = 1, N
00258             D( I ) = EXP( ALPHA*SLARAN( ISEED ) )
00259   220    CONTINUE
00260          GO TO 240
00261 *
00262 *        Randomly distributed D values from IDIST
00263 *
00264   230    CONTINUE
00265          CALL SLARNV( IDIST, ISEED, N, D )
00266 *
00267   240    CONTINUE
00268 *
00269 *        If MODE neither -6 nor 0 nor 6, and IRSIGN = 1, assign
00270 *        random signs to D
00271 *
00272          IF( ( MODE.NE.-6 .AND. MODE.NE.0 .AND. MODE.NE.6 ) .AND.
00273      $       IRSIGN.EQ.1 ) THEN
00274             DO 250 I = 1, N
00275                TEMP = SLARAN( ISEED )
00276                IF( TEMP.GT.HALF )
00277      $            D( I ) = -D( I )
00278   250       CONTINUE
00279          END IF
00280 *
00281 *        Reverse if MODE < 0
00282 *
00283          IF( MODE.LT.0 ) THEN
00284             DO 260 I = 1, N / 2
00285                TEMP = D( I )
00286                D( I ) = D( N+1-I )
00287                D( N+1-I ) = TEMP
00288   260       CONTINUE
00289          END IF
00290 *
00291       END IF
00292 *
00293       RETURN
00294 *
00295 *     End of SLATM7
00296 *
00297       END
 All Files Functions