From bd51954c93ee52ff0ce9aead412b926980ea80ba Mon Sep 17 00:00:00 2001 From: Theo Steininger <theo.steininger@ultimanet.de> Date: Wed, 24 May 2017 01:32:40 +0200 Subject: [PATCH] Fixed fixed point normalization. --- nifty/field.py | 33 +++++++++++++++++++------------ nifty/spaces/lm_space/lm_space.py | 4 ++-- nifty/spaces/rg_space/rg_space.py | 22 ++++++++++----------- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/nifty/field.py b/nifty/field.py index d48e5a7ba..3fca09e04 100644 --- a/nifty/field.py +++ b/nifty/field.py @@ -605,19 +605,26 @@ class Field(Loggable, Versionable, object): if flipped_Q: h *= np.sqrt(2) a *= np.sqrt(2) - 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) + + # in principle one must not correct the variance for the fixed + # points of the hermitianization. However, for a complex field + # the input field looses half of its power at its fixed points + # in the `hermitian` part. Hence, here a factor of sqrt(2) is + # also necessary! + +# 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) diff --git a/nifty/spaces/lm_space/lm_space.py b/nifty/spaces/lm_space/lm_space.py index 5cadf785b..0cf01177e 100644 --- a/nifty/spaces/lm_space/lm_space.py +++ b/nifty/spaces/lm_space/lm_space.py @@ -97,8 +97,8 @@ class LMSpace(Space): anti_hermitian_part[:] = x.imag * 1j return (hermitian_part, anti_hermitian_part) - def hermitian_fixed_points(self): - return None +# def hermitian_fixed_points(self): +# return None # ---Mandatory properties and methods--- diff --git a/nifty/spaces/rg_space/rg_space.py b/nifty/spaces/rg_space/rg_space.py index 887e52de8..e06307d05 100644 --- a/nifty/spaces/rg_space/rg_space.py +++ b/nifty/spaces/rg_space/rg_space.py @@ -120,17 +120,17 @@ class RGSpace(Space): return (hermitian_part, anti_hermitian_part) - def hermitian_fixed_points(self): - shape = self.shape - mid_index = np.array(shape)//2 - ndlist = [2 if (shape[i] % 2 == 0) else 1 for i in xrange(len(shape))] - ndlist = tuple(ndlist) - odd_axes_list = np.array([1 if (shape[i] % 2 == 1) else 0 - for i in xrange(len(shape))]) - fixed_points = [] - for i in np.ndindex(ndlist): - fixed_points += [tuple((i+odd_axes_list) * mid_index)] - return fixed_points +# def hermitian_fixed_points(self): +# shape = self.shape +# mid_index = np.array(shape)//2 +# ndlist = [2 if (shape[i] % 2 == 0) else 1 for i in xrange(len(shape))] +# ndlist = tuple(ndlist) +# odd_axes_list = np.array([1 if (shape[i] % 2 == 1) else 0 +# for i in xrange(len(shape))]) +# fixed_points = [] +# for i in np.ndindex(ndlist): +# fixed_points += [tuple((i+odd_axes_list) * mid_index)] +# return fixed_points def _hermitianize_correct_variance(self, hermitian_part, anti_hermitian_part, axes): -- GitLab