Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
96be7ff9
Commit
96be7ff9
authored
Oct 04, 2017
by
Martin Reinecke
Browse files
remove the (unused and obsolete) projection operator
parent
41879da1
Pipeline
#19220
passed with stage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty/operators/__init__.py
View file @
96be7ff9
...
...
@@ -30,8 +30,6 @@ from .fft_operator import *
from
.invertible_operator_mixin
import
InvertibleOperatorMixin
from
.projection_operator
import
ProjectionOperator
from
.composed_operator
import
ComposedOperator
from
.response_operator
import
ResponseOperator
...
...
nifty/operators/projection_operator/__init__.py
deleted
100644 → 0
View file @
41879da1
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-2017 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
.projection_operator
import
ProjectionOperator
nifty/operators/projection_operator/projection_operator.py
deleted
100644 → 0
View file @
41879da1
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-2017 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
builtins
import
range
import
numpy
as
np
from
...field
import
Field
from
..endomorphic_operator
import
EndomorphicOperator
class
ProjectionOperator
(
EndomorphicOperator
):
""" NIFTY class for projection operators.
The NIFTY ProjectionOperator class is a class derived from the
EndomorphicOperator.
Parameters
----------
projection_field : Field
Field on which the operator projects
default_spaces : tuple of ints *optional*
Defines on which space(s) of a given field the Operator acts by
default (default: None)
Attributes
----------
domain : tuple of DomainObjects, i.e. Spaces and FieldTypes
The domain on which the Operator's input Field lives.
target : tuple of DomainObjects, i.e. Spaces and FieldTypes
The domain in which the outcome of the operator lives. As the Operator
is endomorphic this is the same as its domain.
unitary : boolean
Indicates whether the Operator is unitary or not.
self_adjoint : boolean
Indicates whether the operator is self_adjoint or not.
Raises
------
TypeError
Raised if
* if projection_field is not a Field
See Also
--------
EndomorphicOperator
"""
# ---Overwritten properties and methods---
def
__init__
(
self
,
projection_field
,
default_spaces
=
None
):
super
(
ProjectionOperator
,
self
).
__init__
(
default_spaces
)
if
not
isinstance
(
projection_field
,
Field
):
raise
TypeError
(
"The projection_field must be a NIFTy-Field"
"instance."
)
self
.
_projection_field
=
projection_field
self
.
_unitary
=
None
def
_times
(
self
,
x
,
spaces
):
# if the domain matches directly
# -> multiply the fields directly
if
x
.
domain
==
self
.
domain
:
# here the actual multiplication takes place
dotted
=
(
self
.
_projection_field
*
x
).
sum
()
return
self
.
_projection_field
*
dotted
# if the distribution_strategy of self is sub-slice compatible to
# the one of x, reshape the local data of self and apply it directly
active_axes
=
[]
if
spaces
is
None
:
active_axes
=
list
(
range
(
len
(
x
.
shape
)))
else
:
for
space_index
in
spaces
:
active_axes
+=
x
.
domain
.
axes
[
space_index
]
local_projection_vector
=
self
.
_projection_field
.
val
local_x
=
x
.
val
l
=
len
(
local_projection_vector
.
shape
)
sublist_projector
=
list
(
range
(
l
))
sublist_x
=
np
.
arange
(
len
(
local_x
.
shape
))
+
l
for
i
in
range
(
l
):
a
=
active_axes
[
i
]
sublist_x
[
a
]
=
i
dotted
=
np
.
einsum
(
local_projection_vector
,
sublist_projector
,
local_x
,
sublist_x
)
# get those elements from sublist_x that haven't got contracted
sublist_dotted
=
sublist_x
[
sublist_x
>=
l
]
remultiplied
=
np
.
einsum
(
local_projection_vector
,
sublist_projector
,
dotted
,
sublist_dotted
,
sublist_x
)
return
Field
(
x
.
domain
,
remultiplied
,
x
.
dtype
)
def
_inverse_times
(
self
,
x
,
spaces
):
raise
NotImplementedError
(
"The ProjectionOperator is a singular "
"operator and therefore has no inverse."
)
# ---Mandatory properties and methods---
@
property
def
domain
(
self
):
return
self
.
_projection_field
.
domain
@
property
def
unitary
(
self
):
if
self
.
_unitary
is
None
:
self
.
_unitary
=
(
self
.
_projection_field
.
val
==
1
).
all
()
return
self
.
_unitary
@
property
def
self_adjoint
(
self
):
return
True
# ---Added properties and methods---
@
property
def
projection_field
(
self
):
return
self
.
_projection_field
Write
Preview
Markdown
is supported
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