subroutine cgbmv ( trans, m, n, kl, ku, alpha, a, lda, x, incx, beta, y, incy ) !*****************************************************************************80 ! !! CGBMV computes y := alpha * A * x + beta * y, A a complex band matrix. ! ! Discussion: ! ! CGBMV performs one of the matrix-vector operations ! ! y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y, or ! ! y := alpha*conjg( A' )*x + beta*y, ! ! where alpha and beta are scalars, x and y are vectors and A is an ! m by n band matrix, with kl sub-diagonals and ku super-diagonals. ! ! Parameters: ! ! TRANS - character. ! On entry, TRANS specifies the operation to be performed as ! follows: ! ! TRANS = 'N' or 'n' y := alpha*A*x + beta*y. ! ! TRANS = 'T' or 't' y := alpha*A'*x + beta*y. ! ! TRANS = 'C' or 'c' y := alpha*conjg( A' )*x + beta*y. ! ! Unchanged on exit. ! ! M - integer. ! On entry, M specifies the number of rows of the matrix A. ! M must be at least zero. ! Unchanged on exit. ! ! N - integer. ! On entry, N specifies the number of columns of the matrix A. ! N must be at least zero. ! Unchanged on exit. ! ! KL - integer. ! On entry, KL specifies the number of sub-diagonals of the ! matrix A. KL must satisfy 0 <= KL. ! Unchanged on exit. ! ! KU - integer. ! On entry, KU specifies the number of super-diagonals of the ! matrix A. KU must satisfy 0 <= KU. ! Unchanged on exit. ! ! ALPHA - complex . ! On entry, ALPHA specifies the scalar alpha. ! Unchanged on exit. ! ! A - complex array of DIMENSION ( LDA, n ). ! Before entry, the leading ( kl + ku + 1 ) by n part of the ! array A must contain the matrix of coefficients, supplied ! column by column, with the leading diagonal of the matrix in ! row ( ku + 1 ) of the array, the first super-diagonal ! starting at position 2 in row ku, the first sub-diagonal ! starting at position 1 in row ( ku + 2 ), and so on. ! Elements in the array A that do not correspond to elements ! in the band matrix (such as the top left ku by ku triangle) ! are not referenced. ! The following program segment will transfer a band matrix ! from conventional full matrix storage to band storage: ! ! do j = 1, n ! k = kU + 1 - J ! do i = max ( 1, j - KU ), min ( M, J + KL ) ! a( K + I,j) = matrix(i,j) ! end do ! end do ! ! Unchanged on exit. ! ! LDA - integer. ! On entry, LDA specifies the first dimension of A as declared ! in the calling (sub) program. LDA must be at least ! ( kl + ku + 1 ). ! Unchanged on exit. ! ! X - complex array of DIMENSION at least ! ( 1 + ( n - 1 ) * abs( incx ) ) when TRANS = 'N' or 'n' ! and at least ! ( 1 + ( m - 1 ) * abs( incx ) ) otherwise. ! Before entry, the incremented array X must contain the ! vector x. ! Unchanged on exit. ! ! incx - integer. ! On entry, incx specifies the increment for the elements of ! X. incx must not be zero. ! Unchanged on exit. ! ! BETA - complex . ! On entry, BETA specifies the scalar beta. When BETA is ! supplied as zero then Y need not be set on input. ! Unchanged on exit. ! ! Y - complex array of DIMENSION at least ! ( 1 + ( m - 1 ) * abs( incy ) ) when TRANS = 'N' or 'n' ! and at least ! ( 1 + ( n - 1 ) * abs( incy ) ) otherwise. ! Before entry, the incremented array Y must contain the ! vector y. On exit, Y is overwritten by the updated vector y. ! ! ! incy - integer. ! On entry, incy specifies the increment for the elements of ! Y. incy must not be zero. ! Unchanged on exit. ! implicit none integer lda complex alpha complex beta integer incx integer incy, kl, ku, m, n character trans complex a( lda, * ), x( * ), y( * ) complex, parameter :: one = ( 1.0E+00, 0.0E+00 ) complex, parameter :: zero = ( 0.0E+00, 0.0E+00 ) complex temp integer i, info, ix, iy, j, jx, jy, k, kup1, kx, ky, & lenx, leny logical noconj logical lsame ! ! Test the input. ! info = 0 if ( .not.lsame ( trans, 'N' ) .and. & .not.lsame ( trans, 'T' ) .and. & .not.lsame ( trans, 'C' ) ) then info = 1 else if ( m<0 ) then info = 2 else if ( n<0 ) then info = 3 else if ( kl<0 ) then info = 4 else if ( ku<0 ) then info = 5 else if ( lda<( kl + ku + 1 ) ) then info = 8 else if ( incx == 0 ) then info = 10 else if ( incy == 0 ) then info = 13 end if if ( info /= 0 ) then call xerbla ( 'cgbmv ', info ) return end if ! ! Quick return if possible. ! if ( ( m == 0 ).or.( n == 0 ) .or. & ( ( alpha == zero ) .and. ( beta == one ) ) ) then return end if noconj = lsame ( trans, 'T' ) ! ! Set LENX and LENY, the lengths of the vectors X and Y, and set ! up the start points in X and Y. ! if ( lsame ( trans, 'N' ) ) then lenx = n leny = m else lenx = m leny = n end if if ( 0 < incx ) then kx = 1 else kx = 1 - ( lenx - 1 ) * incx end if if ( 0 < incy ) then ky = 1 else ky = 1 - ( leny - 1 ) * incy end if ! ! Start the operations. In this version the elements of A are ! accessed sequentially with one pass through the band part of A. ! ! First form y := beta*y. ! if ( beta /= one ) then if ( incy == 1 ) then if ( beta == zero ) then y(1:leny) = zero else y(1:leny) = beta * y(1:leny) end if else iy = ky if ( beta == zero ) then do i = 1, leny y(iy) = zero iy = iy + incy end do else do i = 1, leny y(iy) = beta * y(iy) iy = iy + incy end do end if end if end if if ( alpha == zero ) then return end if kup1 = ku + 1 if ( lsame ( trans, 'N' ) ) then ! ! Form y := alpha*A*x + y. ! jx = kx if ( incy == 1 ) then do j = 1, n if ( x(jx) /= zero ) then temp = alpha * x(jx) k = kup1 - j do i = max ( 1, j - ku ), min ( m, j + kl ) y(i) = y(i) + temp * a( k + i,j) end do end if jx = jx + incx end do else do j = 1, n if ( x(jx) /= zero ) then temp = alpha * x(jx) iy = ky k = kup1 - j do i = max ( 1, j - ku ), min ( m, j + kl ) y(iy) = y(iy) + temp * a( k + i,j) iy = iy + incy end do end if jx = jx + incx if ( ku < j ) then ky = ky + incy end if end do end if else ! ! Form y := alpha*A'*x + y or y := alpha*conjg( A' )*x + y. ! jy = ky if ( incx == 1 ) then do j = 1, n temp = zero k = kup1 - j if ( noconj ) then do i = max ( 1, j - ku ), min ( m, j + kl ) temp = temp + a( k + i,j) * x(i) end do else do i = max ( 1, j - ku ), min ( m, j + kl ) temp = temp + conjg ( a( k + i,j) ) * x(i) end do end if y(jy) = y(jy) + alpha * temp jy = jy + incy end do else do j = 1, n temp = zero ix = kx k = kup1 - j if ( noconj ) then do i = max ( 1, j - ku ), min ( m, j + kl ) temp = temp + a( k + i,j) * x(ix) ix = ix + incx end do else do i = max ( 1, j - ku ), min ( m, j + kl ) temp = temp + conjg ( a( k + i,j) ) * x(ix) ix = ix + incx end do end if y(jy) = y(jy) + alpha * temp jy = jy + incy if ( ku < j ) then kx = kx + incx end if end do end if end if return end subroutine cgemv ( trans, m, n, alpha, a, lda, x, incx, beta, y, incy ) !*****************************************************************************80 ! !! CGEMV computes y := alpha * A * x + beta * y, A a general complex matrix. ! ! Discussion: ! ! CGEMV performs one of the matrix-vector operations ! ! y := alpha * A * x + beta * y, or ! y := alpha * A' * x + beta * y, or ! y := alpha * conjg ( A' ) * x + beta * y, ! ! where alpha and beta are scalars, x and y are vectors and A is an ! m by n matrix. ! ! Parameters: ! ! Input, character TRANS, specifies the operation to be performed: ! 'N' or 'n' y := alpha*A*x + beta*y. ! 'T' or 't' y := alpha*A'*x + beta*y. ! 'C' or 'c' y := alpha*conjg( A' )*x + beta*y. ! ! M - integer. ! On entry, M specifies the number of rows of the matrix A. ! M must be at least zero. ! Unchanged on exit. ! ! N - integer. ! On entry, N specifies the number of columns of the matrix A. ! N must be at least zero. ! Unchanged on exit. ! ! ALPHA - complex . ! On entry, ALPHA specifies the scalar alpha. ! Unchanged on exit. ! ! A - complex array of DIMENSION ( LDA, n ). ! Before entry, the leading m by n part of the array A must ! contain the matrix of coefficients. ! Unchanged on exit. ! ! LDA - integer. ! On entry, LDA specifies the first dimension of A as declared ! in the calling (sub) program. LDA must be at least ! max( 1, m ). ! Unchanged on exit. ! ! X - complex array of DIMENSION at least ! ( 1 + ( n - 1 ) * abs( incx ) ) when TRANS = 'N' or 'n' ! and at least ! ( 1 + ( m - 1 ) * abs( incx ) ) otherwise. ! Before entry, the incremented array X must contain the ! vector x. ! Unchanged on exit. ! ! incx - integer. ! On entry, incx specifies the increment for the elements of ! X. incx must not be zero. ! Unchanged on exit. ! ! BETA - complex . ! On entry, BETA specifies the scalar beta. When BETA is ! supplied as zero then Y need not be set on input. ! Unchanged on exit. ! ! Y - complex array of DIMENSION at least ! ( 1 + ( m - 1 ) * abs( incy ) ) when TRANS = 'N' or 'n' ! and at least ! ( 1 + ( n - 1 ) * abs( incy ) ) otherwise. ! Before entry with BETA non-zero, the incremented array Y ! must contain the vector y. On exit, Y is overwritten by the ! updated vector y. ! ! incy - integer. ! On entry, incy specifies the increment for the elements of ! Y. incy must not be zero. ! Unchanged on exit. ! implicit none integer lda complex a(lda,*) complex alpha complex beta integer i integer incx integer incy integer info integer ix integer iy integer j integer jx integer jy integer kx integer ky integer lenx integer leny logical lsame integer m integer n logical noconj complex, parameter :: one = ( 1.0E+00, 0.0E+00 ) complex temp character trans complex x(*) complex y(*) complex, parameter :: zero = ( 0.0E+00, 0.0E+00 ) ! ! Test the input. ! info = 0 if ( .not. lsame ( trans, 'N' ) .and. & .not. lsame ( trans, 'T' ) .and. & .not. lsame ( trans, 'C' ) ) then info = 1 else if ( m < 0 ) then info = 2 else if ( n < 0 ) then info = 3 else if ( lda < max ( 1, m ) ) then info = 6 else if ( incx == 0 ) then info = 8 else if ( incy == 0 ) then info = 11 end if if ( info /= 0 ) then call xerbla ( 'cgemv ', info ) return end if ! ! Quick return if possible. ! if ( ( m == 0 ).or.( n == 0 ) .or. & ( ( alpha == zero ) .and. ( beta == one ) ) ) then return end if noconj = lsame ( trans, 'T' ) ! ! Set lenx and leny, the lengths of the vectors x and y, and set ! up the start points in X and Y. ! if ( lsame ( trans, 'N' ) ) then lenx = n leny = m else lenx = m leny = n end if if ( 0 < incx ) then kx = 1 else kx = 1 - ( lenx - 1 ) * incx end if if ( 0 < incy ) then ky = 1 else ky = 1 - ( leny - 1 ) * incy end if ! ! Start the operations. In this version the elements of A are ! accessed sequentially with one pass through A. ! ! First form y := beta*y. ! if ( beta /= one ) then if ( incy == 1 ) then if ( beta == zero ) then do i = 1, leny y(i) = zero end do else do i = 1, leny y(i) = beta * y(i) end do end if else iy = ky if ( beta == zero ) then do i = 1, leny y(iy) = zero iy = iy + incy end do else do i = 1, leny y(iy) = beta * y(iy) iy = iy + incy end do end if end if end if if ( alpha == zero ) then return end if ! ! Form y := alpha*A*x + y. ! if ( lsame ( trans, 'N' ) ) then jx = kx if ( incy == 1 ) then do j = 1, n if ( x(jx) /= zero ) then temp = alpha * x(jx) do i = 1, m y(i) = y(i) + temp * a(i,j) end do end if jx = jx + incx end do else do j = 1, n if ( x(jx) /= zero ) then temp = alpha * x(jx) iy = ky do i = 1, m y(iy) = y(iy) + temp * a(i,j) iy = iy + incy end do end if jx = jx + incx end do end if ! ! Form y := alpha*A'*x + y or y := alpha*conjg( A' )*x + y. ! else jy = ky if ( incx == 1 ) then do j = 1, n temp = zero if ( noconj ) then do i = 1, m temp = temp + a(i,j) * x(i) end do else do i = 1, m temp = temp + conjg ( a(i,j) ) * x(i) end do end if y(jy) = y(jy) + alpha * temp jy = jy + incy end do else do j = 1, n temp = zero ix = kx if ( noconj ) then do i = 1, m temp = temp + a(i,j) * x(ix) ix = ix + incx end do else do i = 1, m temp = temp + conjg ( a(i,j) ) * x(ix) ix = ix + incx end do end if y(jy) = y(jy) + alpha * temp jy = jy + incy end do end if end if return end subroutine cgerc ( m, n, alpha, x, incx, y, incy, a, lda ) !*****************************************************************************80 ! !! CGERC performs the rank 1 operation A := A + alpha * x * conjg ( y' ). ! ! Discussion: ! ! ALPHA is a scalar, x is an m element vector, y is an n element ! vector and A is an m by n matrix. ! ! Parameters: ! ! M - integer. ! On entry, M specifies the number of rows of the matrix A. ! M must be at least zero. ! Unchanged on exit. ! ! N - integer. ! On entry, N specifies the number of columns of the matrix A. ! N must be at least zero. ! Unchanged on exit. ! ! ALPHA - complex . ! On entry, ALPHA specifies the scalar alpha. ! Unchanged on exit. ! ! X - complex array of dimension at least ! ( 1 + ( m - 1 ) * abs( incx ) ). ! Before entry, the incremented array X must contain the m ! element vector x. ! Unchanged on exit. ! ! incx - integer. ! On entry, incx specifies the increment for the elements of ! X. incx must not be zero. ! Unchanged on exit. ! ! Y - complex array of dimension at least ! ( 1 + ( n - 1 ) * abs( incy ) ). ! Before entry, the incremented array Y must contain the n ! element vector y. ! Unchanged on exit. ! ! incy - integer. ! On entry, incy specifies the increment for the elements of ! Y. incy must not be zero. ! Unchanged on exit. ! ! A - complex array of DIMENSION ( LDA, n ). ! Before entry, the leading m by n part of the array A must ! contain the matrix of coefficients. On exit, A is ! overwritten by the updated matrix. ! ! LDA - integer. ! On entry, LDA specifies the first dimension of A as declared ! in the calling (sub) program. LDA must be at least ! max( 1, m ). ! Unchanged on exit. ! implicit none integer lda complex alpha integer incx integer incy integer m integer n complex temp complex a( lda, * ), x( * ), y( * ) complex, parameter :: zero = ( 0.0E+00, 0.0E+00 ) integer i, info, ix, j, jy, kx ! ! Test the input. ! info = 0 if ( m<0 ) then info = 1 else if ( n<0 ) then info = 2 else if ( incx == 0 ) then info = 5 else if ( incy == 0 ) then info = 7 else if ( lda