Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
e8272dcf
Commit
e8272dcf
authored
Jun 20, 2017
by
Martin Reinecke
Browse files
Field.dot->Field.vdot
parent
3dc1ba04
Pipeline
#13878
passed with stage
in 5 minutes and 28 seconds
Changes
13
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
demos/wiener_filter_hamiltonian.py
View file @
e8272dcf
...
...
@@ -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
.
v
dot
(
self
.
position
)
-
self
.
j
.
dot
(
self
.
position
)
return
H
.
real
@
property
...
...
nifty/energies/line_energy.py
View file @
e8272dcf
...
...
@@ -109,7 +109,7 @@ class LineEnergy(Energy):
@
property
def
gradient
(
self
):
return
self
.
energy
.
gradient
.
dot
(
self
.
line_direction
)
return
self
.
energy
.
gradient
.
v
dot
(
self
.
line_direction
)
@
property
def
curvature
(
self
):
...
...
nifty/field.py
View file @
e8272dcf
...
...
@@ -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
v
dot
(
self
,
x
=
None
,
spaces
=
None
,
bare
=
False
):
""" Computes the volume-factor-aware dot product of 'self' with x.
Parameters
...
...
nifty/minimization/conjugate_gradient.py
View file @
e8272dcf
...
...
@@ -121,12 +121,12 @@ class ConjugateGradient(Loggable, object):
r
=
b
-
A
(
x0
)
d
=
self
.
preconditioner
(
r
)
previous_gamma
=
r
.
dot
(
d
)
previous_gamma
=
r
.
v
dot
(
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
.
v
dot
(
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
.
v
dot
(
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
.
v
dot
(
s
)
if
gamma
.
real
<
0
:
self
.
logger
.
warn
(
"Positive definitness of preconditioner "
...
...
nifty/minimization/descent_minimizer.py
View file @
e8272dcf
...
...
@@ -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
.
v
dot
(
gradient
)
# check if position is at a flat point
if
gradient_norm
==
0
:
...
...
nifty/minimization/vl_bfgs.py
View file @
e8272dcf
...
...
@@ -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
].
v
dot
(
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
].
v
dot
(
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
].
v
dot
(
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
].
v
dot
(
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
].
v
dot
(
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
.
v
dot
(
self
.
last_gradient
)
def
add_new_point
(
self
,
x
,
gradient
):
"""Updates the s list and y list.
...
...
nifty/operators/composed_operator/composed_operator.py
View file @
e8272dcf
...
...
@@ -51,7 +51,7 @@ class ComposedOperator(LinearOperator):
Notes
-----
Very useful
l
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
...
...
nifty/probing/mixin_classes/trace_prober_mixin.py
View file @
e8272dcf
...
...
@@ -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
].
v
dot
(
pre_result
,
bare
=
True
)
self
.
__sum_of_probings
+=
result
if
self
.
compute_variance
:
self
.
__sum_of_squares
+=
result
.
conjugate
()
*
result
...
...
test/test_operators/test_composed_operator.py
View file @
e8272dcf
...
...
@@ -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
.
v
dot
(
op
.
times
(
rand1
))
tt2
=
rand1
.
v
dot
(
op
.
adjoint_times
(
rand2
))
assert_approx_equal
(
tt1
,
tt2
)
@
expand
(
product
(
spaces
,
spaces
))
...
...
test/test_operators/test_diagonal_operator.py
View file @
e8272dcf
...
...
@@ -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
.
v
dot
(
D
.
times
(
rand2
))
tt2
=
rand2
.
v
dot
(
D
.
times
(
rand1
))
assert_approx_equal
(
tt1
,
tt2
)
@
expand
(
product
(
spaces
,
[
True
,
False
],
[
True
,
False
]))
...
...
test/test_operators/test_fft_operator.py
View file @
e8272dcf
...
...
@@ -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
.
v
dot
(
out
))
v2
=
np
.
sqrt
(
inp
.
v
dot
(
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
.
v
dot
(
out
))
v2
=
np
.
sqrt
(
inp
.
v
dot
(
fft
.
adjoint_times
(
out
)))
assert_allclose
(
v1
,
v2
,
rtol
=
tol
,
atol
=
tol
)
test/test_operators/test_response_operator.py
View file @
e8272dcf
...
...
@@ -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
.
v
dot
(
op
.
times
(
rand1
))
tt2
=
rand1
.
v
dot
(
op
.
adjoint_times
(
rand2
))
assert_approx_equal
(
tt1
,
tt2
)
test/test_operators/test_smoothing_operator.py
View file @
e8272dcf
...
...
@@ -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
.
v
dot
(
op
.
times
(
rand2
))
tt2
=
rand2
.
v
dot
(
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
.
v
dot
(
op
.
inverse_times
(
rand2
))
tt2
=
rand2
.
v
dot
(
op
.
inverse_adjoint_times
(
rand1
))
assert_approx_equal
(
tt1
,
tt2
)
@
expand
(
product
([
100
,
200
],
[
1
,
0.4
],
[
0.
,
1.
,
3.7
],
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment