Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NIFTy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ift
NIFTy
Commits
32b85405
There was a problem fetching the pipeline summary.
Commit
32b85405
authored
7 years ago
by
Martin Reinecke
Browse files
Options
Downloads
Patches
Plain Diff
use Hartley transform
parent
5c0c1525
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nifty2go/operators/fft_operator/fft_operator_support.py
+29
-21
29 additions, 21 deletions
nifty2go/operators/fft_operator/fft_operator_support.py
with
29 additions
and
21 deletions
nifty2go/operators/fft_operator/fft_operator_support.py
+
29
−
21
View file @
32b85405
...
@@ -38,21 +38,41 @@ class RGRGTransformation(Transformation):
...
@@ -38,21 +38,41 @@ class RGRGTransformation(Transformation):
import
pyfftw
import
pyfftw
super
(
RGRGTransformation
,
self
).
__init__
(
domain
,
codomain
)
super
(
RGRGTransformation
,
self
).
__init__
(
domain
,
codomain
)
pyfftw
.
interfaces
.
cache
.
enable
()
pyfftw
.
interfaces
.
cache
.
enable
()
self
.
_fwd
=
self
.
codomain
.
harmonic
@property
@property
def
unitary
(
self
):
def
unitary
(
self
):
return
True
return
True
def
_transform_helper
(
self
,
val
,
axes
):
@staticmethod
from
pyfftw.interfaces.numpy_fft
import
fftn
,
ifftn
def
_hartley
(
a
,
axes
=
None
):
# Check if the axes provided are valid given the shape
# Check if the axes provided are valid given the shape
if
axes
is
not
None
and
\
if
axes
is
not
None
and
\
not
all
(
axis
in
range
(
len
(
val
.
shape
))
for
axis
in
axes
):
not
all
(
axis
in
range
(
len
(
val
.
shape
))
for
axis
in
axes
):
raise
ValueError
(
"
Provided axes does not match array shape
"
)
raise
ValueError
(
"
Provided axes does not match array shape
"
)
return
fftn
(
val
,
axes
=
axes
)
if
self
.
_fwd
else
ifftn
(
val
,
axes
=
axes
)
from
pyfftw.interfaces.numpy_fft
import
rfftn
if
issubclass
(
a
.
dtype
.
type
,
np
.
complexfloating
):
raise
TypeError
(
"
Hartley tansform works for real-valued arrays only.
"
)
tmp
=
rfftn
(
a
,
axes
=
axes
)
res
=
np
.
empty_like
(
a
)
if
axes
is
None
:
axes
=
list
(
range
(
a
.
ndim
))
lastaxis
=
axes
[
-
1
]
nlast
=
a
.
shape
[
lastaxis
]
ntmplast
=
tmp
.
shape
[
lastaxis
]
nrem
=
nlast
-
ntmplast
slice1
=
[
slice
(
None
)]
*
a
.
ndim
slice1
[
lastaxis
]
=
slice
(
0
,
ntmplast
)
res
[
slice1
]
=
tmp
.
real
+
tmp
.
imag
tmp
=
np
.
roll
(
tmp
,
-
1
,
axes
)
slice1
=
[
slice
(
None
)]
*
a
.
ndim
slice1
[
lastaxis
]
=
slice
(
ntmplast
,
None
)
slice2
=
[
slice
(
None
)]
*
a
.
ndim
for
i
in
axes
:
slice2
[
i
]
=
slice
(
None
,
None
,
-
1
)
slice2
[
lastaxis
]
=
slice
(
nrem
-
1
,
None
,
-
1
)
res
[
slice1
]
=
tmp
[
slice2
].
real
-
tmp
[
slice2
].
imag
return
res
def
transform
(
self
,
val
,
axes
=
None
):
def
transform
(
self
,
val
,
axes
=
None
):
"""
"""
...
@@ -75,26 +95,14 @@ class RGRGTransformation(Transformation):
...
@@ -75,26 +95,14 @@ class RGRGTransformation(Transformation):
if
self
.
codomain
.
harmonic
:
if
self
.
codomain
.
harmonic
:
fct
=
self
.
domain
.
weight
()
fct
=
self
.
domain
.
weight
()
else
:
else
:
fct
=
1.
/
self
.
codomain
.
weight
()
fct
=
1.
/
(
self
.
codomain
.
weight
()
*
self
.
domain
.
dim
)
# Perform the transformation
# Perform the transformation
if
issubclass
(
val
.
dtype
.
type
,
np
.
complexfloating
):
if
issubclass
(
val
.
dtype
.
type
,
np
.
complexfloating
):
Tval1
=
self
.
_transform_helper
(
val
.
real
,
axes
)
Tval
=
self
.
_hartley
(
val
.
real
,
axes
)
\
Tval2
=
self
.
_transform_helper
(
val
.
imag
,
axes
)
+
1j
*
self
.
_hartley
(
val
.
imag
,
axes
)
if
self
.
codomain
.
harmonic
:
Tval1
.
real
+=
Tval1
.
imag
Tval2
.
real
+=
Tval2
.
imag
else
:
Tval1
.
real
-=
Tval1
.
imag
Tval2
.
real
-=
Tval2
.
imag
Tval1
.
imag
=
Tval2
.
real
Tval
=
Tval1
else
:
else
:
Tval
=
self
.
_transform_helper
(
val
,
axes
)
Tval
=
self
.
_hartley
(
val
,
axes
)
if
self
.
codomain
.
harmonic
:
Tval
=
Tval
.
real
+
Tval
.
imag
else
:
Tval
=
Tval
.
real
-
Tval
.
imag
Tval
*=
fct
Tval
*=
fct
return
Tval
return
Tval
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment