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
ift
NIFTy
Commits
12439028
Commit
12439028
authored
Aug 12, 2018
by
Philipp Arras
Browse files
Add SumOp back in
parent
e3e42447
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty5/operators/operator.py
View file @
12439028
...
...
@@ -152,16 +152,16 @@ class _OpProd(Operator):
return
Linearization
(
lin1
.
_val
*
lin2
.
_val
,
op
(
x
.
jac
))
#
class _OpSum(_CombinedOperator):
#
def __init__(self, ops, _callingfrommake=False):
#
from ..sugar import domain_union
#
super(_OpSum, self).__init__(ops, _callingfrommake)
#
self._domain = domain_union([op.domain for op in self._ops])
#
self._target = domain_union([op.target for op in self._ops])
#
#
def apply(self, x):
#
res = None
#
for op in self._ops:
#
tmp = op(x.extract(op.domain))
#
res = tmp if res is None else res.unite(tmp)
#
return res
class
_OpSum
(
_CombinedOperator
):
def
__init__
(
self
,
ops
,
_callingfrommake
=
False
):
from
..sugar
import
domain_union
super
(
_OpSum
,
self
).
__init__
(
ops
,
_callingfrommake
)
self
.
_domain
=
domain_union
([
op
.
domain
for
op
in
self
.
_ops
])
self
.
_target
=
domain_union
([
op
.
target
for
op
in
self
.
_ops
])
def
apply
(
self
,
x
):
res
=
None
for
op
in
self
.
_ops
:
tmp
=
op
(
x
.
extract
(
op
.
domain
))
res
=
tmp
if
res
is
None
else
res
.
unite
(
tmp
)
return
res
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