## DG01OD

### Scrambled discrete Hartley transform of a real signal

[Specification] [Arguments] [Method] [References] [Comments] [Example]

Purpose

```  To compute the (scrambled) discrete Hartley transform of
a real signal.

```
Specification
```      SUBROUTINE DG01OD( SCR, WGHT, N, A, W, INFO )
C     .. Scalar Arguments ..
CHARACTER         SCR, WGHT
INTEGER           INFO, N
C     .. Array Arguments ..
DOUBLE PRECISION  A(*), W(*)

```
Arguments

Mode Parameters

```  SCR     CHARACTER*1
Indicates whether the signal is scrambled on input or
on output as follows:
= 'N':  the signal is not scrambled at all;
= 'I':  the input signal is bit-reversed;
= 'O':  the output transform is bit-reversed.

WGHT    CHARACTER*1
Indicates whether the precomputed weights are available
or not, as follows:
= 'A':  available;
= 'N':  not available.
Note that if N > 1 and WGHT = 'N' on entry, then WGHT is
set to 'A' on exit.

```
Input/Output Parameters
```  N       (input) INTEGER
Number of real samples. N must be a power of 2.
N >= 0.

A       (input/output) DOUBLE PRECISION array, dimension (N)
On entry with SCR = 'N' or SCR = 'O', this array must
contain the input signal.
On entry with SCR = 'I', this array must contain the
bit-reversed input signal.
On exit with SCR = 'N' or SCR = 'I', this array contains
the Hartley transform of the input signal.
On exit with SCR = 'O', this array contains the
bit-reversed Hartley transform.

W       (input/output) DOUBLE PRECISION array,
dimension (N - LOG2(N))
On entry with WGHT = 'A', this array must contain the long
weight vector computed by a previous call of this routine
with the same value of N. If WGHT = 'N', the contents of
this array on entry is ignored.
On exit, this array contains the long weight vector.

```
Error Indicator
```  INFO    INTEGER
= 0:  successful exit;
< 0:  if INFO = -i, the i-th argument had an illegal
value.

```
Method
```  This routine uses a Hartley butterfly algorithm as described
in .

```
References
```   Van Loan, Charles.
Computational frameworks for the fast Fourier transform.
SIAM, 1992.

```
Numerical Aspects
```  The algorithm is backward stable and requires O(N log(N))
floating point operations.

```
```  None
```
Example

Program Text

```*     DG01OD EXAMPLE PROGRAM TEXT
*     Copyright (c) 2002-2017 NICONET e.V.
*
*     .. Parameters ..
INTEGER          NIN, NOUT
PARAMETER        ( NIN = 5, NOUT = 6 )
INTEGER          NMAX
PARAMETER        ( NMAX = 128 )
*     .. Local Scalars ..
INTEGER          I, INFO, N
CHARACTER*1      SCR, WGHT
*     .. Local Arrays ..
DOUBLE PRECISION A(NMAX), W(NMAX)
*     .. External Subroutines ..
EXTERNAL         DG01OD
*     .. Executable Statements ..
*
WRITE ( NOUT, FMT = 99999 )
*     Skip the heading in the data file and read the data.
READ ( NIN, FMT = '()' )
READ ( NIN, FMT = * ) N, SCR, WGHT
IF ( N.LT.0 .OR. N.GT.NMAX ) THEN
WRITE ( NOUT, FMT = 99995 ) N
ELSE
READ ( NIN, FMT = * ) ( A(I), I = 1,N )
*        Compute the Hartley transform.
CALL DG01OD( SCR, WGHT, N, A, W, INFO )
IF ( INFO.NE.0 ) THEN
WRITE ( NOUT, FMT = 99998 ) INFO
ELSE
WRITE ( NOUT, FMT = 99997 )
DO 10 I = 1, N
WRITE ( NOUT, FMT = 99996 ) I, A(I)
10       CONTINUE
END IF
END IF
STOP
*
99999 FORMAT (' DG01OD EXAMPLE PROGRAM RESULTS',/1X)
99998 FORMAT (' INFO on exit from DG01OD = ',I2)
99997 FORMAT ('   Hartley transform ',//'   i    A(i)',/)
99996 FORMAT (I4,1X,F8.4)
99995 FORMAT (/' N is out of range.',/' N = ',I5)
END
```
Program Data
``` DG01OD EXAMPLE
16      N      N
1.0
2.0
3.0
4.0
5.0
6.0
7.0
8.0
9.0
10.0
11.0
12.0
13.0
14.0
15.0
16.0
```
Program Results
``` DG01OD EXAMPLE PROGRAM RESULTS

Hartley transform

i    A(i)

1 136.0000
2 -48.2187
3 -27.3137
4 -19.9728
5 -16.0000
6 -13.3454
7 -11.3137
8  -9.5913
9  -8.0000
10  -6.4087
11  -4.6863
12  -2.6546
13   0.0000
14   3.9728
15  11.3137
16  32.2187
```