Commit addf0517 authored by Theo Steininger's avatar Theo Steininger
Browse files

Merge branch 'master' of gitlab.mpcdf.mpg.de:ift/NIFTy

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