Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Martin Reinecke
pypocketfft
Commits
4e511317
Commit
4e511317
authored
Aug 11, 2019
by
Martin Reinecke
Browse files
try to write rearrangement code in a clearer fashion
parent
5a83309a
Changes
2
Hide whitespace changes
Inline
Side-by-side
pocketfft_hdronly.h
View file @
4e511317
...
...
@@ -2752,8 +2752,6 @@ template<typename T0> class T_dcst23
template
<
typename
T0
>
class
T_dcst4
{
// even length algorithm from
// https://www.appletonaudio.com/blog/2013/derivation-of-fast-dct-4-algorithm-based-on-dft/
private:
size_t
N
;
unique_ptr
<
pocketfft_c
<
T0
>>
fft
;
...
...
@@ -2789,9 +2787,9 @@ template<typename T0> class T_dcst4
{
// The following code is derived from the FFTW3 function apply_re11()
// and is released under the 3-clause BSD license with friendly
// permission of Matteo Frigo.
// permission of Matteo Frigo
and Steven G. Johnson
.
auto
SGN
_SET
=
[](
T
x
,
size_t
i
)
{
return
(
i
%
2
)
?
-
x
:
x
;};
auto
SGN
=
[](
size_t
i
)
{
return
(
i
&
2
)
?
-
sqrt2
:
sqrt2
;};
arr
<
T
>
y
(
N
);
{
size_t
i
=
0
,
m
=
n2
;
...
...
@@ -2803,30 +2801,26 @@ template<typename T0> class T_dcst4
y
[
i
]
=
-
c
[
m
-
2
*
N
];
for
(;
m
<
4
*
N
;
++
i
,
m
+=
4
)
y
[
i
]
=
c
[
4
*
N
-
m
-
1
];
m
-=
4
*
N
;
for
(;
i
<
N
;
++
i
,
m
+=
4
)
y
[
i
]
=
c
[
m
];
y
[
i
]
=
c
[
m
-
4
*
N
];
}
rfft
->
exec
(
y
.
data
(),
fct
,
true
);
{
size_t
i
=
0
;
for
(;
i
+
i
+
1
<
n2
;
++
i
)
c
[
n2
]
=
y
[
0
]
*
SGN
(
n2
+
1
);
size_t
i
=
0
,
i1
=
1
,
k
=
1
;
for
(;
k
<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cx
,
(
i
+
2
)
/
2
)
+
SGN_SET
(
sx
,
(
i
+
1
)
/
2
));
c
[
i
]
=
y
[
2
*
k
-
1
]
*
SGN
(
i
+
1
)
+
y
[
2
*
k
]
*
SGN
(
i
);
c
[
N
-
i1
]
=
y
[
2
*
k
-
1
]
*
SGN
(
i
+
2
)
+
y
[
2
*
k
]
*
SGN
(
i1
);
}
}
c
[
n2
]
=
sqrt2
*
SGN_SET
(
y
[
0
],
(
n2
+
1
)
/
2
);
// FFTW-derived code ends here
}
...
...
setup.py
View file @
4e511317
...
...
@@ -37,7 +37,7 @@ def get_extension_modules():
return
[
Extension
(
'pypocketfft'
,
language
=
'c++'
,
sources
=
[
'pypocketfft.cc'
],
depends
=
[
'pocketfft_hdronly.h'
],
depends
=
[
'pocketfft_hdronly.h'
,
'setup.py'
],
include_dirs
=
include_dirs
,
define_macros
=
define_macros
,
extra_compile_args
=
extra_compile_args
,
...
...
Write
Preview
Supports
Markdown
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