*     G05YAF Example Program Text
*     Mark 20 Release. NAG Copyright 2001.
*     .. Parameters ..
      INTEGER          NOUT
      PARAMETER        (NOUT=6)
*     .. Local Scalars ..
      DOUBLE PRECISION SUM, VSBL
      INTEGER          I, IDIM, IFAIL, NTIMES, SKIP
      CHARACTER        SEQ
*     .. Local Arrays ..
      DOUBLE PRECISION QUASI(15)
      INTEGER          IREF(2000)
*     .. External Functions ..
      DOUBLE PRECISION FUN
      EXTERNAL         FUN
*     .. External Subroutines ..
      EXTERNAL         G05YAF
*     .. Intrinsic Functions ..
      INTRINSIC        DBLE
*     .. Executable Statements ..
      WRITE (NOUT,*) 'G05YAF Example Program Results'
      IDIM = 15
      NTIMES = 10000
      SEQ = 'S'
      IF (SEQ.EQ.'N' .OR. SEQ.EQ.'n') THEN
         SKIP = 1000
      ELSE
         SKIP = 0
      END IF
      IFAIL = 0
*
      CALL G05YAF(.TRUE.,SEQ,SKIP,IDIM,QUASI,IREF,IFAIL)
*
      SUM = 0.0D0
      DO 20 I = 1, NTIMES
*
         CALL G05YAF(.FALSE.,SEQ,SKIP,IDIM,QUASI,IREF,IFAIL)
*
         SUM = SUM + FUN(IDIM,QUASI)
   20 CONTINUE
      VSBL = SUM/DBLE(NTIMES)
      WRITE (NOUT,*)
      WRITE (NOUT,99999) 'Value of integral = ', VSBL
      STOP
*
99999 FORMAT (1X,A,F8.3)
      END
*
      DOUBLE PRECISION FUNCTION FUN(IDIM,X)
*     .. Scalar Arguments ..
      INTEGER                       IDIM
*     .. Array Arguments ..
      DOUBLE PRECISION              X(IDIM)
*     .. Local Scalars ..
      DOUBLE PRECISION              TMP
      INTEGER                       J
*     .. Intrinsic Functions ..
      INTRINSIC                     ABS
*     .. Executable Statements ..
      TMP = 1.0D0
      DO 20 J = 1, IDIM
         TMP = TMP*ABS(4.0D0*X(J)-2.0D0)
   20 CONTINUE
      FUN = TMP
      RETURN
      END
