Skip to content

Commit

Permalink
adds a smoothing proximal operator
Browse files Browse the repository at this point in the history
  • Loading branch information
Niru Maheswaranathan committed Oct 6, 2015
1 parent 071230d commit 19bcd08
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions proxalgs/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,14 @@ def bfgs(x0, rho, f, fgrad):


@curry
def smooth(x0, rho, gamma):
def smooth(x0, rho, gamma, axis=0):
"""
Proximal operator for a smoothing function enforced via the discrete laplacian operator
Notes
-----
Currently only works with matrices (2-D arrays) as input
Parameters
----------
x0 : array_like
Expand All @@ -187,9 +191,9 @@ def smooth(x0, rho, gamma):
"""

# Apply Laplacian smoothing
n = x0.shape[0]
n = x0.shape[axis]
lap_op = spdiags([(2 + rho / gamma) * np.ones(n), -1 * np.ones(n), -1 * np.ones(n)], [0, -1, 1], n, n, format='csc')
x_out = spsolve(gamma * lap_op, rho * x0)
x_out = np.rollaxis(spsolve(gamma * lap_op, rho * np.rollaxis(x0, axis, 0)), axis, 0)

return x_out

Expand Down

0 comments on commit 19bcd08

Please sign in to comment.