LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
cgemv.f
Go to the documentation of this file.
00001 *> \brief \b CGEMV
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 CGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
00012 * 
00013 *       .. Scalar Arguments ..
00014 *       COMPLEX ALPHA,BETA
00015 *       INTEGER INCX,INCY,LDA,M,N
00016 *       CHARACTER TRANS
00017 *       ..
00018 *       .. Array Arguments ..
00019 *       COMPLEX A(LDA,*),X(*),Y(*)
00020 *       ..
00021 *  
00022 *
00023 *> \par Purpose:
00024 *  =============
00025 *>
00026 *> \verbatim
00027 *>
00028 *> CGEMV performs one of the matrix-vector operations
00029 *>
00030 *>    y := alpha*A*x + beta*y,   or   y := alpha*A**T*x + beta*y,   or
00031 *>
00032 *>    y := alpha*A**H*x + beta*y,
00033 *>
00034 *> where alpha and beta are scalars, x and y are vectors and A is an
00035 *> m by n matrix.
00036 *> \endverbatim
00037 *
00038 *  Arguments:
00039 *  ==========
00040 *
00041 *> \param[in] TRANS
00042 *> \verbatim
00043 *>          TRANS is CHARACTER*1
00044 *>           On entry, TRANS specifies the operation to be performed as
00045 *>           follows:
00046 *>
00047 *>              TRANS = 'N' or 'n'   y := alpha*A*x + beta*y.
00048 *>
00049 *>              TRANS = 'T' or 't'   y := alpha*A**T*x + beta*y.
00050 *>
00051 *>              TRANS = 'C' or 'c'   y := alpha*A**H*x + beta*y.
00052 *> \endverbatim
00053 *>
00054 *> \param[in] M
00055 *> \verbatim
00056 *>          M is INTEGER
00057 *>           On entry, M specifies the number of rows of the matrix A.
00058 *>           M must be at least zero.
00059 *> \endverbatim
00060 *>
00061 *> \param[in] N
00062 *> \verbatim
00063 *>          N is INTEGER
00064 *>           On entry, N specifies the number of columns of the matrix A.
00065 *>           N must be at least zero.
00066 *> \endverbatim
00067 *>
00068 *> \param[in] ALPHA
00069 *> \verbatim
00070 *>          ALPHA is COMPLEX
00071 *>           On entry, ALPHA specifies the scalar alpha.
00072 *> \endverbatim
00073 *>
00074 *> \param[in] A
00075 *> \verbatim
00076 *>          A is COMPLEX array of DIMENSION ( LDA, n ).
00077 *>           Before entry, the leading m by n part of the array A must
00078 *>           contain the matrix of coefficients.
00079 *> \endverbatim
00080 *>
00081 *> \param[in] LDA
00082 *> \verbatim
00083 *>          LDA is INTEGER
00084 *>           On entry, LDA specifies the first dimension of A as declared
00085 *>           in the calling (sub) program. LDA must be at least
00086 *>           max( 1, m ).
00087 *> \endverbatim
00088 *>
00089 *> \param[in] X
00090 *> \verbatim
00091 *>          X is COMPLEX array of DIMENSION at least
00092 *>           ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
00093 *>           and at least
00094 *>           ( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
00095 *>           Before entry, the incremented array X must contain the
00096 *>           vector x.
00097 *> \endverbatim
00098 *>
00099 *> \param[in] INCX
00100 *> \verbatim
00101 *>          INCX is INTEGER
00102 *>           On entry, INCX specifies the increment for the elements of
00103 *>           X. INCX must not be zero.
00104 *> \endverbatim
00105 *>
00106 *> \param[in] BETA
00107 *> \verbatim
00108 *>          BETA is COMPLEX
00109 *>           On entry, BETA specifies the scalar beta. When BETA is
00110 *>           supplied as zero then Y need not be set on input.
00111 *> \endverbatim
00112 *>
00113 *> \param[in,out] Y
00114 *> \verbatim
00115 *>          Y is COMPLEX array of DIMENSION at least
00116 *>           ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
00117 *>           and at least
00118 *>           ( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
00119 *>           Before entry with BETA non-zero, the incremented array Y
00120 *>           must contain the vector y. On exit, Y is overwritten by the
00121 *>           updated vector y.
00122 *> \endverbatim
00123 *>
00124 *> \param[in] INCY
00125 *> \verbatim
00126 *>          INCY is INTEGER
00127 *>           On entry, INCY specifies the increment for the elements of
00128 *>           Y. INCY must not be zero.
00129 *> \endverbatim
00130 *
00131 *  Authors:
00132 *  ========
00133 *
00134 *> \author Univ. of Tennessee 
00135 *> \author Univ. of California Berkeley 
00136 *> \author Univ. of Colorado Denver 
00137 *> \author NAG Ltd. 
00138 *
00139 *> \date November 2011
00140 *
00141 *> \ingroup complex_blas_level2
00142 *
00143 *> \par Further Details:
00144 *  =====================
00145 *>
00146 *> \verbatim
00147 *>
00148 *>  Level 2 Blas routine.
00149 *>  The vector and matrix arguments are not referenced when N = 0, or M = 0
00150 *>
00151 *>  -- Written on 22-October-1986.
00152 *>     Jack Dongarra, Argonne National Lab.
00153 *>     Jeremy Du Croz, Nag Central Office.
00154 *>     Sven Hammarling, Nag Central Office.
00155 *>     Richard Hanson, Sandia National Labs.
00156 *> \endverbatim
00157 *>
00158 *  =====================================================================
00159       SUBROUTINE CGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
00160 *
00161 *  -- Reference BLAS level2 routine (version 3.4.0) --
00162 *  -- Reference BLAS is a software package provided by Univ. of Tennessee,    --
00163 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00164 *     November 2011
00165 *
00166 *     .. Scalar Arguments ..
00167       COMPLEX ALPHA,BETA
00168       INTEGER INCX,INCY,LDA,M,N
00169       CHARACTER TRANS
00170 *     ..
00171 *     .. Array Arguments ..
00172       COMPLEX A(LDA,*),X(*),Y(*)
00173 *     ..
00174 *
00175 *  =====================================================================
00176 *
00177 *     .. Parameters ..
00178       COMPLEX ONE
00179       PARAMETER (ONE= (1.0E+0,0.0E+0))
00180       COMPLEX ZERO
00181       PARAMETER (ZERO= (0.0E+0,0.0E+0))
00182 *     ..
00183 *     .. Local Scalars ..
00184       COMPLEX TEMP
00185       INTEGER I,INFO,IX,IY,J,JX,JY,KX,KY,LENX,LENY
00186       LOGICAL NOCONJ
00187 *     ..
00188 *     .. External Functions ..
00189       LOGICAL LSAME
00190       EXTERNAL LSAME
00191 *     ..
00192 *     .. External Subroutines ..
00193       EXTERNAL XERBLA
00194 *     ..
00195 *     .. Intrinsic Functions ..
00196       INTRINSIC CONJG,MAX
00197 *     ..
00198 *
00199 *     Test the input parameters.
00200 *
00201       INFO = 0
00202       IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND.
00203      +    .NOT.LSAME(TRANS,'C')) THEN
00204           INFO = 1
00205       ELSE IF (M.LT.0) THEN
00206           INFO = 2
00207       ELSE IF (N.LT.0) THEN
00208           INFO = 3
00209       ELSE IF (LDA.LT.MAX(1,M)) THEN
00210           INFO = 6
00211       ELSE IF (INCX.EQ.0) THEN
00212           INFO = 8
00213       ELSE IF (INCY.EQ.0) THEN
00214           INFO = 11
00215       END IF
00216       IF (INFO.NE.0) THEN
00217           CALL XERBLA('CGEMV ',INFO)
00218           RETURN
00219       END IF
00220 *
00221 *     Quick return if possible.
00222 *
00223       IF ((M.EQ.0) .OR. (N.EQ.0) .OR.
00224      +    ((ALPHA.EQ.ZERO).AND. (BETA.EQ.ONE))) RETURN
00225 *
00226       NOCONJ = LSAME(TRANS,'T')
00227 *
00228 *     Set  LENX  and  LENY, the lengths of the vectors x and y, and set
00229 *     up the start points in  X  and  Y.
00230 *
00231       IF (LSAME(TRANS,'N')) THEN
00232           LENX = N
00233           LENY = M
00234       ELSE
00235           LENX = M
00236           LENY = N
00237       END IF
00238       IF (INCX.GT.0) THEN
00239           KX = 1
00240       ELSE
00241           KX = 1 - (LENX-1)*INCX
00242       END IF
00243       IF (INCY.GT.0) THEN
00244           KY = 1
00245       ELSE
00246           KY = 1 - (LENY-1)*INCY
00247       END IF
00248 *
00249 *     Start the operations. In this version the elements of A are
00250 *     accessed sequentially with one pass through A.
00251 *
00252 *     First form  y := beta*y.
00253 *
00254       IF (BETA.NE.ONE) THEN
00255           IF (INCY.EQ.1) THEN
00256               IF (BETA.EQ.ZERO) THEN
00257                   DO 10 I = 1,LENY
00258                       Y(I) = ZERO
00259    10             CONTINUE
00260               ELSE
00261                   DO 20 I = 1,LENY
00262                       Y(I) = BETA*Y(I)
00263    20             CONTINUE
00264               END IF
00265           ELSE
00266               IY = KY
00267               IF (BETA.EQ.ZERO) THEN
00268                   DO 30 I = 1,LENY
00269                       Y(IY) = ZERO
00270                       IY = IY + INCY
00271    30             CONTINUE
00272               ELSE
00273                   DO 40 I = 1,LENY
00274                       Y(IY) = BETA*Y(IY)
00275                       IY = IY + INCY
00276    40             CONTINUE
00277               END IF
00278           END IF
00279       END IF
00280       IF (ALPHA.EQ.ZERO) RETURN
00281       IF (LSAME(TRANS,'N')) THEN
00282 *
00283 *        Form  y := alpha*A*x + y.
00284 *
00285           JX = KX
00286           IF (INCY.EQ.1) THEN
00287               DO 60 J = 1,N
00288                   IF (X(JX).NE.ZERO) THEN
00289                       TEMP = ALPHA*X(JX)
00290                       DO 50 I = 1,M
00291                           Y(I) = Y(I) + TEMP*A(I,J)
00292    50                 CONTINUE
00293                   END IF
00294                   JX = JX + INCX
00295    60         CONTINUE
00296           ELSE
00297               DO 80 J = 1,N
00298                   IF (X(JX).NE.ZERO) THEN
00299                       TEMP = ALPHA*X(JX)
00300                       IY = KY
00301                       DO 70 I = 1,M
00302                           Y(IY) = Y(IY) + TEMP*A(I,J)
00303                           IY = IY + INCY
00304    70                 CONTINUE
00305                   END IF
00306                   JX = JX + INCX
00307    80         CONTINUE
00308           END IF
00309       ELSE
00310 *
00311 *        Form  y := alpha*A**T*x + y  or  y := alpha*A**H*x + y.
00312 *
00313           JY = KY
00314           IF (INCX.EQ.1) THEN
00315               DO 110 J = 1,N
00316                   TEMP = ZERO
00317                   IF (NOCONJ) THEN
00318                       DO 90 I = 1,M
00319                           TEMP = TEMP + A(I,J)*X(I)
00320    90                 CONTINUE
00321                   ELSE
00322                       DO 100 I = 1,M
00323                           TEMP = TEMP + CONJG(A(I,J))*X(I)
00324   100                 CONTINUE
00325                   END IF
00326                   Y(JY) = Y(JY) + ALPHA*TEMP
00327                   JY = JY + INCY
00328   110         CONTINUE
00329           ELSE
00330               DO 140 J = 1,N
00331                   TEMP = ZERO
00332                   IX = KX
00333                   IF (NOCONJ) THEN
00334                       DO 120 I = 1,M
00335                           TEMP = TEMP + A(I,J)*X(IX)
00336                           IX = IX + INCX
00337   120                 CONTINUE
00338                   ELSE
00339                       DO 130 I = 1,M
00340                           TEMP = TEMP + CONJG(A(I,J))*X(IX)
00341                           IX = IX + INCX
00342   130                 CONTINUE
00343                   END IF
00344                   Y(JY) = Y(JY) + ALPHA*TEMP
00345                   JY = JY + INCY
00346   140         CONTINUE
00347           END IF
00348       END IF
00349 *
00350       RETURN
00351 *
00352 *     End of CGEMV .
00353 *
00354       END
 All Files Functions