Commit 14cfe2d9 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

remove unhelpful documentation; fix typo

parent 3e991a41
......@@ -71,12 +71,6 @@ class ComposedOperator(LinearOperator):
>>> f = Field.from_random('normal', domain=(x1,x2))
>>> FFT.times(f)
See Also
--------
EndomorphicOperator, ProjectionOperator,
DiagonalOperator, SmoothingOperator, ResponseOperator,
PropagatorOperator, ComposedOperator
"""
# ---Overwritten properties and methods---
......
......@@ -41,23 +41,6 @@ class InvertibleOperatorMixin(object):
Preconditioner that is used by ConjugateGradient if no minimizer was
given.
Attributes
----------
Raises
------
Notes
-----
Examples
--------
The PropagatorOperator inherits from InvertibleOperatorMixin.
See Also
--------
PropagatorOperator
"""
def __init__(self, inverter=None, preconditioner=None,
......
# 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-2017 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
import numpy as np
from nifty.field import Field
from nifty.spaces.power_space import PowerSpace
from nifty.operators.endomorphic_operator import EndomorphicOperator
import nifty.nifty_utilities as utilities
class LaplaceOperator(EndomorphicOperator):
"""A irregular LaplaceOperator with free boundary and excluding monopole.
This LaplaceOperator implements the second derivative of a Field in PowerSpace
on logarithmic or linear scale with vanishing curvature at the boundary, starting
at the second entry of the Field. The second derivative of the Field on the irregular grid
is calculated using finite differences.
Parameters
----------
logarithmic : boolean,
Whether smoothness is calculated on a logarithmic scale or linear scale
default : True
"""
def __init__(self, domain, default_spaces=None, logarithmic=True):
super(LaplaceOperator, self).__init__(default_spaces)
self._domain = self._parse_domain(domain)
if len(self.domain) != 1:
raise ValueError("The domain must contain exactly one PowerSpace.")
if not isinstance(self.domain[0], PowerSpace):
raise TypeError("The domain must contain exactly one PowerSpace.")
self._logarithmic = bool(logarithmic)
if self.logarithmic:
pos = self.domain[0].kindex.copy()
pos[1:] = np.log(pos[1:])
pos[0] = pos[1]-1e8*(pos[2]-pos[1])
else:
pos self.domain[0].kindex
self._dist = np.diff(pos) # _dist is 1 entry shorter than kindex
@property
def target(self):
return self._domain
@property
def domain(self):
return self._domain
@property
def unitary(self):
return False
@property
def symmetric(self):
return False
@property
def self_adjoint(self):
return False
@property
def logarithmic(self):
return self._logarithmic
def _prep(x, spaces):
if spaces is None:
# this case means that x lives on only one space, which is
# identical to the space in the domain of `self`. Otherwise the
# input check of LinearOperator would have failed.
axes = x.domain_axes[0]
else:
axes = x.domain_axes[spaces[0]]
axis = axes[0]
dist_l = self._dist[:-1] # 2 entries short
dist_l = dist_l.reshape((1,)*axis + dist_l.shape)
dist_r = self._dist[1:] # 2 entries short
dist_r = dist_r.reshape((1,)*axis + dist_r.shape)
prefix = (slice(None),) * axis
slice_r = prefix + (slice(1, None),)
slice_l = prefix + (slice(0, -1),)
slice_m = prefix + (slice(1, -1),)
dx = x[slice_r] - x[slice_l] # 1 entry short
dx_l = dx[slice_l] # 2 entries short
dx_r = dx[slice_r] # 2 entries short
return dist_l, dist_r, dx_l, dx_r, prefix, slice_l, slice_m, slice_r
def _times(self, x, spaces):
spaces = utilities.cast_axis_to_tuple(spaces, len(x.domain))
dist_l, dist_r, dx_l, dx_r, prefix, slice_l, slice_m, slice_r = _prep(x, spaces)
ret = x.val.copy_empty()
ret [slice_m] = \
(dx_r/dist_r - dx_l/dist_l)* 2. * np.sqrt(dist_l)/(dist_l+dist_r)
ret [prefix + (slice(0,2),)] = 0
ret [prefix + (slice(-1, None),)] = 0
return Field(self.domain, val=ret).weight(power=-0.5, spaces=spaces)
def _adjoint_times(self, x, spaces):
spaces = utilities.cast_axis_to_tuple(spaces, len(x.domain))
dist_l, dist_r, dx_l, dx_r, prefix, slice_l, slice_m, slice_r = _prep(x, spaces)
y = x.copy().weight(power=0.5).val
y = y[slice_m]
y *= np.sqrt(dist_l)*2./(dist_l+dist_r)
ret = x.copy_empty()
ret[slice_m] = -y/dist_l - y/dist_r
ret[prefix + (slice(0, -2),)] += \
y / fwd_dist[prefix + (slice(0, -1),)]
ret[prefix + (slice(2, None),)] += \
y[prefix + (slice(1, -1),)] / fwd_dist[prefix + (slice(1, None),)]
return Field(self.domain, val=ret).weight(-1, spaces=spaces)
......@@ -62,12 +62,6 @@ class LinearOperator(Loggable, object):
the LinearOperator. A LinearOperator must have the attributes domain,
target and unitary to be properly defined.
See Also
--------
EndomorphicOperator, ProjectionOperator,
DiagonalOperator, SmoothingOperator, ResponseOperator,
PropagatorOperator, ComposedOperator
"""
__metaclass__ = NiftyMeta
......
......@@ -37,7 +37,7 @@ class FFTSmoothingOperator(SmoothingOperator):
inplace=True)
# now, apply the kernel to transformed_x
# this is done node-locally utilizing numpys reshaping in order to
# this is done node-locally utilizing numpy's reshaping in order to
# apply the kernel to the correct axes
local_transformed_x = transformed_x.val.get_local_data(copy=False)
local_kernel = kernel.get_local_data(copy=False)
......
......@@ -81,12 +81,6 @@ class SmoothingOperator(EndomorphicOperator):
<distributed_data_object>
array([ 3., 3., 3., 3., 3.])
See Also
--------
DiagonalOperator, SmoothingOperator,
PropagatorOperator, ProjectionOperator,
ComposedOperator
"""
_fft_smoothing_spaces = [RGSpace,
......
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