Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pyproximal/proximal/L1.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ class L1(ProxOperator):
r"""L1 norm proximal operator.

Proximal operator of the :math:`\ell_1` norm:
:math:`\sigma\|\mathbf{x} - \mathbf{g}\|_1 = \sigma \sum |x_i - g_i|`.

- :math:`\sigma\|\mathbf{x} - \mathbf{g}\|_1 = \sigma \sum_i |x_i - g_i|` for
1-dimensional arrays;
- :math:`\sum_j \sigma_j \|\mathbf{X}_j - \mathbf{g}\|_1 = \sum_j \sigma_j \sum_i |x_{i,j} - g_i|`
for 2-dimensional arrays.

Parameters
----------
sigma : :obj:`float` or :obj:`np.ndarray` or :obj:`func`, optional
Multiplicative coefficient of L1 norm. This can be a constant number, a list
of values (for multidimensional inputs, acting on the second dimension) or
of values (for 2-dimensional inputs, acting on the second dimension) or
a function that is called passing a counter which keeps track of how many
times the ``prox`` method has been invoked before and returns a scalar (or a list of)
``sigma`` to be used.
Expand Down Expand Up @@ -117,8 +121,8 @@ def __init__(
def __call__(self, x: NDArray) -> float:
sigma = _current_sigma(self.sigma, self.count)
if self.g is None:
return float(sigma * np.sum(np.abs(x)))
return float(sigma * np.sum(np.abs(x - self.g)))
return float(np.sum(sigma * np.sum(np.abs(x), axis=0)))
return float(np.sum(sigma * np.sum(np.abs(x - self.g), axis=0)))

def _increment_count(func: Callable[..., Any]) -> Callable[..., Any]:
"""Increment counter"""
Expand Down
Loading