|
| 1 | +--- |
| 2 | +title: FFTPACK |
| 3 | +--- |
| 4 | + |
| 5 | +# The `fftpack` module |
| 6 | + |
| 7 | +[TOC] |
| 8 | + |
| 9 | +## `zffti` |
| 10 | + |
| 11 | +### Description |
| 12 | + |
| 13 | +Initializes the array `wsave` which is used in both `zfftf` and `zfftb`. |
| 14 | +The prime factorization of `n` together with a tabulation of the trigonometric functions are computed and |
| 15 | +stored in `wsave`. |
| 16 | + |
| 17 | +### Status |
| 18 | + |
| 19 | +Experimental. |
| 20 | + |
| 21 | +### Class |
| 22 | + |
| 23 | +Pure function. |
| 24 | + |
| 25 | +### Snytax |
| 26 | + |
| 27 | +`call [[fftpack(module):zffti(interface)]](n, wsave)` |
| 28 | + |
| 29 | +### Argument |
| 30 | + |
| 31 | +`n`: Shall be an `integer` scalar. |
| 32 | +This argument is `intent(in)`. |
| 33 | +The length of the sequence to be transformed. |
| 34 | + |
| 35 | +`wsave`: Shall be a `real` array. |
| 36 | +This argument is `intent(out)`. |
| 37 | +A work array which must be dimensioned at least `4*n+15`. |
| 38 | +The same work array can be used for both `zfftf` and `zfftb` |
| 39 | +as long as `n` remains unchanged. Different `wsave` arrays |
| 40 | +are required for different values of `n`. |
| 41 | + |
| 42 | +#### Warning |
| 43 | + |
| 44 | +The contents of `wsave` must not be changed between calls of `zfftf` or `zfftb`. |
| 45 | + |
| 46 | +### Example |
| 47 | + |
| 48 | +```fortran |
| 49 | +program demo_zffti |
| 50 | + use fftpack, only: zffti |
| 51 | + complex(kind=8) :: x(4) |
| 52 | + real(kind=8) :: w(31) |
| 53 | + x = [real(kind=8) :: 1.0, 2.0, 3.0, 4.0] |
| 54 | + call zffti(4,w) |
| 55 | +end program demo_zffti |
| 56 | +``` |
| 57 | + |
| 58 | +## `zfftf` |
| 59 | + |
| 60 | +### Description |
| 61 | + |
| 62 | +Computes the forward complex discrete fourier |
| 63 | +transform (the fourier analysis). |
| 64 | +Equivalently, `zfftf` computes |
| 65 | +the fourier coefficients of a complex periodic sequence. |
| 66 | +the transform is defined below at output parameter `c`. |
| 67 | + |
| 68 | +The transform is not normalized. to obtain a normalized transform |
| 69 | +the output must be divided by `n`. otherwise a call of `zfftf` |
| 70 | +followed by a call of `zfftb` will multiply the sequence by `n`. |
| 71 | + |
| 72 | +The array `wsave` which is used by subroutine `zfftf` must be |
| 73 | +initialized by calling subroutine `zffti(n,wsave)`. |
| 74 | + |
| 75 | +### Status |
| 76 | + |
| 77 | +Experimental. |
| 78 | + |
| 79 | +### Class |
| 80 | + |
| 81 | +Pure function. |
| 82 | + |
| 83 | +### Snytax |
| 84 | + |
| 85 | +`call [[fftpack(module):zfftf(interface)]](n, c, wsave)` |
| 86 | + |
| 87 | +### Argument |
| 88 | + |
| 89 | +`n`: Shall be an `integer` scalar. |
| 90 | +This argument is `intent(in)`. |
| 91 | +The length of the `complex` sequence `c`. The method is more efficient when `n` is the product of small primes. |
| 92 | + |
| 93 | +`c`: Shall be a `complex` array. |
| 94 | +This argument is `intent(inout)`. |
| 95 | +A `complex` array of length `n` which contains the sequence. |
| 96 | +``` |
| 97 | +for j=1,...,n |
| 98 | +
|
| 99 | + c(j)=the sum from k=1,...,n of |
| 100 | +
|
| 101 | + c(k)*exp(-i*(j-1)*(k-1)*2*pi/n) |
| 102 | +
|
| 103 | + where i=sqrt(-1) |
| 104 | +``` |
| 105 | + |
| 106 | +`wsave`: Shall be a `real` array. |
| 107 | +This argument is `intent(inout)`. |
| 108 | +A `real` work array which must be dimensioned at least `4n+15` in the program that calls `zfftf`. The wsave array must be initialized by calling subroutine `zffti(n,wsave)` and a different wsave array must be used for each different value of `n`. This initialization does not have to be repeated so long as `n` remains unchanged thus subsequent transforms can be obtained faster than the first. The same wsave array can be used by `zfftf` and `zfftb`. |
| 109 | +Contains initialization calculations which must not be destroyed between calls of subroutine `zfftf` or `zfftb`. |
| 110 | + |
| 111 | +#### Warning |
| 112 | + |
| 113 | +The contents of `wsave` must not be changed between calls of `zfftf` or `zfftb`. |
| 114 | + |
| 115 | +### Example |
| 116 | + |
| 117 | +```fortran |
| 118 | +program demo_zfftf |
| 119 | + use fftpack, only: zffti, zfftf |
| 120 | + complex(kind=8) :: x(4) |
| 121 | + real(kind=8) :: w(31) |
| 122 | + x = [real(kind=8) :: 1.0, 2.0, 3.0, 4.0] |
| 123 | + call zffti(4,w) |
| 124 | + call zfftf(4,x,w) !! `x` returns [(10.0,0.0), (-2.0,2.0), (-2.0,0.0), (-2.0,-2.0)]. |
| 125 | +end program demo_zfftf |
| 126 | +``` |
| 127 | + |
| 128 | +## `zfftb` |
| 129 | + |
| 130 | +### Description |
| 131 | + |
| 132 | +Unnormalized inverse of `zfftf`. |
| 133 | + |
| 134 | +Computes the backward `complex` discrete fourier |
| 135 | +transform (the fourier synthesis). Equivalently, `zfftb` computes |
| 136 | +a `complex` periodic sequence from its fourier coefficients. |
| 137 | +The transform is defined below at output parameter `c`. |
| 138 | + |
| 139 | +The transform is not normalized. to obtain a normalized transform |
| 140 | +the output must be divided by `n`. otherwise a call of `zfftf` |
| 141 | +followed by a call of `zfftb` will multiply the sequence by `n`. |
| 142 | + |
| 143 | +The array `wsave` which is used by subroutine `zfftf` must be |
| 144 | +initialized by calling subroutine `zffti(n,wsave)`. |
| 145 | + |
| 146 | +### Status |
| 147 | + |
| 148 | +Experimental. |
| 149 | + |
| 150 | +### Class |
| 151 | + |
| 152 | +Pure function. |
| 153 | + |
| 154 | +### Snytax |
| 155 | + |
| 156 | +`call [[fftpack(module):zfftb(interface)]](n, c, wsave)` |
| 157 | + |
| 158 | +### Argument |
| 159 | + |
| 160 | +`n`: Shall be an `integer` scalar. |
| 161 | +This argument is `intent(in)`. |
| 162 | +The length of the `complex` sequence `c`. The method is more efficient when `n` is the product of small primes. |
| 163 | + |
| 164 | +`c`: Shall be a `complex` array. |
| 165 | +This argument is `intent(inout)`. |
| 166 | +A `complex` array of length `n` which contains the sequence. |
| 167 | +``` |
| 168 | +for j=1,...,n |
| 169 | +
|
| 170 | + c(j)=the sum from k=1,...,n of |
| 171 | +
|
| 172 | + c(k)*exp(-i*(j-1)*(k-1)*2*pi/n) |
| 173 | +
|
| 174 | + where i=sqrt(-1) |
| 175 | +``` |
| 176 | + |
| 177 | +`wsave`: Shall be a `real` array. |
| 178 | +This argument is `intent(inout)`. |
| 179 | +A `real` work array which must be dimensioned at least `4n+15` in the program that calls `zfftf`. The wsave array must be initialized by calling subroutine `zffti(n,wsave)` and a different wsave array must be used for each different value of `n`. This initialization does not have to be repeated so long as `n` remains unchanged thus subsequent transforms can be obtained faster than the first. The same wsave array can be used by `zfftf` and `zfftb`. |
| 180 | +Contains initialization calculations which must not be destroyed between calls of subroutine `zfftf` or `zfftb`. |
| 181 | + |
| 182 | +#### Warning |
| 183 | + |
| 184 | +The contents of `wsave` must not be changed between calls of `zfftf` or `zfftb`. |
| 185 | + |
| 186 | +### Example |
| 187 | + |
| 188 | +```fortran |
| 189 | +program demo_zfftb |
| 190 | + use fftpack, only: zffti, zfftf, zfftb |
| 191 | + complex(kind=8) :: x(4) |
| 192 | + real(kind=8) :: w(31) |
| 193 | + x = [real(kind=8) :: 1.0, 2.0, 3.0, 4.0] |
| 194 | + call zffti(4,w) |
| 195 | + call zfftf(4,x,w) !! `x` returns [(10.0,0.0), (-2.0,2.0), (-2.0,0.0), (-2.0,-2.0)]. |
| 196 | + call zfftb(4,x,w) !! `x` returns [(4.0,0.0), (8.0,0.0), (12.0,0.0), (16.0,0.0)]. |
| 197 | +end program demo_zfftb |
| 198 | +``` |
0 commit comments