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
698bc932
Commit
698bc932
authored
Mar 06, 2020
by
Reimar Leike
Browse files
added .sum and .vdot method to operator and used them in energy_operators.py
parent
76568d69
Pipeline
#70351
passed with stages
in 15 minutes and 32 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty6/operators/energy_operators.py
View file @
698bc932
...
...
@@ -134,10 +134,8 @@ class VariableCovarianceGaussianEnergy(EnergyOperator):
lin
=
isinstance
(
x
,
Linearization
)
r
=
FieldAdapter
(
self
.
_domain
[
self
.
_r
],
self
.
_r
)
icov
=
FieldAdapter
(
self
.
_domain
[
self
.
_icov
],
self
.
_icov
)
res0
=
r
.
conjugate
()
*
r
*
icov
sum_it
=
ContractionOperator
(
res0
.
target
,
None
)
res0
=
sum_it
(
res0
).
real
res1
=
sum_it
(
icov
.
log
())
res0
=
r
.
vdot
(
r
*
icov
).
real
res1
=
icov
.
log
().
sum
()
res
=
0.5
*
(
res0
-
res1
)
res
=
res
(
x
)
if
not
lin
:
...
...
nifty6/operators/operator.py
View file @
698bc932
...
...
@@ -66,6 +66,13 @@ class Operator(metaclass=NiftyMeta):
from
.simple_linear_operators
import
ConjugationOperator
return
ConjugationOperator
(
self
.
target
)(
self
)
def
sum
(
self
,
spaces
=
None
):
from
.contraction_operator
import
ContractionOperator
return
ContractionOperator
(
self
.
target
,
spaces
)(
self
)
def
vdot
(
self
,
other
):
return
(
self
.
conjugate
()
*
other
).
sum
()
@
property
def
real
(
self
):
from
.simple_linear_operators
import
Realizer
...
...
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