File: DF01MD.html

package info (click to toggle)
slicot 5.9.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,528 kB
  • sloc: fortran: 148,076; makefile: 964; sh: 57
file content (282 lines) | stat: -rw-r--r-- 7,489 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<HTML>
<HEAD><TITLE>DF01MD - SLICOT Library Routine Documentation</TITLE>
</HEAD>
<BODY>

<H2><A Name="DF01MD">DF01MD</A></H2>
<H3>
Sine transform or cosine transform of a real signal
</H3>
<A HREF ="#Specification"><B>[Specification]</B></A>
<A HREF ="#Arguments"><B>[Arguments]</B></A>
<A HREF ="#Method"><B>[Method]</B></A>
<A HREF ="#References"><B>[References]</B></A>
<A HREF ="#Comments"><B>[Comments]</B></A>
<A HREF ="#Example"><B>[Example]</B></A>

<P>
<B><FONT SIZE="+1">Purpose</FONT></B>
<PRE>
  To compute the sine transform or cosine transform of a real
  signal.

</PRE>
<A name="Specification"><B><FONT SIZE="+1">Specification</FONT></B></A>
<PRE>
      SUBROUTINE DF01MD( SICO, N, DT, A, DWORK, INFO )
C     .. Scalar Arguments ..
      CHARACTER         SICO
      INTEGER           INFO, N
      DOUBLE PRECISION  DT
C     .. Array Arguments ..
      DOUBLE PRECISION  A(*), DWORK(*)

</PRE>
<A name="Arguments"><B><FONT SIZE="+1">Arguments</FONT></B></A>
<P>

<B>Mode Parameters</B>
<PRE>
  SICO    CHARACTER*1
          Indicates whether the sine transform or cosine transform
          is to be computed as follows:
          = 'S':  The sine transform is computed;
          = 'C':  The cosine transform is computed.

</PRE>
<B>Input/Output Parameters</B>
<PRE>
  N       (input) INTEGER
          The number of samples.  N must be a power of 2 plus 1.
          N &gt;= 5.

  DT      (input) DOUBLE PRECISION
          The sampling time of the signal.

  A       (input/output) DOUBLE PRECISION array, dimension (N)
          On entry, this array must contain the signal to be
          processed.
          On exit, this array contains either the sine transform, if
          SICO = 'S', or the cosine transform, if SICO = 'C', of the
          given signal.

</PRE>
<B>Workspace</B>
<PRE>
  DWORK   DOUBLE PRECISION array, dimension (N+1)

</PRE>
<B>Error Indicator</B>
<PRE>
  INFO    INTEGER
          = 0:  successful exit;
          &lt; 0:  if INFO = -i, the i-th argument had an illegal
                value.

</PRE>
<A name="Method"><B><FONT SIZE="+1">Method</FONT></B></A>
<PRE>
  Let A(1), A(2),..., A(N) be a real signal of N samples.

  If SICO = 'S', the routine computes the sine transform of A as
  follows. First, transform A(i), i = 1,2,...,N, into the complex
  signal B(i), i = 1,2,...,(N+1)/2, where

     B(1) = -2*A(2),
     B(i) = {A(2i-2) - A(2i)} - j*A(2i-1) for i = 2,3,...,(N-1)/2,
     B((N+1)/2) = 2*A(N-1) and j**2 = -1.

  Next, perform a discrete inverse Fourier transform on B(i) by
  calling SLICOT Library Routine DG01ND, to give the complex signal
  Z(i), i = 1,2,...,(N-1)/2, from which the real signal C(i) may be
  obtained as follows:

     C(2i-1) = Re(Z(i)),  C(2i) = Im(Z(i)) for i = 1,2,...,(N-1)/2.

  Finally, compute the sine transform coefficients S ,S ,...,S
                                                    1  2      N
  given by

     S  = 0,
      1
             {                     [C(k) + C(N+1-k)]     }
     S  = DT*{[C(k) - C(N+1-k)] - -----------------------},
      k      {                    [2*sin(pi*(k-1)/(N-1))]}

        for k = 2,3,...,N-1, and

     S = 0.
      N

  If SICO = 'C', the routine computes the cosine transform of A as
  follows. First, transform A(i), i = 1,2,...,N, into the complex
  signal B(i), i = 1,2,...,(N+1)/2, where

     B(1) = 2*A(1),
     B(i) = 2*A(2i-1) + 2*j*{[A(2i-2) - A(2i)]}
     for i = 2,3,...,(N-1)/2 and B((N+1)/2) = 2*A(N).

  Next, perform a discrete inverse Fourier transform on B(i) by
  calling SLICOT Library Routine DG01ND, to give the complex signal
  Z(i), i = 1,2,...,(N-1)/2, from which the real signal D(i) may be
  obtained as follows:

     D(2i-1) = Re(Z(i)),  D(2i) = Im(Z(i)) for i = 1,2,...,(N-1)/2.

  Finally, compute the cosine transform coefficients S ,S ,...,S
                                                      1  2      N
  given by

     S  = 2*DT*[D(1) + A0],
      1
             {                     [D(k) - D(N+1-k)]     }
     S  = DT*{[D(k) + D(N+1-k)] - -----------------------},
      k      {                    [2*sin(pi*(k-1)/(N-1))]}

        for k = 2,3,...,N-1, and

     S  = 2*DT*[D(1) - A0],
      N
              (N-1)/2
  where A0 = 2*SUM   A(2i).
               i=1

