Program f16ghfe
! F16GHF Example Program Text
! Mark 29.3 Release. NAG Copyright 2023.
! .. Use Statements ..
Use nag_library, Only: blas_zwaxpby, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Complex (Kind=nag_wp) :: alpha, beta
Integer :: i, incw, incx, incy, ix, iy, n
! .. Local Arrays ..
Complex (Kind=nag_wp), Allocatable :: w(:), x(:), y(:)
! .. Intrinsic Procedures ..
Intrinsic :: abs
! .. Executable Statements ..
Write (nout,*) 'F16GHF Example Program Results'
! Skip heading in data file
Read (nin,*)
Read (nin,*) n
Read (nin,*) incx, incy, incw
Allocate (w(1+(n-1)*abs(incw)),x(1+(n-1)*abs(incx)),y(1+(n- &
1)*abs(incy)))
Read (nin,*) alpha, beta
! Read the vectors x and y and store forwards or backwards
! as determined by incx (resp. incy).
If (incx>0) Then
ix = 1
Else
ix = 1 - (n-1)*incx
End If
Do i = 1, n
Read (nin,*) x(ix)
ix = ix + incx
End Do
If (incy>0) Then
iy = 1
Else
iy = 1 - (n-1)*incy
End If
Do i = 1, n
Read (nin,*) y(iy)
iy = iy + incy
End Do
! Compute w = alpha*x + beta*y
Call blas_zwaxpby(n,alpha,x,incx,beta,y,incy,w,incw)
! Display the vector w forwards or backwards
! as determined by incw.
Write (nout,*)
Write (nout,99999)
If (incw>0) Then
Write (nout,99998) w(1:1+(n-1)*incw:incw)
Else
Write (nout,99998) w(1-(n-1)*incw:1:incw)
End If
99999 Format (1X,'Result of scaled vector addition is')
99998 Format (1X,'w = ( ',2('(',F9.4,',',F9.4,'), '),'(',F9.4,',',F9.4,') )')
End Program f16ghfe