NAG Library Manual, Mark 30.1
Interfaces:  FL   CL   CPP   AD 

NAG FL Interface Introduction
Example description
    Program g03bafe

!     G03BAF Example Program Text

!     Mark 30.1 Release. NAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: g03baf, nag_wp, x04caf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: acc, g
      Integer                          :: i, ifail, iter, k, ldfl, ldr, lwk,   &
                                          maxit, nvar
      Character (1)                    :: stand
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: fl(:,:), flr(:,:), r(:,:), wk(:)
!     .. Executable Statements ..
      Write (nout,*) 'G03BAF Example Program Results'
      Write (nout,*)
      Flush (nout)

!     Skip heading in data file
      Read (nin,*)

!     Read in the problem size
      Read (nin,*) nvar, k, g, stand, acc, maxit

      ldfl = nvar
      ldr = k
      lwk = 2*nvar + k*k + 5*(k-1)
      Allocate (fl(ldfl,k),flr(ldfl,k),r(ldr,k),wk(lwk))

!     Read in loadings
      Read (nin,*)(fl(i,1:k),i=1,nvar)

!     Compute rotations
      ifail = 0
      Call g03baf(stand,g,nvar,k,fl,ldfl,flr,r,ldr,acc,maxit,iter,wk,ifail)

!     Display results
      ifail = 0
      Call x04caf('General',' ',nvar,k,flr,ldfl,'Rotated factor loadings',     &
        ifail)
      Write (nout,*)
      Flush (nout)
      ifail = 0
      Call x04caf('General',' ',k,k,r,ldr,'Rotated matrix',ifail)

    End Program g03bafe