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
02647cdc
Commit
02647cdc
authored
Feb 16, 2017
by
Theo Steininger
Browse files
Optimized set_diagonal in DiagonalOperator.
parent
cf834a3e
Pipeline
#10198
passed with stages
in 16 minutes and 5 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty/field.py
View file @
02647cdc
...
...
@@ -90,7 +90,7 @@ class Field(Loggable, Versionable, object):
elif
isinstance
(
val
,
Field
):
distribution_strategy
=
val
.
distribution_strategy
else
:
self
.
logger
.
info
(
"Datamodel set to default!"
)
self
.
logger
.
debug
(
"Datamodel set to default!"
)
distribution_strategy
=
gc
[
'default_distribution_strategy'
]
elif
distribution_strategy
not
in
DISTRIBUTION_STRATEGIES
[
'global'
]:
raise
ValueError
(
...
...
nifty/operators/diagonal_operator/diagonal_operator.py
View file @
02647cdc
...
...
@@ -90,10 +90,15 @@ class DiagonalOperator(EndomorphicOperator):
@
property
def
symmetric
(
self
):
if
self
.
_symmetric
is
None
:
self
.
_symmetric
=
(
self
.
_diagonal
.
val
.
imag
==
0
).
all
()
return
self
.
_symmetric
@
property
def
unitary
(
self
):
if
self
.
_unitary
is
None
:
self
.
_unitary
=
(
self
.
_diagonal
.
val
*
self
.
_diagonal
.
val
.
conjugate
()
==
1
).
all
()
return
self
.
_unitary
# ---Added properties and methods---
...
...
@@ -134,11 +139,11 @@ class DiagonalOperator(EndomorphicOperator):
# Otherwise, inplace weightening would change the external field
f
.
weight
(
inplace
=
copy
,
power
=-
1
)
#
check if the operator is symmetric
:
self
.
_symmetric
=
(
f
.
val
.
imag
==
0
).
all
()
#
Reset the symmetric property
:
self
.
_symmetric
=
None
#
check if the operator is unitary:
self
.
_unitary
=
(
f
.
val
*
f
.
val
.
conjugate
()
==
1
).
all
()
#
Reset the unitarity property
self
.
_unitary
=
None
# store the diagonal-field
self
.
_diagonal
=
f
...
...
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