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

add forgotten file

parent af9bdeb9
Pipeline #23264 passed with stage
in 4 minutes and 36 seconds
# 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-2017 Max-Planck-Society
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from __future__ import division
import numpy as np
from ..field import Field
from ..domain_tuple import DomainTuple
from .endomorphic_operator import EndomorphicOperator
from ..utilities import cast_iseq_to_tuple
from .. import dobj
class ScalingOperator(EndomorphicOperator):
""" NIFTY class for an operator which multiplies a Field with a scalar.
The NIFTY ScalingOperator class is a subclass derived from the
EndomorphicOperator. It multiplies an input field with a given factor.
factor : scalar
The multiplication factor
domain : tuple of DomainObjects
The domain on which the Operator's input Field lives.
domain : DomainTuple
The domain on which the Operator's input Field lives.
def __init__(self, factor, domain):
super(ScalingOperator, self).__init__()
if not np.isscalar(factor):
raise TypeError("Scalar required")
self._factor = factor
self._domain = DomainTuple.make(domain)
def apply(self, x, mode):
self._check_input(x, mode)
if mode == self.TIMES:
return x*self._factor
elif mode == self.ADJOINT_TIMES:
return x*np.conj(self._factor)
elif mode == self.INVERSE_TIMES:
return x*(1./self._factor)
return x*(1./np.conj(self._factor))
def domain(self):
return self._domain
def capability(self):
return (self.TIMES | self.ADJOINT_TIMES |
Supports Markdown
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