Commit 94355504 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

add SandwichOperator

parent 13006f60
......@@ -51,7 +51,7 @@ if __name__ == "__main__":
IC = ift.GradientNormController(name="inverter", iteration_limit=500,
tol_abs_gradnorm=0.1)
inverter = ift.ConjugateGradient(controller=IC)
D = (R.adjoint*N.inverse*R + Sh.inverse).inverse
D = (ift.SandwichOperator(R.adjoint,N.inverse) + Sh.inverse).inverse
# MR FIXME: we can/should provide a preconditioner here as well!
D = ift.InversionEnabler(D, inverter)
m = D(j)
......
......@@ -10,9 +10,10 @@ from .laplace_operator import LaplaceOperator
from .smoothness_operator import SmoothnessOperator
from .power_distributor import PowerDistributor
from .inversion_enabler import InversionEnabler
from .sandwich_operator import SandwichOperator
__all__ = ["LinearOperator", "EndomorphicOperator", "ScalingOperator",
"DiagonalOperator", "HarmonicTransformOperator", "FFTOperator",
"FFTSmoothingOperator", "GeometryRemover",
"LaplaceOperator", "SmoothnessOperator", "PowerDistributor",
"InversionEnabler"]
"InversionEnabler", "SandwichOperator"]
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-2018 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from .endomorphic_operator import EndomorphicOperator
class SandwichOperator(EndomorphicOperator):
"""Operator which is equivalent to the expression `bun*cheese*bun.adjoint`.
Parameters
----------
bun: LinearOperator
the bun part
cheese: EndomorphicOperator
the cheese part
"""
def __init__(self, bun, cheese):
super(SandwichOperator, self).__init__()
self._bun = bun
self._cheese = cheese
self._op = bun*cheese*bun.adjoint
@property
def domain(self):
return self._op.domain
@property
def capability(self):
return self._op.capability
def apply(self, x, mode):
return self._op.apply(x, mode)
def draw_sample(self):
# TBW
raise NotImplementedError
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment