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

more work

parent 201a6a28
...@@ -101,12 +101,7 @@ class LMSpace(StructuredDomain): ...@@ -101,12 +101,7 @@ class LMSpace(StructuredDomain):
# by Challinor et al. # by Challinor et al.
# http://arxiv.org/abs/astro-ph/0008228 # http://arxiv.org/abs/astro-ph/0008228
from ..sugar import exp from ..sugar import exp
return exp((x+1.) * x * (-0.5*sigma*sigma))
res = x+1.
res *= x
res *= -0.5*sigma*sigma
exp(res, out=res)
return res
def get_fft_smoothing_kernel_function(self, sigma): def get_fft_smoothing_kernel_function(self, sigma):
return lambda x: self._kernel(x, sigma) return lambda x: self._kernel(x, sigma)
......
...@@ -125,9 +125,10 @@ class DOFDistributor(LinearOperator): ...@@ -125,9 +125,10 @@ class DOFDistributor(LinearOperator):
else: else:
arr = x.local_data arr = x.local_data
arr = arr.reshape(self._hshape) arr = arr.reshape(self._hshape)
oarr = arr[(slice(None), self._dofdex, slice(None))] oarr = np.empty(self._pshape, dtype=x.dtype)
return Field.from_local_data(self._target, oarr.reshape(self._target.local_shape)) oarr[()] = arr[(slice(None), self._dofdex, slice(None))]
oarr = res.local_data.reshape(self._pshape) return Field.from_local_data(
self._target, oarr.reshape(self._target.local_shape))
def apply(self, x, mode): def apply(self, x, mode):
self._check_input(x, mode) self._check_input(x, mode)
......
...@@ -55,10 +55,8 @@ class QHTOperator(LinearOperator): ...@@ -55,10 +55,8 @@ class QHTOperator(LinearOperator):
sl = (slice(None),)*i + (slice(1, None),) sl = (slice(None),)*i + (slice(1, None),)
if i == ax: if i == ax:
x = dobj.redistribute(x, nodist=(ax,)) x = dobj.redistribute(x, nodist=(ax,))
curax = dobj.distaxis(x) tmp = dobj.local_data(x)
x = dobj.local_data(x) tmp[sl] = hartley(tmp[sl], axes=(i,))
x[sl] = hartley(x[sl], axes=(i,))
x = dobj.from_local_data(globshape, x, distaxis=curax)
if i == ax: if i == ax:
x = dobj.redistribute(x, dist=ax) x = dobj.redistribute(x, dist=ax)
return Field(self._tgt(mode), val=x) return Field(self._tgt(mode), val=x)
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes. # and financially supported by the Studienstiftung des deutschen Volkes.
from builtins import *
from ..utilities import my_sum
from .linear_operator import LinearOperator from .linear_operator import LinearOperator
import numpy as np import numpy as np
...@@ -187,7 +189,5 @@ class SumOperator(LinearOperator): ...@@ -187,7 +189,5 @@ class SumOperator(LinearOperator):
if from_inverse: if from_inverse:
raise NotImplementedError( raise NotImplementedError(
"cannot draw from inverse of this operator") "cannot draw from inverse of this operator")
res = self._ops[0].draw_sample(from_inverse, dtype) return my_sum(map(lambda op: op.draw_sample(from_inverse, dtype),
for op in self._ops[1:]: self._ops))
res += op.draw_sample(from_inverse, dtype)
return res
...@@ -22,10 +22,8 @@ class SymmetrizingOperator(EndomorphicOperator): ...@@ -22,10 +22,8 @@ class SymmetrizingOperator(EndomorphicOperator):
lead = (slice(None),)*i lead = (slice(None),)*i
if i == ax: if i == ax:
tmp = dobj.redistribute(tmp, nodist=(ax,)) tmp = dobj.redistribute(tmp, nodist=(ax,))
curax = dobj.distaxis(tmp) tmp2 = dobj.local_data(tmp)
tmp = dobj.local_data(tmp) tmp2[lead+(slice(1, None),)] -= tmp2[lead+(slice(None, 0, -1),)]
tmp[lead + (slice(1, None),)] -= tmp[lead + (slice(None, 0, -1),)]
tmp = dobj.from_local_data(globshape, tmp, distaxis=curax)
if i == ax: if i == ax:
tmp = dobj.redistribute(tmp, dist=ax) tmp = dobj.redistribute(tmp, dist=ax)
return Field(self.target, val=tmp) return Field(self.target, val=tmp)
......
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