-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5c2ee6
commit 225eb9c
Showing
11 changed files
with
595 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import numpy as np | ||
from scipy.linalg import hankel | ||
|
||
|
||
class HankelProj: | ||
r"""Hankel matrix projection. | ||
Solves the least squares problem | ||
.. math:: | ||
\min_{X\in\mathcal{H}} \|X-X_0\|_F^2 | ||
where :math:`\mathcal{H}` is the set of Hankel matrices. | ||
Notes | ||
----- | ||
The solution to the above-mentioned least squares problem is given by a Hankel matrix, | ||
where the (constant) anti-diagonals are the average value along the corresponding | ||
anti-diagonals of the original matrix :math:`X_0`. | ||
""" | ||
|
||
def __call__(self, X): | ||
m, n = X.shape | ||
ind = hankel(np.arange(m, dtype=np.int32), m - 1 + np.arange(n, dtype=np.int32)) | ||
mean_values = np.bincount(ind.ravel(), weights=X.ravel()) / np.bincount(ind.ravel()) | ||
return mean_values[ind] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import numpy as np | ||
from pyproximal.ProxOperator import _check_tau | ||
from pyproximal import ProxOperator | ||
from pyproximal.projection import HankelProj | ||
|
||
|
||
class Hankel(ProxOperator): | ||
r"""Hankel proximal operator. | ||
Proximal operator of the Hankel matrix indicator function. | ||
Parameters | ||
---------- | ||
dim : :obj:`tuple` | ||
Dimension of the Hankel matrix. | ||
Notes | ||
----- | ||
As the Hankel Operator is an indicator function, the proximal operator corresponds to | ||
its orthogonal projection (see :class:`pyproximal.projection.HankelProj` for | ||
details). | ||
""" | ||
def __init__(self, dim): | ||
super().__init__(None, False) | ||
self.dim = dim | ||
self.hankel_proj = HankelProj() | ||
|
||
def __call__(self, x): | ||
X = x.reshape(self.dim) | ||
return np.allclose(X, self.hankel_proj(X)) | ||
|
||
@_check_tau | ||
def prox(self, x, tau): | ||
X = x.reshape(self.dim) | ||
return self.hankel_proj(X).ravel() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.