Commit 4ff7b806 authored by theos's avatar theos
Browse files

Fixed calc_dot in point_space and rg_space.

parent 6733e2dc
...@@ -1186,7 +1186,7 @@ class point_space(space): ...@@ -1186,7 +1186,7 @@ class point_space(space):
result = result**(1. / q) result = result**(1. / q)
return result return result
def calc_dot(self, x, y): def calc_dot(self, x, y, axes=None):
""" """
Computes the discrete inner product of two given arrays of field Computes the discrete inner product of two given arrays of field
values. values.
...@@ -1203,11 +1203,10 @@ class point_space(space): ...@@ -1203,11 +1203,10 @@ class point_space(space):
dot : scalar dot : scalar
Inner product of the two arrays. Inner product of the two arrays.
""" """
if axes is None:
result = x.vdot(y) result = x.vdot(y)
else:
if np.isreal(result): result = (x.conjugate() * y).sum(axis=axes)
result = np.asscalar(np.real(result))
return result return result
......
...@@ -771,38 +771,6 @@ class rg_space(point_space): ...@@ -771,38 +771,6 @@ class rg_space(point_space):
def get_weight(self, power=1): def get_weight(self, power=1):
return np.prod(self.distances)**power return np.prod(self.distances)**power
def calc_dot(self, x, y):
"""
Computes the discrete inner product of two given arrays of field
values.
Parameters
----------
x : numpy.ndarray
First array
y : numpy.ndarray
Second array
Returns
-------
dot : scalar
Inner product of the two arrays.
"""
x = self.cast(x)
y = self.cast(y)
result = x.vdot(y)
if np.isreal(result):
result = np.asscalar(np.real(result))
if self.paradict['complexity'] != 2:
if (np.absolute(result.imag) >
self.epsilon**2 * np.absolute(result.real)):
about.warnings.cprint(
"WARNING: Discarding considerable imaginary part.")
result = np.asscalar(np.real(result))
return result
def calc_transform(self, x, codomain=None, axes=None, **kwargs): def calc_transform(self, x, codomain=None, axes=None, **kwargs):
""" """
Computes the transform of a given array of field values. Computes the transform of a given array of field values.
...@@ -822,7 +790,6 @@ class rg_space(point_space): ...@@ -822,7 +790,6 @@ class rg_space(point_space):
Tx : numpy.ndarray Tx : numpy.ndarray
Transformed array Transformed array
""" """
x = self.cast(x)
if codomain is None: if codomain is None:
codomain = self.get_codomain() codomain = self.get_codomain()
......
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