Skip to content
GitLab
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
dbe056fc
Commit
dbe056fc
authored
Sep 27, 2018
by
Martin Reinecke
Browse files
add Operator.__pow__
parent
cb31d136
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty5/operators/operator.py
View file @
dbe056fc
from
__future__
import
absolute_import
,
division
,
print_function
from
__future__
import
absolute_import
,
division
,
print_function
import
numpy
as
np
from
..compat
import
*
from
..compat
import
*
from
..utilities
import
NiftyMetaBase
from
..utilities
import
NiftyMetaBase
...
@@ -56,6 +57,11 @@ class Operator(NiftyMetaBase()):
...
@@ -56,6 +57,11 @@ class Operator(NiftyMetaBase()):
return
NotImplemented
return
NotImplemented
return
_OpSum
(
self
,
x
)
return
_OpSum
(
self
,
x
)
def
__pow__
(
self
,
power
):
if
not
np
.
isscalar
(
power
):
return
NotImplemented
return
_OpChain
.
make
((
_PowerOp
(
self
.
target
,
power
),
self
))
def
apply
(
self
,
x
):
def
apply
(
self
,
x
):
raise
NotImplementedError
raise
NotImplementedError
...
@@ -97,6 +103,17 @@ class _FunctionApplier(Operator):
...
@@ -97,6 +103,17 @@ class _FunctionApplier(Operator):
return
getattr
(
x
,
self
.
_funcname
)()
return
getattr
(
x
,
self
.
_funcname
)()
class
_PowerOp
(
Operator
):
def
__init__
(
self
,
domain
,
power
):
from
..sugar
import
makeDomain
self
.
_domain
=
self
.
_target
=
makeDomain
(
domain
)
self
.
_power
=
power
def
apply
(
self
,
x
):
self
.
_check_input
(
x
)
return
x
**
self
.
_power
class
_CombinedOperator
(
Operator
):
class
_CombinedOperator
(
Operator
):
def
__init__
(
self
,
ops
,
_callingfrommake
=
False
):
def
__init__
(
self
,
ops
,
_callingfrommake
=
False
):
if
not
_callingfrommake
:
if
not
_callingfrommake
:
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment