Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
2a7ee176
Commit
2a7ee176
authored
Jul 02, 2017
by
Theo Steininger
Browse files
Merge branch 'master' of gitlab.mpcdf.mpg.de:ift/NIFTy
parents
ab7c9479
70b3d873
Pipeline
#14269
passed with stages
in 11 minutes and 2 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
nifty/minimization/conjugate_gradient.py
View file @
2a7ee176
...
@@ -121,13 +121,13 @@ class ConjugateGradient(Loggable, object):
...
@@ -121,13 +121,13 @@ class ConjugateGradient(Loggable, object):
r
=
b
-
A
(
x0
)
r
=
b
-
A
(
x0
)
d
=
self
.
preconditioner
(
r
)
d
=
self
.
preconditioner
(
r
)
previous_gamma
=
r
.
vdot
(
d
)
previous_gamma
=
(
r
.
vdot
(
d
)
).
real
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
.
vdot
(
b
))
norm_b
=
np
.
sqrt
(
(
b
.
vdot
(
b
))
.
real
)
x
=
x0
x
=
x0
.
copy
()
convergence
=
0
convergence
=
0
iteration_number
=
1
iteration_number
=
1
self
.
logger
.
info
(
"Starting conjugate gradient."
)
self
.
logger
.
info
(
"Starting conjugate gradient."
)
...
@@ -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
.
vdot
(
q
)
alpha
=
previous_gamma
/
d
.
vdot
(
q
)
.
real
if
not
np
.
isfinite
(
alpha
):
if
not
np
.
isfinite
(
alpha
):
self
.
logger
.
error
(
"Alpha became infinite! Stopping."
)
self
.
logger
.
error
(
"Alpha became infinite! Stopping."
)
...
@@ -146,7 +146,7 @@ class ConjugateGradient(Loggable, object):
...
@@ -146,7 +146,7 @@ class ConjugateGradient(Loggable, object):
x
+=
d
*
alpha
x
+=
d
*
alpha
reset
=
False
reset
=
False
if
alpha
.
real
<
0
:
if
alpha
<
0
:
self
.
logger
.
warn
(
"Positive definiteness of A violated!"
)
self
.
logger
.
warn
(
"Positive definiteness of A violated!"
)
reset
=
True
reset
=
True
if
self
.
reset_count
is
not
None
:
if
self
.
reset_count
is
not
None
:
...
@@ -158,9 +158,9 @@ class ConjugateGradient(Loggable, object):
...
@@ -158,9 +158,9 @@ class ConjugateGradient(Loggable, object):
r
-=
q
*
alpha
r
-=
q
*
alpha
s
=
self
.
preconditioner
(
r
)
s
=
self
.
preconditioner
(
r
)
gamma
=
r
.
vdot
(
s
)
gamma
=
r
.
vdot
(
s
)
.
real
if
gamma
.
real
<
0
:
if
gamma
<
0
:
self
.
logger
.
warn
(
"Positive definitness of preconditioner "
self
.
logger
.
warn
(
"Positive definitness of preconditioner "
"violated!"
)
"violated!"
)
...
@@ -170,10 +170,7 @@ class ConjugateGradient(Loggable, object):
...
@@ -170,10 +170,7 @@ class ConjugateGradient(Loggable, object):
self
.
logger
.
debug
(
"Iteration : %08u alpha = %3.1E "
self
.
logger
.
debug
(
"Iteration : %08u alpha = %3.1E "
"beta = %3.1E delta = %3.1E"
%
"beta = %3.1E delta = %3.1E"
%
(
iteration_number
,
(
iteration_number
,
alpha
,
beta
,
delta
))
np
.
real
(
alpha
),
np
.
real
(
beta
),
np
.
real
(
delta
)))
if
gamma
==
0
:
if
gamma
==
0
:
convergence
=
self
.
convergence_level
+
1
convergence
=
self
.
convergence_level
+
1
...
...
nifty/spaces/lm_space/lm_space.py
View file @
2a7ee176
...
@@ -165,7 +165,9 @@ class LMSpace(Space):
...
@@ -165,7 +165,9 @@ class LMSpace(Space):
return
res
return
res
def
get_fft_smoothing_kernel_function
(
self
,
sigma
):
def
get_fft_smoothing_kernel_function
(
self
,
sigma
):
# FIXME why x(x+1) ? add reference to paper!
# cf. "All-sky convolution for polarimetry experiments"
# by Challinor et al.
# http://arxiv.org/abs/astro-ph/0008228
return
lambda
x
:
np
.
exp
(
-
0.5
*
x
*
(
x
+
1
)
*
sigma
*
sigma
)
return
lambda
x
:
np
.
exp
(
-
0.5
*
x
*
(
x
+
1
)
*
sigma
*
sigma
)
# ---Added properties and methods---
# ---Added properties and methods---
...
...
nifty/spaces/rg_space/rg_space.py
View file @
2a7ee176
...
@@ -284,7 +284,7 @@ class RGSpace(Space):
...
@@ -284,7 +284,7 @@ class RGSpace(Space):
return
dists
return
dists
def
get_fft_smoothing_kernel_function
(
self
,
sigma
):
def
get_fft_smoothing_kernel_function
(
self
,
sigma
):
return
lambda
x
:
np
.
exp
(
-
0.5
*
np
.
pi
*
np
.
pi
*
x
*
x
*
sigma
*
sigma
)
return
lambda
x
:
np
.
exp
(
-
2.
*
np
.
pi
*
np
.
pi
*
x
*
x
*
sigma
*
sigma
)
# ---Added properties and methods---
# ---Added properties and methods---
...
...
Write
Preview
Markdown
is supported
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