</PRE>
<A name="References"><B><FONT SIZE="+1">References</FONT></B></A>
<PRE>
  [1] Rabiner, L.R. and Rader, C.M.
      Digital Signal Processing.
      IEEE Press, 1972.

  [2] Oppenheim, A.V. and Schafer, R.W.
      Discrete-Time Signal Processing.
      Prentice-Hall Signal Processing Series, 1989.

</PRE>
<A name="Numerical Aspects"><B><FONT SIZE="+1">Numerical Aspects</FONT></B></A>
<PRE>
  The algorithm requires 0( N*log(N) ) operations.

</PRE>

<A name="Comments"><B><FONT SIZE="+1">Further Comments</FONT></B></A>
<PRE>
  None
</PRE>

<A name="Example"><B><FONT SIZE="+1">Example</FONT></B></A>
<P>
<B>Program Text</B>
<PRE>
*     DF01MD EXAMPLE PROGRAM TEXT
*
*     .. Parameters ..
      INTEGER          NIN, NOUT
      PARAMETER        ( NIN = 5, NOUT = 6 )
      INTEGER          NMAX
      PARAMETER        ( NMAX = 129 )
*     .. Local Scalars ..
      DOUBLE PRECISION DT
      INTEGER          I, INFO, N
      CHARACTER*1      SICO
*     .. Local Arrays ..
      DOUBLE PRECISION A(NMAX), DWORK(NMAX+1)
*     .. External Functions ..
      LOGICAL          LSAME
      EXTERNAL         LSAME
*     .. External Subroutines ..
      EXTERNAL         DF01MD
*     .. Executable Statements ..
*
      WRITE ( NOUT, FMT = 99999 )
*     Skip the heading in the data file and read the data.
      READ ( NIN, FMT = '()' )
      READ ( NIN, FMT = * ) N, DT, SICO
      IF ( N.LE.1 .OR. N.GT.NMAX ) THEN
         WRITE ( NOUT, FMT = 99994 ) N
      ELSE
         READ ( NIN, FMT = * ) ( A(I), I = 1,N )
*        Compute the sine/cosine transform of the given real signal.
         CALL DF01MD( SICO, N, DT, A, DWORK, INFO )
*
         IF ( INFO.NE.0 ) THEN
            WRITE ( NOUT, FMT = 99998 ) INFO
         ELSE
            IF ( LSAME( SICO, 'S' ) ) THEN
               WRITE ( NOUT, FMT = 99997 )
               DO 20 I = 1, N
                  WRITE ( NOUT, FMT = 99995 ) I, A(I)
   20          CONTINUE
            ELSE
               WRITE ( NOUT, FMT = 99996 )
               DO 40 I = 1, N
                  WRITE ( NOUT, FMT = 99995 ) I, A(I)
   40          CONTINUE
            END IF
         END IF
      END IF
*
      STOP
*
99999 FORMAT (' DF01MD EXAMPLE PROGRAM RESULTS',/1X)
99998 FORMAT (' INFO on exit from DF01MD = ',I2)
99997 FORMAT (' Components of sine transform are',//'   i',6X,'A(i)',/)
99996 FORMAT (' Components of cosine transform are',//'   i',6X,'A(i)',
     $       /)
99995 FORMAT (I4,3X,F8.4)
99994 FORMAT (/' N is out of range.',/' N = ',I5)
      END
</PRE>
<B>Program Data</B>
<PRE>
 DF01MD EXAMPLE PROGRAM DATA
  17     1.0     C
  -0.1862
   0.1288
   0.3948
   0.0671
   0.6788
  -0.2417
   0.1861
   0.8875
   0.7254
   0.9380
   0.5815
  -0.2682
   0.4904
   0.9312
  -0.9599
  -0.3116
   0.8743
</PRE>
<B>Program Results</B>
<PRE>
 DF01MD EXAMPLE PROGRAM RESULTS

 Components of cosine transform are

   i      A(i)

   1    28.0536
   2     3.3726
   3   -20.8158
   4     6.0566
   5     5.7317
   6    -3.9347
   7   -12.8074
   8    -6.8780
   9    16.2892
  10   -17.0788
  11    21.7836
  12   -20.8203
  13    -7.3277
  14    -2.5325
  15    -0.3636
  16     7.8792
  17    11.0048
</PRE>

<HR>
<p>
<A HREF=..\libindex.html><B>Return to index</B></A></BODY>
</HTML>