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
Neel Shah
NIFTy
Commits
ff54ff45
Commit
ff54ff45
authored
May 18, 2018
by
Philipp Arras
Browse files
Allow inverse samples from sandwiches which are diagonal
parent
23b0ed81
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty4/operators/sandwich_operator.py
View file @
ff54ff45
...
...
@@ -16,9 +16,11 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
import
numpy
as
np
from
.diagonal_operator
import
DiagonalOperator
from
.endomorphic_operator
import
EndomorphicOperator
from
.scaling_operator
import
ScalingOperator
import
numpy
as
np
class
SandwichOperator
(
EndomorphicOperator
):
...
...
@@ -54,8 +56,15 @@ class SandwichOperator(EndomorphicOperator):
return
self
.
_op
.
apply
(
x
,
mode
)
def
draw_sample
(
self
,
from_inverse
=
False
,
dtype
=
np
.
float64
):
# Drawing samples from diagonal operators is easy (inverse is possible)
if
isinstance
(
self
.
_op
,
(
ScalingOperator
,
DiagonalOperator
)):
return
self
.
_op
.
draw_sample
(
from_inverse
,
dtype
)
# Inverse samples from general sandwiches is not possible
if
from_inverse
:
raise
NotImplementedError
(
"cannot draw from inverse of this operator"
)
# Samples from general sandwiches
return
self
.
_bun
.
adjoint_times
(
self
.
_cheese
.
draw_sample
(
from_inverse
,
dtype
))
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