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
d648bbff
Commit
d648bbff
authored
Aug 16, 2018
by
Martin Reinecke
Browse files
Merge remotetracking branch 'origin/NIFTy_5' into misc_op_work
parents
67a152ea
e7f2378c
Changes
1
Hide whitespace changes
Inline
Sidebyside
Showing
1 changed file
with
19 additions
and
4 deletions
+19
4
nifty5/operators/domain_distributor.py
nifty5/operators/domain_distributor.py
+19
4
No files found.
nifty5/operators/domain_distributor.py
View file @
d648bbff
...
...
@@ 28,11 +28,26 @@ from .linear_operator import LinearOperator
class
DomainDistributor
(
LinearOperator
):
"""A linear operator which broadcasts a field to a larger domain.
This DomainDistributor broadcasts a field which is defined on a
DomainTuple to a DomainTuple which contains the former as a subset. The
entries of the field are copied such that they are constant in the
direction of the new spaces.
Parameters

target : Domain, tuple of Domain or DomainTuple
spaces : int or tuple of int
The elements of "target" which are taken as domain.
"""
def
__init__
(
self
,
target
,
spaces
):
self
.
_target
=
DomainTuple
.
make
(
target
)
self
.
_spaces
=
utilities
.
parse_spaces
(
spaces
,
len
(
self
.
_target
))
self
.
_domain
=
[
tgt
for
i
,
tgt
in
enumerate
(
self
.
_target
)
if
i
in
self
.
_spaces
]
self
.
_domain
=
[
tgt
for
i
,
tgt
in
enumerate
(
self
.
_target
)
if
i
in
self
.
_spaces
]
self
.
_domain
=
DomainTuple
.
make
(
self
.
_domain
)
self
.
_capability
=
self
.
TIMES

self
.
ADJOINT_TIMES
...
...
@@ 47,5 +62,5 @@ class DomainDistributor(LinearOperator):
ldat
=
np
.
broadcast_to
(
ldat
.
reshape
(
shp
),
self
.
_target
.
local_shape
)
return
Field
.
from_local_data
(
self
.
_target
,
ldat
)
else
:
return
x
.
sum
(
[
s
for
s
in
range
(
len
(
x
.
domain
))
if
s
not
in
self
.
_spaces
])
return
x
.
sum
(
[
s
for
s
in
range
(
len
(
x
.
domain
))
if
s
not
in
self
.
_spaces
])
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