Program c09dcfe
! C09DCF Example Program Text
! Mark 30.3 Release. nAG Copyright 2024.
! .. Use Statements ..
Use nag_library, Only: c09aaf, c09dcf, c09ddf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Integer :: ifail, lenc, n, na, nf, nwc, nwl, ny
Character (10) :: keepa, mode, wavnam, wtrans
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: c(:), x(:), y(:)
Integer :: icomm(100)
! .. Executable Statements ..
Write (nout,*) 'C09DCF Example Program Results'
! Skip heading in data file
Read (nin,*)
! Read problem parameters
Read (nin,*) n
Read (nin,*) wavnam, mode, keepa
Allocate (x(n),y(n))
Write (nout,99999) wavnam, mode, n
Write (nout,99998) keepa
! Read data array and write it out
Read (nin,*) x(1:n)
Write (nout,*) ' Input Data X :'
Write (nout,99997) x(1:n)
! Query wavelet filter dimensions
! For Multi-Resolution Analysis, decomposition, wtrans = 'U'
wtrans = 'U'
! ifail: behaviour on error exit
! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
ifail = 0
Call c09aaf(wavnam,wtrans,mode,n,nwl,nf,nwc,icomm,ifail)
! Choose to decompose over two levels
nwl = 2
nwc = (nwl+1)*n
If (keepa=='Final') Then
lenc = nwc
Else
lenc = 2*n*nwl
End If
Allocate (c(lenc))
! Perform Discrete Wavelet transform
ifail = 0
Call c09dcf(n,x,keepa,lenc,c,nwl,na,icomm,ifail)
Write (nout,99996) nwl
Write (nout,99995) na
Write (nout,99994)
Write (nout,99997) c(1:lenc)
! Reconstruct original data
ny = n
ifail = 0
Call c09ddf(nwl,keepa,lenc,c,ny,y,icomm,ifail)
Write (nout,99993)
Write (nout,99997) y(1:ny)
99999 Format (1X,' MLMODWT :: Wavelet : ',A10,', End mode : ',A10,' N = ',I10)
99998 Format (1X,' :: Keepa : ',A10)
99997 Format (8(F8.4,1X),:)
99996 Format (1X,' Number of Levels : ',I10)
99995 Format (1X,' Number of coefficients in each level : ',I10)
99994 Format (1X,' Wavelet coefficients C : ')
99993 Format (1X,' Reconstruction Y : ')
End Program c09dcfe