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
fe1ce4a4
Commit
fe1ce4a4
authored
Mar 23, 2018
by
Martin Reinecke
Browse files
Merge branch 'NIFTy_4' into diag_hack
parents
38f2fc5c
83c74e7b
Pipeline
#26417
passed with stage
in 5 minutes and 47 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty4/minimization/quadratic_energy.py
View file @
fe1ce4a4
...
...
@@ -31,12 +31,14 @@ class QuadraticEnergy(Energy):
self
.
_b
=
b
if
_grad
is
not
None
:
self
.
_grad
=
_grad
Ax
=
_grad
+
self
.
_
b
Ax
=
_grad
if
b
is
None
else
_grad
+
b
else
:
Ax
=
self
.
_A
(
self
.
position
)
self
.
_grad
=
Ax
-
self
.
_
b
self
.
_grad
=
Ax
if
b
is
None
else
Ax
-
b
self
.
_grad
.
lock
()
self
.
_value
=
0.5
*
self
.
position
.
vdot
(
Ax
)
-
b
.
vdot
(
self
.
position
)
self
.
_value
=
0.5
*
self
.
position
.
vdot
(
Ax
)
if
b
is
not
None
:
self
.
_value
-=
b
.
vdot
(
self
.
position
)
def
at
(
self
,
position
):
return
QuadraticEnergy
(
position
=
position
,
A
=
self
.
_A
,
b
=
self
.
_b
)
...
...
nifty4/utilities.py
View file @
fe1ce4a4
...
...
@@ -84,6 +84,8 @@ def parse_spaces(spaces, nspc):
spaces
=
(
safe_cast
(
int
,
spaces
),)
else
:
spaces
=
tuple
(
safe_cast
(
int
,
item
)
for
item
in
spaces
)
if
len
(
spaces
)
==
0
:
return
spaces
tmp
=
tuple
(
set
(
spaces
))
if
tmp
[
0
]
<
0
or
tmp
[
-
1
]
>=
nspc
:
raise
ValueError
(
"space index out of range"
)
...
...
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