Skip to content

Commit 6d7ab85

Browse files
committed
Add zfft interfaces, FORD docs, a related test.
1 parent 1dbcdb7 commit 6d7ab85

File tree

9 files changed

+382
-3
lines changed

9 files changed

+382
-3
lines changed

.github/workflows/fpm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ jobs:
5454
- name: Run tests
5555
run: |
5656
gfortran --version
57-
fpm test --flag "-O2" tstfft
57+
fpm test --flag "-O2"

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ build*
44
*.o
55
*.a
66
*.so
7-
*.x
7+
*.x
8+
9+
# API-doc
10+
API-doc/

API-doc-FORD-file.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
project: fftpack
3+
summary: A opensource package fftpack v4.0.0 for (modern) Fortran
4+
src_dir: src/
5+
output_dir: API-doc
6+
page_dir: doc/
7+
media_dir: doc/media
8+
display: public
9+
protected
10+
source: true
11+
proc_internals: true
12+
md_extensions: markdown.extensions.toc
13+
graph: true
14+
graph_maxnodes: 250
15+
graph_maxdepth: 5
16+
coloured_edges: true
17+
sort: permission-alpha
18+
extra_mods: iso_fortran_env:https://gcc.gnu.org/onlinedocs/gfortran/ISO_005fFORTRAN_005fENV.html
19+
iso_c_binding:https://gcc.gnu.org/onlinedocs/gfortran/ISO_005fC_005fBINDING.html#ISO_005fC_005fBINDING
20+
print_creation_date: true
21+
creation_date: %Y-%m-%d %H:%M %z
22+
project_github: https://github.com/certik/fftpack
23+
license: by-sa
24+
author: Paul N. Swarztrauber & fftpack contributors
25+
github: https://github.com/certik/fftpack
26+
dbg: true
27+
parallel: 4
28+
---
29+
30+
[TOC]
31+
32+
@warning This API documentation for the certik/fftpack v4.0.0 is a work in progress.
33+
34+
Fortran FFTPACK API Documentation
35+
=================================
36+
37+
This is the main API documentation landing page generated by [FORD].
38+
The documentation for comment markup in source code, running [FORD] and the [FORD project file] are all maintained on the [FORD wiki].
39+
40+
[FORD]: https://github.com/Fortran-FOSS-Programmers/ford#readme
41+
[FORD wiki]: https://github.com/Fortran-FOSS-Programmers/ford/wiki
42+
[FORD project file]: https://github.com/certik/fftpack/blob/master/API-doc-FORD-file.md
43+
44+
A package of fortran subprograms for the fast fourier transform of periodic and other symmetric sequences.
45+
46+
## Getting started
47+
### Get the code
48+
```bash
49+
git clone https://github.com/certik/fftpack.git
50+
cd fftpack
51+
```
52+
53+
### Build with [fortran-lang/fpm](https://github.com/fortran-lang/fpm)
54+
Fortran Package Manager (fpm) is a great package manager and build system for Fortran.
55+
You can build using provided `fpm.toml`:
56+
```bash
57+
fpm build --flag "-O2"
58+
fpm test --flag "-O2" tstfft
59+
```
60+
To use `fftpack` within your `fpm` project, add the following to your `fpm.toml` file:
61+
```toml
62+
[dependencies]
63+
fftpack = { git="https://github.com/certik/fftpack.git" }
64+
```
65+
66+
## Build with Make
67+
Alternatively, you can build using provided `Makefile`:
68+
```bash
69+
make
70+
```
71+
72+
## Links
73+
[netlib/dfftpack1.0(fftpack4.0)](http://www.netlib.org/fftpack/)
74+

doc/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: Contributing and specs
3+
---
4+
5+
@warning
6+
This page is currently under construction!

doc/specs/fftpack.md

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
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+
```

doc/specs/index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: Specifications (specs)
3+
---
4+
5+
# Fortran fftpack Specifications (specs)
6+
7+
[TOC]
8+
9+
## Experimental Features & Modules
10+
11+
- [fftpack](./fftpack.html) - fftpack module.
12+
13+
## Released/Stable Features & Modules
14+
15+
- (None yet)

fpm.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ auto-examples = false
1818
[[test]]
1919
name = "tstfft"
2020
source-dir = "test"
21-
main = "tstfft.f"
21+
main = "tstfft.f"
22+
23+
[[test]]
24+
name = "fftpack_zfft"
25+
source-dir = "test"
26+
main = "test_fftpack_zfft.f90"

src/fftpack.f90

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module fftpack
2+
3+
use iso_fortran_env, only: dp => real64
4+
implicit none
5+
private
6+
7+
public :: zffti, zfftf, zfftb
8+
9+
interface
10+
11+
!> Version: experimental
12+
!>
13+
!> Initialize `zfftf` and `zfftb`.
14+
!> ([Specification](../page/specs/fftpack.html#zffti))
15+
pure subroutine zffti(n, wsave)
16+
import dp
17+
integer, intent(in) :: n
18+
real(kind=dp), intent(out) :: wsave(*)
19+
end subroutine zffti
20+
21+
!> Version: experimental
22+
!>
23+
!> Forward transform of a double complex periodic sequence.
24+
!> ([Specification](../page/specs/fftpack.html#zfftf))
25+
pure subroutine zfftf(n, c, wsave)
26+
import dp
27+
integer, intent(in) :: n
28+
complex(kind=dp), intent(inout) :: c(*)
29+
real(kind=dp), intent(inout) :: wsave(*)
30+
end subroutine zfftf
31+
32+
!> Version: experimental
33+
!>
34+
!> Unnormalized inverse of `zfftf`.
35+
!> ([Specification](../page/specs/fftpack.html#zfftb))
36+
pure subroutine zfftb(n, c, wsave)
37+
import dp
38+
integer, intent(in) :: n
39+
complex(kind=dp), intent(inout) :: c(*)
40+
real(kind=dp), intent(inout) :: wsave(*)
41+
end subroutine zfftb
42+
43+
end interface
44+
45+
end module fftpack

0 commit comments

Comments
 (0)