ctpmv Subroutine

public subroutine ctpmv(uplo, trans, diag, n, ap, x, incx)

NAME

ctpmv(3f) - [BLAS:COMPLEX_BLAS_LEVEL2]

CX := A*CX, A is a packed triangular band matrix.

SYNOPSIS

 subroutine ctpmv(uplo,trans,diag,n,ap,x,incx)

   .. Scalar Arguments ..
   integer,intent(in)    :: incx,n
   character,intent(in)  :: diag,trans,uplo
   ..
   .. Array Arguments ..
   complex,intent(in)    :: ap(*)
   complex,intent(inout) :: x(*)
   ..

DEFINITION

CTPMV performs one of the matrix-vector operations

 x := A*x,   or   x := A**T*x,   or   x := A**H*x,

where x is an n element vector and A is an n by n unit, or non-unit, upper or lower triangular matrix, supplied in packed form.

OPTIONS

UPLO

       UPLO is CHARACTER*1
        On entry, UPLO specifies whether the matrix is an upper or
        lower triangular matrix as follows:

           UPLO = 'U' or 'u'   A is an upper triangular matrix.

           UPLO = 'L' or 'l'   A is a lower triangular matrix.

TRANS

       TRANS is CHARACTER*1
        On entry, TRANS specifies the operation to be performed as
        follows:

           TRANS = 'N' or 'n'   x := A*x.

           TRANS = 'T' or 't'   x := A**T*x.

           TRANS = 'C' or 'c'   x := A**H*x.

DIAG

       DIAG is CHARACTER*1
        On entry, DIAG specifies whether or not A is unit
        triangular as follows:

           DIAG = 'U' or 'u'   A is assumed to be unit triangular.

           DIAG = 'N' or 'n'   A is not assumed to be unit
                               triangular.

N

       N is INTEGER
        On entry, N specifies the order of the matrix A.
        N must be at least zero.

AP

       AP is COMPLEX array, dimension at least
        ( ( n*( n + 1 ) )/2 ).
        Before entry with UPLO = 'U' or 'u', the array AP must
        contain the upper triangular matrix packed sequentially,
        column by column, so that AP( 1 ) contains a( 1, 1 ),
        AP( 2 ) and AP( 3 ) contain a( 1, 2 ) and a( 2, 2 )
        respectively, and so on.
        Before entry with UPLO = 'L' or 'l', the array AP must
        contain the lower triangular matrix packed sequentially,
        column by column, so that AP( 1 ) contains a( 1, 1 ),
        AP( 2 ) and AP( 3 ) contain a( 2, 1 ) and a( 3, 1 )
        respectively, and so on.
        Note that when DIAG = 'U' or 'u', the diagonal elements of
        A are not referenced, but are assumed to be unity.

X

       X is COMPLEX array, dimension at least
        ( 1 + ( n - 1 )*abs( INCX ) ).
        Before entry, the incremented array X must contain the n
        element vector x. On exit, X is overwritten with the
        transformed vector x.

INCX

       INCX is INTEGER
        On entry, INCX specifies the increment for the elements of
        X. INCX must not be zero.

AUTHORS

  • Univ. of Tennessee
  • Univ. of California Berkeley
  • Univ. of Colorado Denver
  • NAG Ltd.

date:December 2016

FURTHER DETAILS

Level 2 Blas routine. The vector and matrix arguments are not referenced when N = 0, or M = 0

– Written on 22-October-1986. Jack Dongarra, Argonne National Lab. Jeremy Du Croz, Nag Central Office. Sven Hammarling, Nag Central Office. Richard Hanson, Sandia National Labs.

SEE ALSO

Online html documentation available at
http://www.netlib.org/lapack/explore-html/

Arguments

Type IntentOptional Attributes Name
character(len=1), intent(in) :: uplo
character(len=1), intent(in) :: trans
character(len=1), intent(in) :: diag
integer, intent(in) :: n
complex, intent(in) :: ap(*)
complex, intent(inout) :: x(*)
integer, intent(in) :: incx

Contents

Source Code


Variables

Type Visibility Attributes Name Initial
integer, public :: i
integer, public :: info
integer, public :: ix
integer, public :: j
integer, public :: jx
integer, public :: k
integer, public :: kk
integer, public :: kx
logical, public :: noconj
logical, public :: nounit
complex, public :: temp
complex, public, parameter :: zero = (0.0e+0,0.0e+0)

Source Code

       subroutine ctpmv(uplo,trans,diag,n,ap,x,incx)
      implicit none
!
!  -- Reference BLAS level2 routine (version 3.7.0) --
!  -- Reference BLAS is a software package provided by Univ. of Tennessee,    --
!  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
!     December 2016
!
!     .. Scalar Arguments ..
      integer,intent(in)    :: incx,n
      character,intent(in)  :: diag,trans,uplo
!     ..
!     .. Array Arguments ..
      complex,intent(in)    :: ap(*)
      complex,intent(inout) :: x(*)
!     ..
!
!  =====================================================================
!
!     .. Parameters ..
      complex zero
      parameter (zero= (0.0e+0,0.0e+0))
!     ..
!     .. Local Scalars ..
      complex temp
      integer i,info,ix,j,jx,k,kk,kx
      logical noconj,nounit
!     ..
!     .. External Functions ..
!     ..
!     .. External Subroutines ..
!     ..
!     .. Intrinsic Functions ..
      intrinsic conjg
