Commit e1e4be1b authored by Lukas Platz's avatar Lukas Platz

create OperatorNormalizer operator

parent 9c2ebd5d
Pipeline #61510 failed with stages
in 4 minutes and 12 seconds
......@@ -52,6 +52,7 @@ from .operators.energy_operators import (
EnergyOperator, GaussianEnergy, PoissonianEnergy, InverseGammaLikelihood,
BernoulliEnergy, StandardHamiltonian, AveragedEnergy)
from .operators.convolution_operators import FuncConvolutionOperator
from .operators.operator_normalizer import OperatorNormalizer
from .probing import probe_with_posterior_samples, probe_diagonal, \
StatCalculator
......
# 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-2019 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
from ..field import Field
from .simple_linear_operators import VdotOperator, WeightApplier
def OperatorNormalizer(op):
"""Wraps `op` into a shell that ensures the fields returned by
(shell @ op) will have an integral of one.
Implements an operator analogously to
OperatorNormalizer(op) = op / op.integrate()
where the integration is implemented as an operator chain.
Parameters
----------
op : Operator
"""
ones_field = Field.full(op.target, 1.)
vdot = VdotOperator(ones_field)
wa = WeightApplier(op.target, spaces=None, power=1)
# integrate as an operator
op_integrated = vdot.adjoint @ vdot @ wa @ op
return op * op_integrated**(-1)
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