Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pypocketfft
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
4
Issues
4
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Reinecke
pypocketfft
Commits
8ef32034
Commit
8ef32034
authored
May 05, 2019
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into 'master'
Develop See merge request
!2
parents
66a05b14
5f09d105
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
244 additions
and
194 deletions
+244
-194
pocketfft.cc
pocketfft.cc
+218
-164
test.py
test.py
+26
-30
No files found.
pocketfft.cc
View file @
8ef32034
This diff is collapsed.
Click to expand it.
test.py
View file @
8ef32034
...
...
@@ -32,96 +32,92 @@ def test1D(len):
@
pmp
(
"shp"
,
shapes
)
def
test_fftn
(
shp
):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
+
1j
*
np
.
random
.
rand
(
*
shp
)
-
0.5j
vmax
=
np
.
max
(
np
.
abs
(
pyfftw
.
interfaces
.
numpy_fft
.
fftn
(
a
)))
assert
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
fftn
(
a
),
pypocketfft
.
fftn
(
a
))
<
1e-15
*
vmax
)
assert
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
fftn
(
a
),
pypocketfft
.
fftn
(
a
))
<
1e-15
)
a
=
a
.
astype
(
np
.
complex64
)
assert
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
fftn
(
a
),
pypocketfft
.
fftn
(
a
))
<
5e-7
*
vmax
)
assert
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
fftn
(
a
),
pypocketfft
.
fftn
(
a
))
<
5e-7
)
@
pmp
(
"shp"
,
shapes2D
)
@
pmp
(
"axes"
,
((
0
,),(
1
,),(
0
,
1
),(
1
,
0
)))
def
test_fftn2D
(
shp
,
axes
):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
+
1j
*
np
.
random
.
rand
(
*
shp
)
-
0.5j
vmax
=
np
.
max
(
np
.
abs
(
pyfftw
.
interfaces
.
numpy_fft
.
fftn
(
a
,
axes
=
axes
)))
assert
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
fftn
(
a
,
axes
=
axes
),
pypocketfft
.
fftn
(
a
,
axes
=
axes
))
<
1e-15
*
vmax
)
assert
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
fftn
(
a
,
axes
=
axes
),
pypocketfft
.
fftn
(
a
,
axes
=
axes
))
<
1e-15
)
a
=
a
.
astype
(
np
.
complex64
)
assert
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
fftn
(
a
,
axes
=
axes
),
pypocketfft
.
fftn
(
a
,
axes
=
axes
))
<
5e-7
*
vmax
)
assert
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
fftn
(
a
,
axes
=
axes
),
pypocketfft
.
fftn
(
a
,
axes
=
axes
))
<
5e-7
)
@
pmp
(
"shp"
,
shapes
)
def
test_rfftn
(
shp
):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
vmax
=
np
.
max
(
np
.
abs
(
pyfftw
.
interfaces
.
numpy_fft
.
fftn
(
a
)))
assert
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
rfftn
(
a
),
pypocketfft
.
rfftn
(
a
))
<
1e-15
*
vmax
)
assert
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
rfftn
(
a
),
pypocketfft
.
rfftn
(
a
))
<
1e-15
)
a
=
a
.
astype
(
np
.
float32
)
assert
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
rfftn
(
a
),
pypocketfft
.
rfftn
(
a
))
<
5e-7
*
vmax
)
assert
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
rfftn
(
a
),
pypocketfft
.
rfftn
(
a
))
<
5e-7
)
@
pmp
(
"shp"
,
shapes
)
def
test_rfft_scipy
(
shp
):
for
i
in
range
(
len
(
shp
)):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
assert
(
_l2error
(
pyfftw
.
interfaces
.
scipy_fftpack
.
rfft
(
a
,
axis
=
i
),
pypocketfft
.
rfft_scipy
(
a
,
axis
=
i
))
<
1e-15
)
assert
(
_l2error
(
pyfftw
.
interfaces
.
scipy_fftpack
.
irfft
(
a
,
axis
=
i
),
pypocketfft
.
irfft_scipy
(
a
,
axis
=
i
,
fct
=
1.
/
a
.
shape
[
i
]))
<
1e-15
)
@
pmp
(
"shp"
,
shapes2D
)
@
pmp
(
"axes"
,
((
0
,),(
1
,),(
0
,
1
),(
1
,
0
)))
def
test_rfftn2D
(
shp
,
axes
):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
vmax
=
np
.
max
(
np
.
abs
(
pyfftw
.
interfaces
.
numpy_fft
.
rfftn
(
a
,
axes
=
axes
)))
assert
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
rfftn
(
a
,
axes
=
axes
),
pypocketfft
.
rfftn
(
a
,
axes
=
axes
))
<
1e-15
*
vmax
)
assert
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
rfftn
(
a
,
axes
=
axes
),
pypocketfft
.
rfftn
(
a
,
axes
=
axes
))
<
1e-15
)
a
=
a
.
astype
(
np
.
float32
)
assert
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
rfftn
(
a
,
axes
=
axes
),
pypocketfft
.
rfftn
(
a
,
axes
=
axes
))
<
5e-7
*
vmax
)
assert
(
_l2error
(
pyfftw
.
interfaces
.
numpy_fft
.
rfftn
(
a
,
axes
=
axes
),
pypocketfft
.
rfftn
(
a
,
axes
=
axes
))
<
5e-7
)
@
pmp
(
"shp"
,
shapes
)
def
test_identity
(
shp
):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
+
1j
*
np
.
random
.
rand
(
*
shp
)
-
0.5j
vmax
=
np
.
max
(
np
.
abs
(
a
))
assert
(
_l2error
(
pypocketfft
.
ifftn
(
pypocketfft
.
fftn
(
a
),
fct
=
1.
/
a
.
size
),
a
)
<
1.5e-15
*
vmax
)
assert
(
_l2error
(
pypocketfft
.
ifftn
(
pypocketfft
.
fftn
(
a
),
fct
=
1.
/
a
.
size
),
a
)
<
1.5e-15
)
tmp
=
a
.
copy
()
assert
(
pypocketfft
.
ifftn
(
pypocketfft
.
fftn
(
tmp
,
inplace
=
True
),
fct
=
1.
/
a
.
size
,
inplace
=
True
)
is
tmp
)
assert
(
_l2error
(
tmp
,
a
)
<
1.5e-15
*
vmax
)
assert
(
_l2error
(
tmp
,
a
)
<
1.5e-15
)
a
=
a
.
astype
(
np
.
complex64
)
assert
(
_l2error
(
pypocketfft
.
ifftn
(
pypocketfft
.
fftn
(
a
),
fct
=
1.
/
a
.
size
),
a
)
<
6e-7
*
vmax
)
assert
(
_l2error
(
pypocketfft
.
ifftn
(
pypocketfft
.
fftn
(
a
),
fct
=
1.
/
a
.
size
),
a
)
<
6e-7
)
@
pmp
(
"shp"
,
shapes
)
def
test_identity_r
(
shp
):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
b
=
a
.
astype
(
np
.
float32
)
vmax
=
np
.
max
(
np
.
abs
(
a
))
for
ax
in
range
(
a
.
ndim
):
n
=
a
.
shape
[
ax
]
assert
(
_l2error
(
pypocketfft
.
irfftn
(
pypocketfft
.
rfftn
(
a
,(
ax
,)),(
ax
,),
lastsize
=
n
,
fct
=
1.
/
n
),
a
)
<
1e-15
*
vmax
)
assert
(
_l2error
(
pypocketfft
.
irfftn
(
pypocketfft
.
rfftn
(
b
,(
ax
,)),(
ax
,),
lastsize
=
n
,
fct
=
1.
/
n
),
b
)
<
5e-7
*
vmax
)
assert
(
_l2error
(
pypocketfft
.
irfftn
(
pypocketfft
.
rfftn
(
a
,(
ax
,)),(
ax
,),
lastsize
=
n
,
fct
=
1.
/
n
),
a
)
<
1e-15
)
assert
(
_l2error
(
pypocketfft
.
irfftn
(
pypocketfft
.
rfftn
(
b
,(
ax
,)),(
ax
,),
lastsize
=
n
,
fct
=
1.
/
n
),
b
)
<
5e-7
)
@
pmp
(
"shp"
,
shapes
)
def
test_identity_r2
(
shp
):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
+
1j
*
np
.
random
.
rand
(
*
shp
)
-
0.5j
a
=
pypocketfft
.
rfftn
(
pypocketfft
.
irfftn
(
a
))
fct
=
1.
/
pypocketfft
.
irfftn
(
a
).
size
vmax
=
np
.
max
(
np
.
abs
(
a
))
assert
(
_l2error
(
pypocketfft
.
rfftn
(
pypocketfft
.
irfftn
(
a
),
fct
=
fct
),
a
)
<
1e-15
*
vmax
)
assert
(
_l2error
(
pypocketfft
.
rfftn
(
pypocketfft
.
irfftn
(
a
),
fct
=
fct
),
a
)
<
1e-15
)
@
pmp
(
"shp"
,
shapes2D
+
shapes3D
)
def
test_hartley2
(
shp
):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
v1
=
pypocketfft
.
hartley2
(
a
)
v2
=
pypocketfft
.
fftn
(
a
.
astype
(
np
.
complex128
))
vmax
=
np
.
max
(
np
.
abs
(
v1
))
v2
=
v2
.
real
+
v2
.
imag
assert
(
_l2error
(
v1
,
v2
)
<
1e-15
*
vmax
)
assert
(
_l2error
(
v1
,
v2
)
<
1e-15
)
@
pmp
(
"shp"
,
shapes
)
def
test_hartley_identity
(
shp
):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
v1
=
pypocketfft
.
hartley
(
pypocketfft
.
hartley
(
a
))
/
a
.
size
vmax
=
np
.
max
(
np
.
abs
(
a
))
assert
(
_l2error
(
a
,
v1
)
<
1e-15
*
vmax
)
assert
(
_l2error
(
a
,
v1
)
<
1e-15
)
@
pmp
(
"shp"
,
shapes
)
def
test_hartley2_identity
(
shp
):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
v1
=
pypocketfft
.
hartley2
(
pypocketfft
.
hartley2
(
a
))
/
a
.
size
vmax
=
np
.
max
(
np
.
abs
(
a
))
assert
(
_l2error
(
a
,
v1
)
<
1e-15
*
vmax
)
assert
(
_l2error
(
a
,
v1
)
<
1e-15
)
v1
=
a
.
copy
()
assert
(
pypocketfft
.
hartley2
(
pypocketfft
.
hartley2
(
v1
,
inplace
=
True
),
fct
=
1.
/
a
.
size
,
inplace
=
True
)
is
v1
)
assert
(
_l2error
(
a
,
v1
)
<
1e-15
*
vmax
)
assert
(
_l2error
(
a
,
v1
)
<
1e-15
)
@
pmp
(
"shp"
,
shapes2D
)
@
pmp
(
"axes"
,
((
0
,),(
1
,),(
0
,
1
),(
1
,
0
)))
def
test_hartley2_2D
(
shp
,
axes
):
a
=
np
.
random
.
rand
(
*
shp
)
-
0.5
fct
=
1.
/
np
.
prod
(
np
.
take
(
shp
,
axes
))
vmax
=
np
.
max
(
np
.
abs
(
a
))
assert
(
_l2error
(
pypocketfft
.
hartley2
(
pypocketfft
.
hartley2
(
a
,
axes
=
axes
),
axes
=
axes
,
fct
=
fct
),
a
)
<
1e-15
*
vmax
)
assert
(
_l2error
(
pypocketfft
.
hartley2
(
pypocketfft
.
hartley2
(
a
,
axes
=
axes
),
axes
=
axes
,
fct
=
fct
),
a
)
<
1e-15
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment