Commit a675f9ad authored by Philipp Arras's avatar Philipp Arras

Merge branch 'introduce_squared_norm' into 'NIFTy_5'

introduce and use squared_norm()

See merge request ift/nifty-dev!1
parents 67e96903 7efbe721
......@@ -487,6 +487,16 @@ class Field(object):
"""
return np.sqrt(abs(self.vdot(x=self)))
def squared_norm(self):
""" Computes the square of the L2-norm of the field values.
Returns
-------
float
The square of the L2-norm of the field values.
"""
return abs(self.vdot(x=self))
def conjugate(self):
""" Returns the complex conjugate of the field.
......
......@@ -45,7 +45,7 @@ class UnitLogGauss(Energy):
@property
@memo
def value(self):
return .5 * self._s.value.vdot(self._s.value).real
return .5 * self._s.value.squared_norm()
@property
@memo
......
......@@ -151,6 +151,16 @@ class MultiField(object):
"""
return np.sqrt(np.abs(self.vdot(x=self)))
def squared_norm(self):
""" Computes the square of the L2-norm of the field values.
Returns
-------
float
The square of the L2-norm of the field values.
"""
return abs(self.vdot(x=self))
def __neg__(self):
return MultiField({key: -val for key, val in self.items()})
......
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