Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
f22d711a
Commit
f22d711a
authored
Jul 12, 2018
by
Philipp Arras
Browse files
Change direction von FieldZeroPadder
parent
0e382f9b
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty5/operators/field_zero_padder.py
View file @
f22d711a
...
...
@@ -4,31 +4,29 @@ import numpy as np
from
..
import
dobj
from
..compat
import
*
from
..field
import
Field
from
..domains.rg_space
import
RGSpace
from
..domain_tuple
import
DomainTuple
from
..domains.rg_space
import
RGSpace
from
..field
import
Field
from
.linear_operator
import
LinearOperator
# MR FIXME: we probably need a better name. This thing is actually
# an AdointFieldZeroPadder (no, that's not a name suggestion ...)
class
FieldZeroPadder
(
LinearOperator
):
def
__init__
(
self
,
target
,
factor
,
space
=
0
):
def
__init__
(
self
,
domain
,
factor
,
space
=
0
):
super
(
FieldZeroPadder
,
self
).
__init__
()
self
.
_
target
=
DomainTuple
.
make
(
target
)
self
.
_
domain
=
DomainTuple
.
make
(
domain
)
self
.
_space
=
int
(
space
)
tgt
=
self
.
_
target
[
self
.
_space
]
if
not
isinstance
(
tgt
,
RGSpace
):
dom
=
self
.
_
domain
[
self
.
_space
]
if
not
isinstance
(
dom
,
RGSpace
):
raise
TypeError
(
"RGSpace required"
)
if
not
len
(
tgt
.
shape
)
==
1
:
if
not
len
(
dom
.
shape
)
==
1
:
raise
TypeError
(
"RGSpace must be one-dimensional"
)
if
tgt
.
harmonic
:
if
dom
.
harmonic
:
raise
TypeError
(
"RGSpace must not be harmonic"
)
dom
=
RGSpace
((
int
(
factor
*
tgt
.
shape
[
0
]),),
tgt
.
distances
)
self
.
_
domain
=
list
(
self
.
_
target
)
self
.
_
domain
[
self
.
_space
]
=
dom
self
.
_
domain
=
DomainTuple
.
make
(
self
.
_
domain
)
tgt
=
RGSpace
((
int
(
factor
*
dom
.
shape
[
0
]),),
dom
.
distances
)
self
.
_
target
=
list
(
self
.
_
domain
)
self
.
_
target
[
self
.
_space
]
=
tgt
self
.
_
target
=
DomainTuple
.
make
(
self
.
_
target
)
@
property
def
domain
(
self
):
...
...
@@ -48,12 +46,12 @@ class FieldZeroPadder(LinearOperator):
dax
=
dobj
.
distaxis
(
x
)
shp_in
=
x
.
shape
shp_out
=
self
.
_tgt
(
mode
).
shape
ax
=
self
.
_
domain
.
axes
[
self
.
_space
][
0
]
ax
=
self
.
_
target
.
axes
[
self
.
_space
][
0
]
if
dax
==
ax
:
x
=
dobj
.
redistribute
(
x
,
nodist
=
(
ax
,))
curax
=
dobj
.
distaxis
(
x
)
if
mode
==
self
.
TIMES
:
if
mode
==
self
.
ADJOINT_
TIMES
:
newarr
=
np
.
empty
(
dobj
.
local_shape
(
shp_out
),
dtype
=
x
.
dtype
)
newarr
[()]
=
dobj
.
local_data
(
x
)[(
slice
(
None
),)
*
ax
+
(
slice
(
0
,
shp_out
[
ax
]),)]
...
...
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