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
nam
ProxPython
Commits
0fbfec7b
Commit
0fbfec7b
authored
Mar 19, 2019
by
robin.requadt
Browse files
Upload New File
parent
cb0297bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
proxtoolbox/P_S.py
0 → 100644
View file @
0fbfec7b
from
proxoperators
import
ProxOperator
import
numpy
as
np
class
P_S
(
ProxOperator
):
"""
Projection onto support constraints
"""
def
__init__
(
self
,
config
):
"""
Initialization
Parameters
----------
config : dict - Dictionary containing the problem configuration. It must contain the following mapping:
'support :idx' : array_like - a vector of indeces of the nonzero elements of the array.
"""
self
.
n
=
config
[
'support_idx'
]
def
work
(
self
,
u
):
"""
Applies the proxoperator P_S
Parameters
----------
u : array_like - array to be projected
Returns
-------
p_S : array_like - the Projection
"""
n
=
self
.
n
p_S
=
np
.
zeros
(
u
.
shape
,
dtype
=
u
.
dtype
)
for
x
in
n
:
p_S
[
x
]
=
u
[
x
]
return
p_S
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