ScaLAPACK  2.0.2
ScaLAPACK: Scalable Linear Algebra PACKage
cset.f
Go to the documentation of this file.
00001       SUBROUTINE CSET( N, ALPHA, X, INCX )
00002 *
00003 *  -- PBLAS auxiliary routine (version 2.0) --
00004 *     University of Tennessee, Knoxville, Oak Ridge National Laboratory,
00005 *     and University of California, Berkeley.
00006 *     April 1, 1998
00007 *
00008 *     .. Scalar Arguments ..
00009       INTEGER            INCX, N
00010       COMPLEX            ALPHA
00011 *     ..
00012 *     .. Array Arguments ..
00013       COMPLEX            X( * )
00014 *     ..
00015 *
00016 *  Purpose
00017 *  =======
00018 *
00019 *  CSET sets the entries of an n vector x to the scalar alpha.
00020 *
00021 *  Arguments
00022 *  =========
00023 *
00024 *  N       (input) INTEGER
00025 *          On entry, N specifies the length of the vector x. N  must  be
00026 *          at least zero.
00027 *
00028 *  ALPHA   (input) COMPLEX
00029 *          On entry, ALPHA specifies the scalar alpha.
00030 *
00031 *  X       (input/output) COMPLEX array of dimension at least
00032 *          ( 1 + ( n - 1 )*abs( INCX ) ). Before entry,  the incremented
00033 *          array  X  must  contain the vector x. On exit, entries of the
00034 *          incremented array X are set to alpha.
00035 *
00036 *  INCX    (input) INTEGER
00037 *          On entry, INCX specifies the increment for the elements of X.
00038 *          INCX must not be zero.
00039 *
00040 *  -- Written on April 1, 1998 by
00041 *     Antoine Petitet, University  of  Tennessee, Knoxville 37996, USA.
00042 *
00043 *  =====================================================================
00044 *
00045 *     .. Local Scalars ..
00046       INTEGER            I, INFO, IX, M, MP1
00047 *     ..
00048 *     .. External Subroutines ..
00049       EXTERNAL           XERBLA
00050 *     ..
00051 *     .. Intrinsic Functions ..
00052       INTRINSIC          MOD
00053 *     ..
00054 *     .. Executable Statements ..
00055 *
00056 *     Test the input parameters.
00057 *
00058       INFO = 0
00059       IF( N.LT.0 ) THEN
00060          INFO = 1
00061       ELSE IF( INCX.EQ.0 ) THEN
00062          INFO = 4
00063       END IF
00064       IF( INFO.NE.0 ) THEN
00065          CALL XERBLA( 'CSET', INFO )
00066          RETURN
00067       END IF
00068 *
00069 *     Quick return if possible.
00070 *
00071       IF( N.LE.0 )
00072      $   RETURN
00073 *
00074 *     Form  x := alpha
00075 *
00076       IF( INCX.EQ.1 )
00077      $   GO TO 20
00078 *
00079 *     code for increments not equal to 1
00080 *
00081 *     Set up the start point in  X.
00082 *
00083       IF( INCX.GT.0 ) THEN
00084          IX = 1
00085       ELSE
00086          IX = 1 - ( N - 1 ) * INCX
00087       END IF
00088 *
00089       DO 10 I = 1, N
00090         X( IX ) = ALPHA
00091         IX = IX + INCX
00092    10 CONTINUE
00093 *
00094       RETURN
00095 *
00096 *     code for increment equal to 1
00097 *
00098 *     clean-up loop
00099 *
00100    20 M = MOD( N, 4 )
00101 *
00102       IF( M.EQ.0 )
00103      $   GO TO 40
00104 *
00105       DO 30 I = 1, M
00106         X( I ) = ALPHA
00107    30 CONTINUE
00108       IF( N.LT.4 )
00109      $   RETURN
00110 *
00111    40 MP1 = M + 1
00112       DO 50 I = MP1, N, 4
00113          X( I     ) = ALPHA
00114          X( I + 1 ) = ALPHA
00115          X( I + 2 ) = ALPHA
00116          X( I + 3 ) = ALPHA
00117    50 CONTINUE
00118 *
00119       RETURN
00120 *
00121 *     End of CSET
00122 *
00123       END