@proxify<EOL>def smooth(x, rho, penalty, axis=<NUM_LIT:0>, newshape=None):
orig_shape = x.shape<EOL>if newshape is not None:<EOL><INDENT>x = x.reshape(newshape)<EOL><DEDENT>n = x.shape[axis]<EOL>lap_op = spdiags([(<NUM_LIT:2> + rho / penalty) * np.ones(n),<EOL>-<NUM_LIT:1> * np.ones(n), -<NUM_LIT:1> * np.ones(n)],<EOL>[<NUM_LIT:0>, -<NUM_LIT:1>, <NUM_LIT:1>], n, n, format='<STR_LIT>')<EOL>A = penalty * lap_op<EOL>b = rho * np.rollaxis(x, axis, <NUM_LIT:0>)<EOL>return np.rollaxis(spsolve(A, b), axis, <NUM_LIT:0>).reshape(orig_shape)<EOL>
Applies a smoothing operator along one dimension

currently only accepts a matrix as input

Parameters
----------
penalty : float

axis : int, optional
    Axis along which to apply the smoothing (Default: 0)

newshape : tuple, optional
    Desired shape of the parameters to apply the nuclear norm to. The given
    parameters are reshaped to an array with this shape, or not reshaped if
    the value of newshape is None. (Default: None)