diff --git a/nifty/field.py b/nifty/field.py index d4bd3e31eed98ae2fe39bc17a96a4707d0e1077f..a46e36cd42f3922ad7f467410a50c4cadcfcca5f 100644 --- a/nifty/field.py +++ b/nifty/field.py @@ -617,6 +617,42 @@ class Field(Loggable, Versionable, object): h *= np.sqrt(2) a *= np.sqrt(2) +# The code below should not be needed in practice, since it would +# only ever be called when hermitianizing a purely real field. +# However it might be of educational use and keep us from forgetting +# how these things are done ... + +# if not issubclass(val.dtype.type, np.complexfloating): +# # in principle one must not correct the variance for the fixed +# # points of the hermitianization. However, for a complex field +# # the input field loses half of its power at its fixed points +# # in the `hermitian` part. Hence, here a factor of sqrt(2) is +# # also necessary! +# # => The hermitianization can be done on a space level since +# # either nothing must be done (LMSpace) or ALL points need a +# # factor of sqrt(2) +# # => use the preserve_gaussian_variance flag in the +# # hermitian_decomposition method above. +# +# # This code is for educational purposes: +# fixed_points = [domain[i].hermitian_fixed_points() +# for i in spaces] +# fixed_points = [[fp] if fp is None else fp +# for fp in fixed_points] +# +# for product_point in itertools.product(*fixed_points): +# slice_object = np.array((slice(None), )*len(val.shape), +# dtype=np.object) +# for i, sp in enumerate(spaces): +# point_component = product_point[i] +# if point_component is None: +# point_component = slice(None) +# slice_object[list(domain_axes[sp])] = point_component +# +# slice_object = tuple(slice_object) +# h[slice_object] /= np.sqrt(2) +# a[slice_object] /= np.sqrt(2) + return (h, a) def _spec_to_rescaler(self, spec, result_list, power_space_index): diff --git a/nifty/spaces/rg_space/rg_space.py b/nifty/spaces/rg_space/rg_space.py index 89a9f5e221e53fdde70066e8f8ca6c48f6179dc3..8f70ccf27a3c77c875abdaa1396a7c9860eaef85 100644 --- a/nifty/spaces/rg_space/rg_space.py +++ b/nifty/spaces/rg_space/rg_space.py @@ -100,6 +100,27 @@ class RGSpace(Space): self._distances = self._parse_distances(distances) self._zerocenter = self._parse_zerocenter(zerocenter) +# This code is unused but may be useful to keep around if it is ever needed +# again in the future ... + +# def hermitian_fixed_points(self): +# dimensions = len(self.shape) +# mid_index = np.array(self.shape)//2 +# ndlist = [1]*dimensions +# for k in range(dimensions): +# if self.shape[k] % 2 == 0: +# ndlist[k] = 2 +# ndlist = tuple(ndlist) +# fixed_points = [] +# for index in np.ndindex(ndlist): +# for k in range(dimensions): +# if self.shape[k] % 2 != 0 and self.zerocenter[k]: +# index = list(index) +# index[k] = 1 +# index = tuple(index) +# fixed_points += [tuple(index * mid_index)] +# return fixed_points + def hermitianize_inverter(self, x, axes): # calculate the number of dimensions the input array has dimensions = len(x.shape)