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,
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", "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
# 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 <>.
# 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`.
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
def domain(self):
return self._op.domain
def capability(self):
return self._op.capability
def apply(self, x, mode):
return self._op.apply(x, mode)
def draw_sample(self):
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