Skip to content
GitLab
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
c24d275b
Commit
c24d275b
authored
May 29, 2020
by
Philipp Arras
Browse files
Refactoring
parent
6251760d
Pipeline
#75764
passed with stages
in 13 minutes and 6 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/operators/energy_operators.py
View file @
c24d275b
...
...
@@ -150,21 +150,21 @@ class VariableCovarianceGaussianEnergy(EnergyOperator):
"""
def
__init__
(
self
,
domain
,
residual_key
,
inverse_covariance_key
,
sampling_dtype
):
self
.
_r
=
str
(
residual_key
)
self
.
_i
cov
=
str
(
inverse_covariance_key
)
self
.
_
k
r
=
str
(
residual_key
)
self
.
_
k
i
=
str
(
inverse_covariance_key
)
dom
=
DomainTuple
.
make
(
domain
)
self
.
_domain
=
MultiDomain
.
make
({
self
.
_r
:
dom
,
self
.
_i
cov
:
dom
})
self
.
_
sampling_dtype
=
sampling_dtype
self
.
_domain
=
MultiDomain
.
make
({
self
.
_
k
r
:
dom
,
self
.
_
k
i
:
dom
})
self
.
_
dt
=
sampling_dtype
_check_sampling_dtype
(
self
.
_domain
,
sampling_dtype
)
def
apply
(
self
,
x
):
self
.
_check_input
(
x
)
res
=
0.5
*
(
x
[
self
.
_r
].
vdot
(
x
[
self
.
_r
]
*
x
[
self
.
_icov
].
real
).
real
-
x
[
self
.
_icov
].
ptw
(
"log"
).
sum
())
r
,
i
=
x
[
self
.
_kr
],
x
[
self
.
_ki
]
res
=
0.5
*
(
r
.
vdot
(
r
*
i
.
real
).
real
-
i
.
ptw
(
"log"
).
sum
())
if
not
x
.
want_metric
:
return
res
mf
=
{
self
.
_r
:
x
.
val
[
self
.
_icov
],
self
.
_icov
:
.
5
*
x
.
val
[
self
.
_icov
]
**
(
-
2
)}
met
=
makeOp
(
MultiField
.
from_dict
(
mf
))
return
res
.
add_metric
(
SamplingDtypeSetter
(
met
,
self
.
_sampling_dtype
))
met
=
MultiField
.
from_dict
({
self
.
_kr
:
i
.
val
,
self
.
_ki
:
.
5
*
i
.
val
**
(
-
2
)})
return
res
.
add_metric
(
SamplingDtypeSetter
(
makeOp
(
met
),
self
.
_dt
))
class
GaussianEnergy
(
EnergyOperator
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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