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
d9e254cd
Commit
d9e254cd
authored
Jun 28, 2018
by
Martin Reinecke
Browse files
allow subtraction and negation as well
parent
bae4a32b
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty5/minimization/energy.py
View file @
d9e254cd
...
...
@@ -140,7 +140,16 @@ class Energy(NiftyMetaBase()):
def
__add__
(
self
,
other
):
from
.energy_sum
import
EnergySum
from
..sugar
import
full
if
not
isinstance
(
other
,
Energy
):
raise
TypeError
(
"can only add Energies to Energies"
)
return
EnergySum
.
make
([
self
,
other
])
def
__sub__
(
self
,
other
):
from
.energy_sum
import
EnergySum
if
not
isinstance
(
other
,
Energy
):
raise
TypeError
(
"can only subtract Energies from Energies"
)
return
EnergySum
.
make
([
self
,
other
],
[
1.
,
-
1.
])
def
__neg__
(
self
):
from
.energy_sum
import
EnergySum
return
EnergySum
.
make
([
self
],
[
-
1.
])
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