Commit 79cdb60e by jansen31

### symmetric sparsity constraint implemented

parent 22df3d31
 ... ... @@ -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' ... ...
 ... ... @@ -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
 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 ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment