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
0f4a5c18
Commit
0f4a5c18
authored
Jan 27, 2017
by
Theo Steininger
Browse files
Added invertible_operator_mixin.
parent
a4b43a07
Pipeline
#9760
failed with stages
in 29 minutes and 54 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty/operators/__init__.py
View file @
0f4a5c18
...
...
@@ -31,6 +31,8 @@ from smoothing_operator import SmoothingOperator
from
fft_operator
import
*
from
invertible_operator_mixin
import
InvertibleOperatorMixin
from
propagator_operator
import
PropagatorOperator
from
composed_operator
import
ComposedOperator
nifty/operators/invertible_operator_mixin/__init__.py
0 → 100644
View file @
0f4a5c18
# -*- coding: utf-8 -*-
from
invertible_operator_mixin
import
InvertibleOperatorMixin
\ No newline at end of file
nifty/operators/invertible_operator_mixin/invertible_operator_mixin.py
0 → 100644
View file @
0f4a5c18
# -*- coding: utf-8 -*-
from
nifty.minimization
import
ConjugateGradient
from
nifty.field
import
Field
class
InvertibleOperatorMixin
(
object
):
def
__init__
(
self
,
inverter
=
None
,
preconditioner
=
None
):
self
.
__preconditioner
=
preconditioner
if
inverter
is
not
None
:
self
.
__inverter
=
inverter
else
:
self
.
__inverter
=
ConjugateGradient
(
preconditioner
=
self
.
preconditioner
)
def
_times
(
self
,
x
,
spaces
,
types
,
x0
=
None
):
if
x0
is
None
:
x0
=
Field
(
self
.
target
,
val
=
0.
,
dtype
=
x
.
dtype
)
(
result
,
convergence
)
=
self
.
inverter
(
A
=
self
.
inverse_times
,
b
=
x
,
x0
=
x0
)
return
result
def
_adjoint_times
(
self
,
x
,
spaces
,
types
,
x0
=
None
):
if
x0
is
None
:
x0
=
Field
(
self
.
domain
,
val
=
0.
,
dtype
=
x
.
dtype
)
(
result
,
convergence
)
=
self
.
inverter
(
A
=
self
.
adjoint_inverse_times
,
b
=
x
,
x0
=
x0
)
return
result
def
_inverse_times
(
self
,
x
,
spaces
,
types
,
x0
=
None
):
if
x0
is
None
:
x0
=
Field
(
self
.
domain
,
val
=
0.
,
dtype
=
x
.
dtype
)
(
result
,
convergence
)
=
self
.
inverter
(
A
=
self
.
times
,
b
=
x
,
x0
=
x0
)
return
result
def
_adjoint_inverse_times
(
self
,
x
,
spaces
,
types
,
x0
=
None
):
if
x0
is
None
:
x0
=
Field
(
self
.
target
,
val
=
0.
,
dtype
=
x
.
dtype
)
(
result
,
convergence
)
=
self
.
inverter
(
A
=
self
.
adjoint_times
,
b
=
x
,
x0
=
x0
)
return
result
def
_inverse_adjoint_times
(
self
,
x
,
spaces
,
types
):
raise
NotImplementedError
(
"no generic instance method 'inverse_adjoint_times'."
)
nifty/operators/propagator_operator/propagator_operator.py
View file @
0f4a5c18
...
...
@@ -109,7 +109,7 @@ class PropagatorOperator(EndomorphicOperator):
def
_times
(
self
,
x
,
spaces
,
types
,
x0
=
None
):
if
x0
is
None
:
x0
=
Field
(
self
.
domain
,
val
=
0.
,
dtype
=
x
.
dtype
)
x0
=
Field
(
self
.
target
,
val
=
0.
,
dtype
=
x
.
dtype
)
(
result
,
convergence
)
=
self
.
inverter
(
A
=
self
.
inverse_times
,
b
=
x
,
...
...
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