!     ..
!
!     Test the input parameters.
!
      info = 0
      if (.not.lsame(uplo,'U') .and. .not.lsame(uplo,'L')) then
          info = 1
      elseif (.not.lsame(trans,'N') .and. .not.lsame(trans,'T') .and.  .not.lsame(trans,'C')) then
          info = 2
      elseif (.not.lsame(diag,'U') .and. .not.lsame(diag,'N')) then
          info = 3
      elseif (n.lt.0) then
          info = 4
      elseif (incx.eq.0) then
          info = 7
      endif
      if (info.ne.0) then
          call xerbla('CTPMV ',info)
          return
      endif
!
!     Quick return if possible.
!
      if (n.eq.0) return
!
      noconj = lsame(trans,'T')
      nounit = lsame(diag,'N')
!
!     Set up the start point in X if the increment is not unity. This
!     will be  ( N - 1 )*INCX  too small for descending loops.
!
      if (incx.le.0) then
          kx = 1 - (n-1)*incx
      elseif (incx.ne.1) then
          kx = 1
      endif
!
!     Start the operations. In this version the elements of AP are
!     accessed sequentially with one pass through AP.
!
      if (lsame(trans,'N')) then
!
!        Form  x:= A*x.
!
          if (lsame(uplo,'U')) then
              kk = 1
              if (incx.eq.1) then
                  do j = 1,n
                      if (x(j).ne.zero) then
                          temp = x(j)
                          k = kk
                          do i = 1,j - 1
                              x(i) = x(i) + temp*ap(k)
                              k = k + 1
                          enddo
                          if (nounit) x(j) = x(j)*ap(kk+j-1)
                      endif
                      kk = kk + j
                  enddo
              else
                  jx = kx
                  do j = 1,n
                      if (x(jx).ne.zero) then
                          temp = x(jx)
                          ix = kx
                          do k = kk,kk + j - 2
                              x(ix) = x(ix) + temp*ap(k)
                              ix = ix + incx
                          enddo
                          if (nounit) x(jx) = x(jx)*ap(kk+j-1)
                      endif
                      jx = jx + incx
                      kk = kk + j
                  enddo
              endif
          else
              kk = (n* (n+1))/2
              if (incx.eq.1) then
                  do j = n,1,-1
                      if (x(j).ne.zero) then
                          temp = x(j)
                          k = kk
                          do i = n,j + 1,-1
                              x(i) = x(i) + temp*ap(k)
                              k = k - 1
                          enddo
                          if (nounit) x(j) = x(j)*ap(kk-n+j)
                      endif
                      kk = kk - (n-j+1)
                  enddo
              else
                  kx = kx + (n-1)*incx
                  jx = kx
                  do j = n,1,-1
                      if (x(jx).ne.zero) then
                          temp = x(jx)
                          ix = kx
                          do k = kk,kk - (n- (j+1)),-1
                              x(ix) = x(ix) + temp*ap(k)
                              ix = ix - incx
                          enddo
                          if (nounit) x(jx) = x(jx)*ap(kk-n+j)
                      endif
                      jx = jx - incx
                      kk = kk - (n-j+1)
                  enddo
              endif
          endif
      else
!
!        Form  x := A**T*x  or  x := A**H*x.
!
          if (lsame(uplo,'U')) then
              kk = (n* (n+1))/2
              if (incx.eq.1) then
                  do j = n,1,-1
                      temp = x(j)
                      k = kk - 1
                      if (noconj) then
                          if (nounit) temp = temp*ap(kk)
                          do i = j - 1,1,-1
                              temp = temp + ap(k)*x(i)
                              k = k - 1
                          enddo
                      else
                          if (nounit) temp = temp*conjg(ap(kk))
                          do i = j - 1,1,-1
                              temp = temp + conjg(ap(k))*x(i)
                              k = k - 1
                          enddo
                      endif
                      x(j) = temp
                      kk = kk - j
                  enddo
              else
                  jx = kx + (n-1)*incx
                  do j = n,1,-1
                      temp = x(jx)
                      ix = jx
                      if (noconj) then
                          if (nounit) temp = temp*ap(kk)
                          do k = kk - 1,kk - j + 1,-1
                              ix = ix - incx
                              temp = temp + ap(k)*x(ix)
                          enddo
                      else
                          if (nounit) temp = temp*conjg(ap(kk))
                          do k = kk - 1,kk - j + 1,-1
                              ix = ix - incx
                              temp = temp + conjg(ap(k))*x(ix)
                          enddo
                      endif
                      x(jx) = temp
                      jx = jx - incx
                      kk = kk - j
                  enddo
              endif
          else
              kk = 1
              if (incx.eq.1) then
                  do j = 1,n
                      temp = x(j)
                      k = kk + 1
                      if (noconj) then
                          if (nounit) temp = temp*ap(kk)
                          do i = j + 1,n
                              temp = temp + ap(k)*x(i)
                              k = k + 1
                          enddo
                      else
                          if (nounit) temp = temp*conjg(ap(kk))
                          do i = j + 1,n
                              temp = temp + conjg(ap(k))*x(i)
                              k = k + 1
                          enddo
                      endif
                      x(j) = temp
                      kk = kk + (n-j+1)
                  enddo
              else
                  jx = kx
                  do j = 1,n
                      temp = x(jx)
                      ix = jx
                      if (noconj) then
                          if (nounit) temp = temp*ap(kk)
                          do k = kk + 1,kk + n - j
                              ix = ix + incx
                              temp = temp + ap(k)*x(ix)
                          enddo
                      else
                          if (nounit) temp = temp*conjg(ap(kk))
                          do k = kk + 1,kk + n - j
                              ix = ix + incx
                              temp = temp + conjg(ap(k))*x(ix)
                          enddo
                      endif
                      x(jx) = temp
                      jx = jx + incx
                      kk = kk + (n-j+1)
                  enddo
              endif
          endif
      endif
!
!     End of CTPMV .
!
      end subroutine ctpmv