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
21f72f3c
Commit
21f72f3c
authored
Nov 06, 2017
by
Martin Reinecke
Browse files
merge nifty2go
parents
a2690f08
352cd0f7
Pipeline
#21107
passed with stage
in 4 minutes and 11 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty/operators/diagonal_operator.py
View file @
21f72f3c
...
...
@@ -25,7 +25,6 @@ from ..nifty_utilities import cast_iseq_to_tuple
from
..dobj
import
to_ndarray
as
to_np
class
DiagonalOperator
(
EndomorphicOperator
):
""" NIFTY class for diagonal operators.
...
...
@@ -93,6 +92,16 @@ class DiagonalOperator(EndomorphicOperator):
for
i
,
j
in
enumerate
(
self
.
_spaces
):
if
diagonal
.
domain
[
i
]
!=
self
.
_domain
[
j
]:
raise
ValueError
(
"domain mismatch"
)
if
self
.
_spaces
==
tuple
(
range
(
len
(
self
.
_domain
.
domains
))):
self
.
_spaces
=
None
# shortcut
if
self
.
_spaces
is
not
None
:
active_axes
=
[]
for
space_index
in
self
.
_spaces
:
active_axes
+=
self
.
_domain
.
axes
[
space_index
]
self
.
_reshaper
=
[
shp
if
i
in
active_axes
else
1
for
i
,
shp
in
enumerate
(
self
.
_domain
.
shape
)]
self
.
_diagonal
=
diagonal
.
copy
()
self
.
_self_adjoint
=
None
...
...
@@ -143,13 +152,5 @@ class DiagonalOperator(EndomorphicOperator):
if
self
.
_spaces
is
None
:
return
diag
*
x
active_axes
=
[]
for
space_index
in
self
.
_spaces
:
active_axes
+=
x
.
domain
.
axes
[
space_index
]
reshaper
=
[
shp
if
i
in
active_axes
else
1
for
i
,
shp
in
enumerate
(
x
.
shape
)]
reshaped_local_diagonal
=
to_np
(
diag
.
val
).
reshape
(
reshaper
)
# here the actual multiplication takes place
reshaped_local_diagonal
=
np
.
reshape
(
to_np
(
diag
.
val
),
self
.
_reshaper
)
return
Field
(
x
.
domain
,
val
=
x
.
val
*
reshaped_local_diagonal
)
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