Program g05rzfe
! G05RZF Example Program Text
! Mark 26.2 Release. NAG Copyright 2017.
! .. Use Statements ..
Use nag_library, Only: g05kff, g05rzf, nag_wp, x04caf
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: lseed = 1, nin = 5, nout = 6
! .. Local Scalars ..
Integer :: genid, i, ifail, ldc, ldx, lr, &
lstate, m, mode, n, subid
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: c(:,:), r(:), x(:,:), xmu(:)
Integer :: seed(lseed)
Integer, Allocatable :: state(:)
! .. Executable Statements ..
Write (nout,*) 'G05RZF Example Program Results'
Write (nout,*)
Flush (nout)
! Skip heading in data file
Read (nin,*)
! Read in the base generator information and seed
Read (nin,*) genid, subid, seed(1)
! Initial call to initializer to get size of STATE array
lstate = 0
Allocate (state(lstate))
ifail = 0
Call g05kff(genid,subid,seed,lseed,state,lstate,ifail)
! Reallocate STATE
Deallocate (state)
Allocate (state(lstate))
! Initialize the generator to a repeatable sequence
ifail = 0
Call g05kff(genid,subid,seed,lseed,state,lstate,ifail)
! Read in sample size and number of dimensions
Read (nin,*) n, m
ldc = m
ldx = n
lr = m*(m+1) + 1
Allocate (x(ldx,m),c(ldc,m),r(lr),xmu(m))
! Read in vector of means
Read (nin,*) xmu(1:m)
! Read in upper triangle portion of the covariance matrix
Do i = 1, m
Read (nin,*) c(i,i:m)
End Do
! Using a single call to G05RZF, so set up reference vector
! and generate values in one go
mode = 2
! Generate variates
ifail = 0
Call g05rzf(mode,n,m,xmu,c,ldc,r,lr,state,x,ldx,ifail)
! Display the variates
ifail = 0
Call x04caf('General',' ',n,m,x,ldx,'Variates',ifail)
End Program g05rzfe