You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The method is most efficient when n-1 is a product of small primes.
1117
+
1118
+
`wsave`: Shall be a `real` and rank-1 array.
1119
+
This argument is `intent(out)`.
1120
+
A work array which must be dimensioned at least `3*n+15`.
1121
+
Different `wsave` arrays are required for different values of `n`.
1122
+
The contents of `wsave` must not be changed between calls of `dcost`.
1123
+
1124
+
#### Example
1125
+
1126
+
```fortran
1127
+
program demo_dcosti
1128
+
use fftpack, only: dcosti
1129
+
real(kind=8) :: w(3*4 + 15)
1130
+
call dcosti(4, w) !! Initializes the array `w` which is used in subroutine `dcost`.
1131
+
end program demo_dcosti
1132
+
```
1133
+
1134
+
### `dcost`
1135
+
1136
+
#### Description
1137
+
1138
+
Computes the discrete fourier cosine transform of an even sequence `x(i)`.
1139
+
The transform is defined below at output parameter `x`.
1140
+
1141
+
`dcost` is the unnormalized inverse of itself since a call of `dcost` followed by another call of `dcost` will multiply the input sequence `x` by `2*(n-1)`.
1142
+
The transform is defined below at output parameter `x`.
1143
+
1144
+
The array `wsave` which is used by subroutine `dcost` must be initialized by calling subroutine `dcosti(n,wsave)`.
The method is most efficient when `n-1` is a product of small primes.
1165
+
1166
+
`x`: Shall be a `real` and rank-1 array.
1167
+
This argument is `intent(inout)`.
1168
+
An array which contains the sequence to be transformed.
1169
+
```
1170
+
for i=1,...,n
1171
+
1172
+
x(i) = x(1)+(-1)**(i-1)*x(n)
1173
+
1174
+
+ the sum from k=2 to k=n-1
1175
+
1176
+
2*x(k)*cos((k-1)*(i-1)*pi/(n-1))
1177
+
1178
+
a call of dcost followed by another call of
1179
+
dcost will multiply the sequence x by 2*(n-1)
1180
+
hence dcost is the unnormalized inverse
1181
+
of itself.
1182
+
```
1183
+
1184
+
`wsave`: Shall be a `real` and rank-1 array.
1185
+
This argument is `intent(in)`.
1186
+
A work array which must be dimensioned at least `3*n+15` in the program that calls `dcost`.
1187
+
The `wsave` array must be initialized by calling subroutine `dcosti(n,wsave)` and a different `wsave` array must be used for each different value of `n`.
1188
+
This initialization does not have to be repeated so long as `n` remains unchanged thus subsequent
1189
+
transforms can be obtained faster than the first.
1190
+
Contains initialization calculations which must not be destroyed between calls of `dcost`.
1191
+
1192
+
#### Example
1193
+
1194
+
```fortran
1195
+
program demo_dcost
1196
+
use fftpack, only: dcosti, dcost
1197
+
real(kind=8) :: x(4) = [1, 2, 3, 4]
1198
+
real(kind=8) :: w(3*4 + 15)
1199
+
call dcosti(4, w)
1200
+
call dcost(4, x, w) !! Computes the discrete fourier cosine (forward) transform of an even sequence, `x`(unnormalized): [15.0, -4.0, 0.0, -1.0]
1201
+
call dcost(4, x, w) !! Computes the discrete fourier cosine (backward) transform of an even sequence, `x`(unnormalized): [6.0, 12.0, 18.0, 24.0]
1202
+
end program demo_dcost
1203
+
```
1204
+
1205
+
### `dct`
1206
+
1207
+
#### Description
1208
+
1209
+
Discrete fourier cosine (forward) transform of an even sequence.
Defines the length of the Fourier transform. If `n` is not specified (the default) then `n = size(x)`. If `n <= size(x)`, `x` is truncated, if `n > size(x)`, `x` is zero-padded.
1232
+
1233
+
#### Return value
1234
+
1235
+
Returns a `real` and rank-1 array, the Discrete-Cosine Transform (DCT) of `x`.
1236
+
1237
+
#### Notes
1238
+
1239
+
Within numerical accuracy, `y == dct(idct(y))/2*(size(y) - 1)`.
Defines the length of the Fourier transform. If `n` is not specified (the default) then `n = size(x)`. If `n <= size(x)`, `x` is truncated, if `n > size(x)`, `x` is zero-padded.
1282
+
1283
+
#### Return value
1284
+
1285
+
Returns a `real` and rank-1 array, the inverse Discrete-Cosine Transform (iDCT) of `x`.
0 commit comments