diff --git a/nifty_core.py b/nifty_core.py index cc27ec3862ae9c4abbeadc1601f1e45b8023c8b3..88bc0882772478c0d71d427397b86b90521e36e8 100644 --- a/nifty_core.py +++ b/nifty_core.py @@ -5897,17 +5897,27 @@ class field(object): x = self.domain.calc_weight(x,power=1) return self.domain.calc_dot(self.val,x) - def norm(self): ## TODO: extend to L^q norm + def norm(self,q=None): """ - Computes the L2-norm of the field values. + Computes the Lq-norm of the field values. + + Parameters + ---------- + q : scalar + Parameter q of the Lq-norm (default: 2). Returns ------- norm : scalar - The L2-norm of the field values. + The Lq-norm of the field values. """ - return np.sqrt(self.dot(x=self.val)) + if(q is None): + return np.sqrt(self.dot(x=self.val)) + else: + return self.dot(x=self.val**(q-1))**(1/q) + + ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ def pseudo_dot(self,x=1,**kwargs): """ diff --git a/nifty_power.py b/nifty_power.py index 58b3c3bffb82c7791b66a91773d329fb2614279f..6ef88ae498dd715ab74447ec67979ba49e7c81cb 100644 --- a/nifty_power.py +++ b/nifty_power.py @@ -36,11 +36,8 @@ homogeneity and isotropy. Fields which are only statistically homogeneous can also be created using the diagonal operator routine. - At the moment, NIFTy offers one additional routine for power spectrum - manipulation, the smooth_power function to smooth a power spectrum with a - Gaussian convolution kernel. This can be necessary in cases where power - spectra are reconstructed and reused in an iterative algorithm, where - too much statistical variation might severely effect the results. + At the moment, NIFTY offers several additional routines for power spectrum + manipulation. """