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
170fe8ec
Commit
170fe8ec
authored
Apr 27, 2020
by
Philipp Arras
Browse files
Add .imag to Operator
parent
a56d26bc
Pipeline
#73812
passed with stages
in 19 minutes and 37 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty6/linearization.py
View file @
170fe8ec
...
...
@@ -133,6 +133,10 @@ class Linearization(Operator):
def
real
(
self
):
return
self
.
new
(
self
.
_val
.
real
,
self
.
_jac
.
real
)
@
property
def
imag
(
self
):
return
self
.
new
(
self
.
_val
.
imag
,
self
.
_jac
.
imag
)
def
_myadd
(
self
,
other
,
neg
):
if
np
.
isscalar
(
other
)
or
other
.
jac
is
None
:
return
self
.
new
(
self
.
_val
-
other
if
neg
else
self
.
_val
+
other
,
...
...
nifty6/operators/operator.py
View file @
170fe8ec
...
...
@@ -143,6 +143,11 @@ class Operator(metaclass=NiftyMeta):
from
.simple_linear_operators
import
Realizer
return
Realizer
(
self
.
target
)(
self
)
@
property
def
imag
(
self
):
from
.simple_linear_operators
import
Imaginizer
return
Imaginizer
(
self
.
target
)(
self
)
def
__neg__
(
self
):
return
self
.
scale
(
-
1
)
...
...
nifty6/operators/simple_linear_operators.py
View file @
170fe8ec
...
...
@@ -112,6 +112,24 @@ class Realizer(EndomorphicOperator):
return
x
.
real
class
Imaginizer
(
EndomorphicOperator
):
"""Operator returning the imaginary component of its input.
Parameters
----------
domain: Domain, tuple of domains or DomainTuple
domain of the input field
"""
def
__init__
(
self
,
domain
):
self
.
_domain
=
DomainTuple
.
make
(
domain
)
self
.
_capability
=
self
.
TIMES
|
self
.
ADJOINT_TIMES
def
apply
(
self
,
x
,
mode
):
self
.
_check_input
(
x
,
mode
)
return
x
.
imag
class
FieldAdapter
(
LinearOperator
):
"""Operator for conversion between Fields and MultiFields.
...
...
Write
Preview
Supports
Markdown
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