Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
nam
ProxPython
Commits
79cdb60e
Commit
79cdb60e
authored
Jun 12, 2019
by
jansen31
Browse files
symmetric sparsity constraint implemented
parent
22df3d31
Changes
3
Hide whitespace changes
Inline
Side-by-side
proxtoolbox/Problems/OrbitalTomog/phase.py
View file @
79cdb60e
...
...
@@ -66,6 +66,12 @@ class Phase(Problem):
used_proxoperators
[
0
]
=
'P_Sparsity_real'
elif
self
.
config
[
'constraint'
]
==
'sparse complex'
:
used_proxoperators
[
0
]
=
'P_Sparsity'
elif
self
.
config
[
'constraint'
]
in
[
'symmetric sparse real'
,
'sparse symmetric real'
]:
used_proxoperators
[
0
]
=
'P_Sparsity_Symmetric_real'
elif
self
.
config
[
'constraint'
]
in
[
'symmetric sparse complex'
,
'symmetric sparse complex'
]:
used_proxoperators
[
0
]
=
'P_Sparsity_Symmetric'
else
:
raise
ValueError
(
'Constraint not recognized'
)
# Projector 2 (k / Fourier space)
# used_proxoperators[1] = 'P_M' # 'Approx_P_FreFra_Poisson'
...
...
proxtoolbox/ProxOperators/P_Sparsity.py
View file @
79cdb60e
...
...
@@ -74,3 +74,28 @@ class P_Sparsity_real(P_Sparsity):
def
work
(
self
,
u
):
return
super
(
P_Sparsity_real
,
self
).
work
(
u
.
real
)
class
P_Sparsity_Symmetric
(
P_Sparsity
):
def
__init__
(
self
,
config
):
super
(
P_Sparsity_Symmetric
,
self
).
__init__
(
config
=
config
)
self
.
symmetry
=
config
[
'symmetry type'
]
# antisymmetric = -1, symmetric = 1
self
.
symmetry_axis
=
config
[
'symmetry axis'
]
# -1 for last, 0 for first, 'both', 'all' or None for full flip
def
work
(
self
,
u
):
if
self
.
symmetry_axis
in
[
'both'
,
'all'
]:
mirror
=
np
.
flip
(
u
,
axis
=
None
)
else
:
mirror
=
np
.
flip
(
u
,
axis
=
self
.
symmetry_axis
)
inp
=
(
u
+
self
.
symmetry
*
mirror
)
/
2
out
=
super
(
P_Sparsity_Symmetric
,
self
).
work
(
inp
)
return
out
class
P_Sparsity_Symmetric_real
(
P_Sparsity_Symmetric
):
def
__init__
(
self
,
config
):
super
(
P_Sparsity_Symmetric_real
,
self
).
__init__
(
config
=
config
)
def
work
(
self
,
u
):
out
=
super
(
P_Sparsity_Symmetric_real
,
self
).
work
(
u
.
real
)
return
out
\ No newline at end of file
proxtoolbox/ProxOperators/P_binary.py
View file @
79cdb60e
import
numpy
as
np
from
numpy
import
shape
,
real
,
zeros
from
proxoperators
import
ProxOperator
from
.
proxoperators
import
ProxOperator
#original matlab comment
# written on May 23, 2002 by
# Russell Luke
...
...
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