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
9918b72b
Commit
9918b72b
authored
Jul 20, 2019
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tweak docstrings; simplify tests
parent
ee5193a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
71 deletions
+38
-71
pypocketfft.cc
pypocketfft.cc
+15
-2
test.py
test.py
+23
-69
No files found.
pypocketfft.cc
View file @
9918b72b
...
...
@@ -597,11 +597,18 @@ axes : list of integers
inorm : int
Normalization type
0 : no normalization
1 : divide by sqrt(N)
1 :
make transform orthogonal and
divide by sqrt(N)
2 : divide by N
where N is the product of n_i for every transformed axis i.
n_i is 2*(<axis_length>-1 for type 1 and 2*<axis length>
for types 2, 3, 4.
Making the transform orthogonal involves the following additional steps
for every 1D sub-transform:
Type 1 : multiply first and last input value by sqrt(2)
divide first and last output value by sqrt(2)
Type 2 : divide first output value by sqrt(2)
Type 3 : multiply first input value by sqrt(2)
Type 4 : nothing
out : numpy.ndarray (same shape and data type as `a`)
May be identical to `a`, but if it isn't, it must not overlap with `a`.
If None, a new array is allocated to store the output.
...
...
@@ -629,11 +636,17 @@ axes : list of integers
inorm : int
Normalization type
0 : no normalization
1 : divide by sqrt(N)
1 :
make transform orthogonal and
divide by sqrt(N)
2 : divide by N
where N is the product of n_i for every transformed axis i.
n_i is 2*(<axis_length>+1 for type 1 and 2*<axis length>
for types 2, 3, 4.
Making the transform orthogonal involves the following additional steps
for every 1D sub-transform:
Type 1 : nothing
Type 2 : divide first output value by sqrt(2)
Type 3 : multiply first input value by sqrt(2)
Type 4 : nothing
out : numpy.ndarray (same shape and data type as `a`)
May be identical to `a`, but if it isn't, it must not overlap with `a`.
If None, a new array is allocated to store the output.
...
...
test.py
View file @
9918b72b
...
...
@@ -55,36 +55,27 @@ def irfft_scipy(a, axis, inorm=0, out=None, nthreads=1):
forward
=
False
,
inorm
=
inorm
,
out
=
out
,
nthreads
=
nthreads
)
tol
=
{
np
.
float32
:
6e-7
,
np
.
float64
:
1.5e-15
,
np
.
longfloat
:
1e-18
}
ctype
=
{
np
.
float32
:
np
.
complex64
,
np
.
float64
:
np
.
complex128
,
np
.
longfloat
:
np
.
longcomplex
}
@
pmp
(
"len"
,
len1D
)
@
pmp
(
"inorm"
,
[
0
,
1
,
2
])
def
test1D
(
len
,
inorm
):
@
pmp
(
"dtype"
,
[
np
.
float32
,
np
.
float64
,
np
.
longfloat
])
def
test1D
(
len
,
inorm
,
dtype
):
a
=
np
.
random
.
rand
(
len
)
-
0.5
+
1j
*
np
.
random
.
rand
(
len
)
-
0.5j
b
=
a
.
astype
(
np
.
complex64
)
c
=
a
.
astype
(
np
.
complex256
)
_assert_close
(
a
,
ifftn
(
fftn
(
c
,
inorm
=
inorm
),
inorm
=
2
-
inorm
),
1e-18
)
assert_
(
_l2error
(
a
,
ifftn
(
fftn
(
a
,
inorm
=
inorm
),
inorm
=
2
-
inorm
))
<
1.5e-15
)
a
=
a
.
astype
(
ctype
[
dtype
])
eps
=
tol
[
dtype
]
assert_
(
_l2error
(
a
,
ifftn
(
fftn
(
a
,
inorm
=
inorm
),
inorm
=
2
-
inorm
))
<
eps
)
assert_
(
_l2error
(
a
.
real
,
ifftn
(
fftn
(
a
.
real
,
inorm
=
inorm
),
inorm
=
2
-
inorm
))
<
1.5e-15
)
<
eps
)
assert_
(
_l2error
(
a
.
real
,
fftn
(
ifftn
(
a
.
real
,
inorm
=
inorm
),
inorm
=
2
-
inorm
))
<
1.5e-15
)
<
eps
)
assert_
(
_l2error
(
a
.
real
,
irfftn
(
rfftn
(
a
.
real
,
inorm
=
inorm
),
inorm
=
2
-
inorm
,
lastsize
=
len
))
<
1.5e-15
)
inorm
=
2
-
inorm
,
lastsize
=
len
))
<
eps
)
tmp
=
a
.
copy
()
assert_
(
ifftn
(
fftn
(
tmp
,
out
=
tmp
,
inorm
=
inorm
),
out
=
tmp
,
inorm
=
2
-
inorm
)
is
tmp
)
assert_
(
_l2error
(
tmp
,
a
)
<
1.5e-15
)
assert_
(
_l2error
(
b
,
ifftn
(
fftn
(
b
,
inorm
=
inorm
),
inorm
=
2
-
inorm
))
<
6e-7
)
assert_
(
_l2error
(
b
.
real
,
ifftn
(
fftn
(
b
.
real
,
inorm
=
inorm
),
inorm
=
2
-
inorm
))
<
6e-7
)
assert_
(
_l2error
(
b
.
real
,
fftn
(
ifftn
(
b
.
real
,
inorm
=
inorm
),
inorm
=
2
-
inorm
))
<
6e-7
)
assert_
(
_l2error
(
b
.
real
,
irfftn
(
rfftn
(
b
.
real
,
inorm
=
inorm
),
lastsize
=
len
,
inorm
=
2
-
inorm
))
<
6e-7
)
tmp
=
b
.
copy
()
assert_
(
ifftn
(
fftn
(
tmp
,
out
=
tmp
,
inorm
=
inorm
),
out
=
tmp
,
inorm
=
2
-
inorm
)
is
tmp
)
assert_
(
_l2error
(
tmp
,
b
)
<
6e-7
)
assert_
(
_l2error
(
tmp
,
a
)
<
eps
)
@
pmp
(
"shp"
,
shapes
)
...
...
@@ -206,54 +197,17 @@ def test_genuine_hartley_2D(shp, axes):
@
pmp
(
"len"
,
len1D
)
@
pmp
(
"inorm"
,
[
0
,
1
,
2
])
@
pmp
(
"type"
,
[
1
,
2
,
3
])
def
testdcst1D
(
len
,
inorm
,
type
):
a
=
np
.
random
.
rand
(
len
)
-
0.5
b
=
a
.
astype
(
np
.
float32
)
c
=
a
.
astype
(
np
.
float128
)
itp
=
(
0
,
1
,
3
,
2
,
4
)
itype
=
itp
[
type
]
if
type
!=
1
or
len
>
1
:
_assert_close
(
a
,
pypocketfft
.
dct
(
pypocketfft
.
dct
(
c
,
inorm
=
inorm
,
type
=
type
),
inorm
=
2
-
inorm
,
type
=
itype
),
2e-18
)
_assert_close
(
a
,
pypocketfft
.
dct
(
pypocketfft
.
dct
(
a
,
inorm
=
inorm
,
type
=
type
),
inorm
=
2
-
inorm
,
type
=
itype
),
1.5e-15
)
_assert_close
(
b
,
pypocketfft
.
dct
(
pypocketfft
.
dct
(
b
,
inorm
=
inorm
,
type
=
type
),
inorm
=
2
-
inorm
,
type
=
itype
),
6e-7
)
_assert_close
(
a
,
pypocketfft
.
dst
(
pypocketfft
.
dst
(
c
,
inorm
=
inorm
,
type
=
type
),
inorm
=
2
-
inorm
,
type
=
itype
),
2e-18
)
_assert_close
(
a
,
pypocketfft
.
dst
(
pypocketfft
.
dst
(
a
,
inorm
=
inorm
,
type
=
type
),
inorm
=
2
-
inorm
,
type
=
itype
),
1.5e-15
)
_assert_close
(
b
,
pypocketfft
.
dst
(
pypocketfft
.
dst
(
b
,
inorm
=
inorm
,
type
=
type
),
inorm
=
2
-
inorm
,
type
=
itype
),
6e-7
)
@
pmp
(
"len"
,
len1D
)
@
pmp
(
"type"
,
[
1
,
2
,
3
])
def
testdcst1Dortho
(
len
,
type
):
a
=
np
.
random
.
rand
(
len
)
-
0.5
b
=
a
.
astype
(
np
.
float32
)
c
=
a
.
astype
(
np
.
float128
)
itp
=
(
0
,
1
,
3
,
2
,
4
)
itype
=
itp
[
type
]
if
type
!=
1
or
len
>
1
:
_assert_close
(
a
,
pypocketfft
.
dct
(
pypocketfft
.
dct
(
c
,
inorm
=
1
,
type
=
type
),
inorm
=
1
,
type
=
itype
),
2e-18
)
_assert_close
(
a
,
pypocketfft
.
dct
(
pypocketfft
.
dct
(
a
,
inorm
=
1
,
type
=
type
),
inorm
=
1
,
type
=
itype
),
1.5e-15
)
_assert_close
(
b
,
pypocketfft
.
dct
(
pypocketfft
.
dct
(
b
,
inorm
=
1
,
type
=
type
),
inorm
=
1
,
type
=
itype
),
6e-7
)
if
type
!=
1
:
_assert_close
(
a
,
pypocketfft
.
dst
(
pypocketfft
.
dst
(
c
,
inorm
=
1
,
type
=
type
),
inorm
=
1
,
type
=
itype
),
2e-18
)
_assert_close
(
a
,
pypocketfft
.
dst
(
pypocketfft
.
dst
(
a
,
inorm
=
1
,
type
=
type
),
inorm
=
1
,
type
=
itype
),
1.5e-15
)
_assert_close
(
b
,
pypocketfft
.
dst
(
pypocketfft
.
dst
(
b
,
inorm
=
1
,
type
=
type
),
inorm
=
1
,
type
=
itype
),
6e-7
)
# TEMPORARY: separate test for DCT/DST IV, since they are less accurate
@
pmp
(
"len"
,
len1D
)
@
pmp
(
"inorm"
,
[
0
,
1
,
2
])
@
pmp
(
"type"
,
[
4
])
def
testdcst1D4
(
len
,
inorm
,
type
):
a
=
np
.
random
.
rand
(
len
)
-
0.5
b
=
a
.
astype
(
np
.
float32
)
c
=
a
.
astype
(
np
.
float128
)
@
pmp
(
"inorm"
,
[
0
,
1
])
# inorm==2 not needed, tested via inverse
@
pmp
(
"type"
,
[
1
,
2
,
3
,
4
])
@
pmp
(
"dtype"
,
[
np
.
float32
,
np
.
float64
,
np
.
longfloat
])
def
testdcst1D
(
len
,
inorm
,
type
,
dtype
):
a
=
(
np
.
random
.
rand
(
len
)
-
0.5
).
astype
(
dtype
)
eps
=
tol
[
dtype
]
itp
=
(
0
,
1
,
3
,
2
,
4
)
if
type
==
4
and
len
%
2
==
1
:
# relaxed accuracies for odd-length type 4 transforms
special_tol
=
{
np
.
float32
:
4e-5
,
np
.
float64
:
6e-14
,
np
.
longfloat
:
4e-17
}
eps
=
special_tol
[
dtype
]
itype
=
itp
[
type
]
if
type
!=
1
or
len
>
1
:
_assert_close
(
a
,
pypocketfft
.
dct
(
pypocketfft
.
dct
(
c
,
inorm
=
inorm
,
type
=
type
),
inorm
=
2
-
inorm
,
type
=
itype
),
2e-16
)
_assert_close
(
a
,
pypocketfft
.
dct
(
pypocketfft
.
dct
(
a
,
inorm
=
inorm
,
type
=
type
),
inorm
=
2
-
inorm
,
type
=
itype
),
1.5e-13
)
_assert_close
(
b
,
pypocketfft
.
dct
(
pypocketfft
.
dct
(
b
,
inorm
=
inorm
,
type
=
type
),
inorm
=
2
-
inorm
,
type
=
itype
),
6e-5
)
_assert_close
(
a
,
pypocketfft
.
dst
(
pypocketfft
.
dst
(
c
,
inorm
=
inorm
,
type
=
type
),
inorm
=
2
-
inorm
,
type
=
itype
),
2e-16
)
_assert_close
(
a
,
pypocketfft
.
dst
(
pypocketfft
.
dst
(
a
,
inorm
=
inorm
,
type
=
type
),
inorm
=
2
-
inorm
,
type
=
itype
),
1.5e-13
)
_assert_close
(
b
,
pypocketfft
.
dst
(
pypocketfft
.
dst
(
b
,
inorm
=
inorm
,
type
=
type
),
inorm
=
2
-
inorm
,
type
=
itype
),
6e-5
)
if
type
!=
1
or
len
>
1
:
# there are no length-1 type 1 DCTs
_assert_close
(
a
,
pypocketfft
.
dct
(
pypocketfft
.
dct
(
a
,
inorm
=
inorm
,
type
=
type
),
inorm
=
2
-
inorm
,
type
=
itype
),
eps
)
_assert_close
(
a
,
pypocketfft
.
dst
(
pypocketfft
.
dst
(
a
,
inorm
=
inorm
,
type
=
type
),
inorm
=
2
-
inorm
,
type
=
itype
),
eps
)
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