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
a9652e2c
Commit
a9652e2c
authored
Jul 22, 2019
by
Philipp Arras
Browse files
Add approximation stuff to nifty
parent
3e46f282
Pipeline
#52283
passed with stages
in 8 minutes and 21 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty5/__init__.py
View file @
a9652e2c
...
...
@@ -54,7 +54,7 @@ from .operators.energy_operators import (
from
.operators.convolution_operators
import
FuncConvolutionOperator
from
.probing
import
probe_with_posterior_samples
,
probe_diagonal
,
\
StatCalculator
StatCalculator
,
approximation2endo
from
.minimization.line_search
import
LineSearch
from
.minimization.iteration_controllers
import
(
...
...
nifty5/probing.py
View file @
a9652e2c
...
...
@@ -134,3 +134,18 @@ def probe_diagonal(op, nprobes, random_type="pm1"):
x
=
from_random
(
random_type
,
op
.
domain
)
sc
.
add
(
op
(
x
).
conjugate
()
*
x
)
return
sc
.
mean
def
approximation2endo
(
op
,
nsamples
):
from
.sugar
import
from_global_data
from
.multi_field
import
MultiField
sc
=
StatCalculator
()
for
_
in
range
(
nsamples
):
sc
.
add
(
op
.
draw_sample
())
approx
=
sc
.
var
dct
=
approx
.
to_dict
()
for
kk
in
dct
:
foo
=
dct
[
kk
].
to_global_data_rw
()
foo
[
foo
==
0
]
=
1
dct
[
kk
]
=
from_global_data
(
dct
[
kk
].
domain
,
foo
)
return
MultiField
.
from_dict
(
dct
)
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