Program c06fbfe
! C06FBF Example Program Text
! Mark 28.6 Release. NAG Copyright 2022.
! .. Use Statements ..
Use nag_library, Only: c06faf, c06fbf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Integer :: ieof, ifail, j, n
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: u(:), v(:), work(:), x(:), xx(:)
! .. Intrinsic Procedures ..
Intrinsic :: mod
! .. Executable Statements ..
Write (nout,*) 'C06FBF Example Program Results'
! Skip heading in data file
Read (nin,*)
loop: Do
Read (nin,*,Iostat=ieof) n
If (ieof<0) Then
Exit loop
End If
Allocate (u(0:n-1),v(0:n-1),x(0:n-1),xx(0:n-1),work(n))
Read (nin,*) x(0:n-1)
xx(0:n-1) = x(0:n-1)
! Convert x to separated real and imaginary parts for printing.
u(0:n/2) = x(0:n/2)
u(n-1:n/2+1:-1) = x(1:n/2)
v(0) = 0.0_nag_wp
v(1:(n-1)/2) = x(n-1:n-(n-1)/2:-1)
v(n-(n-1)/2:n-1) = -v((n-1)/2:1:-1)
If (mod(n,2)==0) Then
v(n/2) = 0.0_nag_wp
End If
! ifail: behaviour on error exit
! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
ifail = 0
Call c06fbf(x,n,work,ifail)
Write (nout,*)
Write (nout,*) 'Original sequence and corresponding complex sequence'
Write (nout,*)
Write (nout,*) ' Data Real Imag'
Write (nout,*)
Write (nout,99999)(j,xx(j),' ',u(j),v(j),j=0,n-1)
Write (nout,*)
Write (nout,*) 'Components of discrete Fourier transform'
Write (nout,*)
Write (nout,99998)(j,x(j),j=0,n-1)
Call c06faf(x,n,work,ifail)
x(n/2+1:n-1) = -x(n/2+1:n-1)
Write (nout,*)
Write (nout,*) 'Original sequence as restored by inverse transform'
Write (nout,*)
Write (nout,*) ' Original Restored'
Write (nout,*)
Write (nout,99997)(j,xx(j),x(j),j=0,n-1)
Deallocate (u,v,x,xx,work)
End Do loop
99999 Format (1X,I5,F10.5,A,2F10.5)
99998 Format (1X,I5,F10.5)
99997 Format (1X,I5,2F10.5)
End Program c06fbfe