Commit e8272dcf authored by Martin Reinecke's avatar Martin Reinecke

Field.dot->Field.vdot

parent 3dc1ba04
Pipeline #13878 passed with stage
in 5 minutes and 28 seconds
......@@ -24,7 +24,7 @@ class WienerFilterEnergy(Energy):
@property
def value(self):
D_inv_x = self.D_inverse_x()
H = 0.5 * D_inv_x.dot(self.position) - self.j.dot(self.position)
H = 0.5 * D_inv_x.vdot(self.position) - self.j.dot(self.position)
return H.real
@property
......
......@@ -109,7 +109,7 @@ class LineEnergy(Energy):
@property
def gradient(self):
return self.energy.gradient.dot(self.line_direction)
return self.energy.gradient.vdot(self.line_direction)
@property
def curvature(self):
......
......@@ -1040,7 +1040,7 @@ class Field(Loggable, Versionable, object):
new_field.set_val(new_val=new_val, copy=False)
return new_field
def dot(self, x=None, spaces=None, bare=False):
def vdot(self, x=None, spaces=None, bare=False):
""" Computes the volume-factor-aware dot product of 'self' with x.
Parameters
......
......@@ -121,12 +121,12 @@ class ConjugateGradient(Loggable, object):
r = b - A(x0)
d = self.preconditioner(r)
previous_gamma = r.dot(d)
previous_gamma = r.vdot(d)
if previous_gamma == 0:
self.logger.info("The starting guess is already perfect solution "
"for the inverse problem.")
return x0, self.convergence_level+1
norm_b = np.sqrt(b.dot(b))
norm_b = np.sqrt(b.vdot(b))
x = x0
convergence = 0
iteration_number = 1
......@@ -137,7 +137,7 @@ class ConjugateGradient(Loggable, object):
self.callback(x, iteration_number)
q = A(d)
alpha = previous_gamma/d.dot(q)
alpha = previous_gamma/d.vdot(q)
if not np.isfinite(alpha):
self.logger.error("Alpha became infinite! Stopping.")
......@@ -158,7 +158,7 @@ class ConjugateGradient(Loggable, object):
r -= q * alpha
s = self.preconditioner(r)
gamma = r.dot(s)
gamma = r.vdot(s)
if gamma.real < 0:
self.logger.warn("Positive definitness of preconditioner "
......
......@@ -137,7 +137,7 @@ class DescentMinimizer(Loggable, object):
# compute the the gradient for the current location
gradient = energy.gradient
gradient_norm = gradient.dot(gradient)
gradient_norm = gradient.vdot(gradient)
# check if position is at a flat point
if gradient_norm == 0:
......
......@@ -261,7 +261,7 @@ class InformationStore(object):
"""
key = tuple(sorted((i, j)))
if key not in self._ss_store:
self._ss_store[key] = self.s[i].dot(self.s[j])
self._ss_store[key] = self.s[i].vdot(self.s[j])
return self._ss_store[key]
def sy_store(self, i, j):
......@@ -284,7 +284,7 @@ class InformationStore(object):
"""
key = (i, j)
if key not in self._sy_store:
self._sy_store[key] = self.s[i].dot(self.y[j])
self._sy_store[key] = self.s[i].vdot(self.y[j])
return self._sy_store[key]
def yy_store(self, i, j):
......@@ -307,7 +307,7 @@ class InformationStore(object):
"""
key = tuple(sorted((i, j)))
if key not in self._yy_store:
self._yy_store[key] = self.y[i].dot(self.y[j])
self._yy_store[key] = self.y[i].vdot(self.y[j])
return self._yy_store[key]
def sgrad_store(self, i):
......@@ -319,7 +319,7 @@ class InformationStore(object):
Scalar product.
"""
return self.s[i].dot(self.last_gradient)
return self.s[i].vdot(self.last_gradient)
def ygrad_store(self, i):
"""Returns scalar product between y_i and gradient on initial position.
......@@ -330,7 +330,7 @@ class InformationStore(object):
Scalar product.
"""
return self.y[i].dot(self.last_gradient)
return self.y[i].vdot(self.last_gradient)
def gradgrad_store(self):
"""Returns scalar product of gradient on initial position with itself.
......@@ -341,7 +341,7 @@ class InformationStore(object):
Scalar product.
"""
return self.last_gradient.dot(self.last_gradient)
return self.last_gradient.vdot(self.last_gradient)
def add_new_point(self, x, gradient):
"""Updates the s list and y list.
......
......@@ -51,7 +51,7 @@ class ComposedOperator(LinearOperator):
Notes
-----
Very usefull in case one has to transform a Field living over a product
Very useful in case one has to transform a Field living over a product
space (see example below).
Examples
......
......@@ -30,7 +30,7 @@ class TraceProberMixin(object):
super(TraceProberMixin, self).reset()
def finish_probe(self, probe, pre_result):
result = probe[1].dot(pre_result, bare=True)
result = probe[1].vdot(pre_result, bare=True)
self.__sum_of_probings += result
if self.compute_variance:
self.__sum_of_squares += result.conjugate() * result
......
......@@ -40,8 +40,8 @@ class ComposedOperator_Tests(unittest.TestCase):
rand1 = Field.from_random('normal', domain=(space1,space2))
rand2 = Field.from_random('normal', domain=(space1,space2))
tt1 = rand2.dot(op.times(rand1))
tt2 = rand1.dot(op.adjoint_times(rand2))
tt1 = rand2.vdot(op.times(rand1))
tt2 = rand1.vdot(op.adjoint_times(rand2))
assert_approx_equal(tt1, tt2)
@expand(product(spaces, spaces))
......
......@@ -33,8 +33,8 @@ class DiagonalOperator_Tests(unittest.TestCase):
rand2 = Field.from_random('normal', domain=space)
diag = Field.from_random('normal', domain=space)
D = DiagonalOperator(space, diagonal=diag, bare=bare, copy=copy)
tt1 = rand1.dot(D.times(rand2))
tt2 = rand2.dot(D.times(rand1))
tt1 = rand1.vdot(D.times(rand2))
tt2 = rand2.vdot(D.times(rand1))
assert_approx_equal(tt1, tt2)
@expand(product(spaces, [True, False], [True, False]))
......
......@@ -143,8 +143,8 @@ class FFTOperatorTests(unittest.TestCase):
inp = Field.from_random(domain=a, random_type='normal', std=1, mean=0,
dtype=tp)
out = fft.times(inp)
v1 = np.sqrt(out.dot(out))
v2 = np.sqrt(inp.dot(fft.adjoint_times(out)))
v1 = np.sqrt(out.vdot(out))
v2 = np.sqrt(inp.vdot(fft.adjoint_times(out)))
assert_allclose(v1, v2, rtol=tol, atol=tol)
@expand(product([128, 256],
......@@ -159,6 +159,6 @@ class FFTOperatorTests(unittest.TestCase):
inp = Field.from_random(domain=a, random_type='normal', std=1, mean=0,
dtype=tp)
out = fft.times(inp)
v1 = np.sqrt(out.dot(out))
v2 = np.sqrt(inp.dot(fft.adjoint_times(out)))
v1 = np.sqrt(out.vdot(out))
v2 = np.sqrt(inp.vdot(fft.adjoint_times(out)))
assert_allclose(v1, v2, rtol=tol, atol=tol)
......@@ -27,6 +27,6 @@ class ResponseOperator_Tests(unittest.TestCase):
exposure=[exposure])
rand1 = Field.from_random('normal', domain=space)
rand2 = Field.from_random('normal', domain=op.target[0])
tt1 = rand2.dot(op.times(rand1))
tt2 = rand1.dot(op.adjoint_times(rand2))
tt1 = rand2.vdot(op.times(rand1))
tt2 = rand1.vdot(op.adjoint_times(rand2))
assert_approx_equal(tt1, tt2)
......@@ -60,8 +60,8 @@ class SmoothingOperator_Tests(unittest.TestCase):
log_distances=log_distances)
rand1 = Field.from_random('normal', domain=space)
rand2 = Field.from_random('normal', domain=space)
tt1 = rand1.dot(op.times(rand2))
tt2 = rand2.dot(op.adjoint_times(rand1))
tt1 = rand1.vdot(op.times(rand2))
tt2 = rand2.vdot(op.adjoint_times(rand1))
assert_approx_equal(tt1, tt2)
@expand(product(spaces, [0., .5, 5.], [False]))
......@@ -79,8 +79,8 @@ class SmoothingOperator_Tests(unittest.TestCase):
log_distances=log_distances)
rand1 = Field.from_random('normal', domain=space)
rand2 = Field.from_random('normal', domain=space)
tt1 = rand1.dot(op.inverse_times(rand2))
tt2 = rand2.dot(op.inverse_adjoint_times(rand1))
tt1 = rand1.vdot(op.inverse_times(rand2))
tt2 = rand2.vdot(op.inverse_adjoint_times(rand1))
assert_approx_equal(tt1, tt2)
@expand(product([100, 200], [1, 0.4], [0., 1., 3.7],
......
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