Commit 90cd3bf1 authored by Philipp Arras's avatar Philipp Arras
Browse files

Add Integration operator

parent 83cc5351
Pipeline #74993 passed with stages
in 24 minutes and 54 seconds
......@@ -25,7 +25,7 @@ from .operators.adder import Adder
from .operators.diagonal_operator import DiagonalOperator
from .operators.distributors import DOFDistributor, PowerDistributor
from .operators.domain_tuple_field_inserter import DomainTupleFieldInserter
from .operators.contraction_operator import ContractionOperator
from .operators.contraction_operator import ContractionOperator, IntegrationOperator
from .operators.linear_interpolation import LinearInterpolator
from .operators.endomorphic_operator import EndomorphicOperator
from .operators.harmonic_operators import (
......
......@@ -11,7 +11,7 @@
# 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
# Copyright(C) 2013-2020 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
......@@ -270,10 +270,8 @@ class Linearization(Operator):
Linearization
the (partial) integral
"""
from .operators.contraction_operator import ContractionOperator
return self.new(
self._val.integrate(spaces),
ContractionOperator(self._jac.target, spaces, 1)(self._jac))
from .operators.contraction_operator import IntegrationOperator
return IntegrationOperator(self._target, spaces)(self)
def ptw(self, op, *args, **kwargs):
t1, t2 = self._val.ptw_with_deriv(op, *args, **kwargs)
......
......@@ -11,7 +11,7 @@
# 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
# Copyright(C) 2013-2020 Max-Planck-Society
import numpy as np
import scipy.sparse.linalg as ssl
......
......@@ -11,7 +11,7 @@
# 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
# Copyright(C) 2013-2020 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
......@@ -69,3 +69,9 @@ class ContractionOperator(LinearOperator):
x = x.weight(self._weight, spaces=self._spaces)
res = x.sum(self._spaces)
return res if isinstance(res, Field) else Field.scalar(res)
def IntegrationOperator(domain, spaces):
domain = DomainTuple.make(domain)
swgt = domain.scalar_weight(spaces)
return ContractionOperator(domain, spaces, swgt)
......@@ -128,6 +128,10 @@ class Operator(metaclass=NiftyMeta):
from .contraction_operator import ContractionOperator
return ContractionOperator(self.target, spaces)(self)
def intergate(self, spaces=None):
from .contraction_operator import IntegrationOperator
return IntegrationOperator(self.target, spaces)(self)
def vdot(self, other):
from ..sugar import makeOp
if not isinstance(other, Operator):
......
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